Print this page
OS-4741 Add support for multiple addresses & IPv6 to lx-branded zones
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdhcpagent/common/dhcpagent_util.c
          +++ new/usr/src/lib/libdhcpagent/common/dhcpagent_util.c
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29  #include <sys/socket.h>
  30   30  #include <sys/time.h>
  31   31  #include <sys/wait.h>
  32   32  #include <fcntl.h>
  33   33  #include <libcontract.h>
  34   34  #include <libcontract_priv.h>
  35   35  #include <unistd.h>
  36   36  #include <stdio.h>
  37   37  #include <stdlib.h>
  38   38  #include <string.h>
       39 +#include <zone.h>
  39   40  
  40   41  #include "dhcpagent_ipc.h"
  41   42  #include "dhcpagent_util.h"
  42   43  
  43   44  /*
  44   45   * Strings returned by dhcp_status_hdr_string() and
  45   46   * dhcp_status_reply_to_string(). The first define is the header line, and
  46   47   * the second defines line printed underneath.
  47   48   * The spacing of fields must match.
  48   49   */
↓ open down ↓ 69 lines elided ↑ open up ↑
 118  119  int
 119  120  dhcp_start_agent(int timeout)
 120  121  {
 121  122          int                     error;
 122  123          time_t                  start_time = time(NULL);
 123  124          dhcp_ipc_request_t      *request;
 124  125          dhcp_ipc_reply_t        *reply;
 125  126          int                     ctfd;
 126  127          pid_t                   childpid;
 127  128          ctid_t                  ct;
      129 +        char                    dhcpcmd[MAXPATHLEN];
      130 +        const char              *zroot = zone_get_nroot();
 128  131  
      132 +        /* Prepend the root of the native code in the brand to the command */
      133 +        (void) snprintf(dhcpcmd, sizeof (dhcpcmd), "%s%s", zroot != NULL ?
      134 +            zroot : "", DHCP_AGENT_PATH);
      135 +
 129  136          /*
 130  137           * just send a dummy request to the agent to find out if it's
 131  138           * up.  we do this instead of directly connecting to it since
 132  139           * we want to make sure we follow its IPC conventions
 133  140           * (otherwise, it will log warnings to syslog).
 134  141           */
 135  142  
 136  143          request = dhcp_ipc_alloc_request(DHCP_PING, "", NULL, 0,
 137  144              DHCP_TYPE_NONE);
 138  145          if (request == NULL)
↓ open down ↓ 14 lines elided ↑ open up ↑
 153  160          childpid = fork();
 154  161  
 155  162          (void) ct_tmpl_clear(ctfd);
 156  163          (void) close(ctfd);
 157  164  
 158  165          switch (childpid) {
 159  166          case -1:
 160  167                  goto fail;
 161  168  
 162  169          case  0:
 163      -                (void) execl(DHCP_AGENT_PATH, DHCP_AGENT_PATH, (char *)0);
      170 +                (void) execl(dhcpcmd, dhcpcmd, (char *)0);
 164  171                  _exit(EXIT_FAILURE);
 165  172  
 166  173          default:
 167  174                  break;
 168  175          }
 169  176  
 170  177          /* wait for the daemon to run and then abandon the contract */
 171  178          (void) waitpid(childpid, NULL, 0);
 172  179  
 173  180          if (contract_latest(&ct) != -1)
↓ open down ↓ 108 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX