Print this page
OS-4807 arp(1M) and ndp(1M) should use zone_get_nroot()

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/usr.sbin/arp.c
          +++ new/usr/src/cmd/cmd-inet/usr.sbin/arp.c
↓ open down ↓ 50 lines elided ↑ open up ↑
  51   51  #include <errno.h>
  52   52  #include <netdb.h>
  53   53  #include <net/if.h>
  54   54  #include <net/if_arp.h>
  55   55  #include <stdlib.h>
  56   56  #include <unistd.h>
  57   57  #include <string.h>
  58   58  #include <arpa/inet.h>
  59   59  #include <net/if_types.h>
  60   60  #include <net/if_dl.h>
       61 +#include <zone.h>
  61   62  
  62   63  static int file(char *);
  63   64  static int set(int, char *[]);
  64   65  static void get(char *);
  65   66  static void delete(char *);
  66   67  static void usage(void);
  67   68  
  68   69  int
  69   70  main(int argc, char *argv[])
  70   71  {
↓ open down ↓ 40 lines elided ↑ open up ↑
 111  112          }
 112  113  
 113  114          argsleft = argc - optind;
 114  115  
 115  116          if (a_flag && (argsleft == 0)) {
 116  117                  /*
 117  118                   * the easiest way to get the complete arp table
 118  119                   * is to let netstat, which prints it as part of
 119  120                   * the MIB statistics, do it.
 120  121                   */
 121      -                (void) execl("/usr/bin/netstat", "netstat",
      122 +                char netstat_path[MAXPATHLEN];
      123 +                const char *zroot = zone_get_nroot();
      124 +                (void) snprintf(netstat_path, sizeof (netstat_path), "%s%s", zroot != NULL ?
      125 +                    zroot : "", "/usr/bin/netstat");
      126 +                (void) execl(netstat_path, "netstat",
 122  127                      (n_flag ? "-np" : "-p"),
 123  128                      "-f", "inet", (char *)0);
 124      -                (void) fprintf(stderr, "failed to exec netstat: %s\n",
 125      -                    strerror(errno));
      129 +                (void) fprintf(stderr, "failed to exec %s: %s\n",
      130 +                    netstat_path, strerror(errno));
 126  131                  exit(1);
 127  132  
 128  133          } else if (s_flag && (argsleft >= 2)) {
 129  134                  if (set(argsleft, &argv[optind]) != 0)
 130  135                          exit(1);
 131  136  
 132  137          } else if (d_flag && (argsleft == 1)) {
 133  138                  delete(argv[optind]);
 134  139  
 135  140          } else if (f_flag && (argsleft == 1)) {
↓ open down ↓ 278 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX