Changeset 50551 in vbox
- Timestamp:
- Feb 24, 2014 9:31:41 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92405
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r44529 r50551 27 27 #include <sys/wait.h> 28 28 #include <sys/ioctl.h> 29 #include <sys/stat.h> 29 30 #include <fcntl.h> 30 31 #ifdef RT_OS_LINUX … … 62 63 typedef VBOXNETADPREQ *PVBOXNETADPREQ; 63 64 64 65 #define VBOXADPCTL_IFCONFIG_PATH "/sbin/ifconfig" 65 #define VBOXADPCTL_IFCONFIG_PATH1 "/sbin/ifconfig" 66 #define VBOXADPCTL_IFCONFIG_PATH2 "/bin/ifconfig" 67 static char *g_pszIfConfig; 66 68 67 69 #if defined(RT_OS_LINUX) … … 83 85 } 84 86 87 static void setPathIfConfig(void) 88 { 89 struct stat s; 90 if ( !stat(VBOXADPCTL_IFCONFIG_PATH1, &s) 91 && S_ISREG(s.st_mode)) 92 g_pszIfConfig = (char*)VBOXADPCTL_IFCONFIG_PATH1; 93 else 94 g_pszIfConfig = (char*)VBOXADPCTL_IFCONFIG_PATH2; 95 } 96 85 97 static int executeIfconfig(const char *pcszAdapterName, const char *pcszArg1, 86 98 const char *pcszArg2 = NULL, … … 91 103 const char * const argv[] = 92 104 { 93 VBOXADPCTL_IFCONFIG_PATH,105 g_pszIfConfig, 94 106 pcszAdapterName, 95 107 pcszArg1, /* [address family] */ … … 110 122 break; 111 123 case 0: /* Child process. */ 112 if (execve( VBOXADPCTL_IFCONFIG_PATH, (char * const*)argv, envp) == -1)124 if (execve(argv[0], (char * const*)argv, envp) == -1) 113 125 rc = EXIT_FAILURE; 114 126 break; … … 130 142 int rc; 131 143 int fds[2]; 132 char * const argv[] = { (char*)VBOXADPCTL_IFCONFIG_PATH, pszAdapterName, NULL };144 char * const argv[] = { g_pszIfConfig, pszAdapterName, NULL }; 133 145 char * const envp[] = { (char*)"LC_ALL=C", NULL }; 134 146 … … 150 162 rc = dup2(fds[1], STDOUT_FILENO); 151 163 if (rc >= 0) 152 execve( VBOXADPCTL_IFCONFIG_PATH, argv, envp);164 execve(argv[0], argv, envp); 153 165 return false; 154 166 } … … 250 262 bool fRemove = false; 251 263 VBOXNETADPREQ Req; 264 265 setPathIfConfig(); 252 266 253 267 switch (argc)
Note:
See TracChangeset
for help on using the changeset viewer.