command.c (223327) | command.c (223351) |
---|---|
1/*- 2 * Copyright (c) 2011 James Gritton 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011 James Gritton 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: projects/jailconf/usr.sbin/jail/command.c 223327 2011-06-20 07:58:44Z jamie $"); | 28__FBSDID("$FreeBSD: projects/jailconf/usr.sbin/jail/command.c 223351 2011-06-20 23:04:13Z jamie $"); |
29 30#include <sys/types.h> 31#include <sys/event.h> 32#include <sys/mount.h> 33#include <sys/stat.h> 34#include <sys/sysctl.h> 35#include <sys/user.h> 36#include <sys/wait.h> --- 205 unchanged lines hidden (view full) --- 242 */ 243int 244run_command(struct cfjail *j) 245{ 246 const struct passwd *pwd; 247 const struct cfstring *comstring, *s; 248 login_cap_t *lcap; 249 char **argv; | 29 30#include <sys/types.h> 31#include <sys/event.h> 32#include <sys/mount.h> 33#include <sys/stat.h> 34#include <sys/sysctl.h> 35#include <sys/user.h> 36#include <sys/wait.h> --- 205 unchanged lines hidden (view full) --- 242 */ 243int 244run_command(struct cfjail *j) 245{ 246 const struct passwd *pwd; 247 const struct cfstring *comstring, *s; 248 login_cap_t *lcap; 249 char **argv; |
250 char *cs, *addr, *comcs, *devpath; | 250 char *cs, *comcs, *devpath; |
251 const char *jidstr, *conslog, *path, *ruleset, *term, *username; 252 enum intparam comparam; 253 size_t comlen; 254 pid_t pid; 255 int argc, bg, clean, consfd, down, fib, i, injail, sjuser, timeout; | 251 const char *jidstr, *conslog, *path, *ruleset, *term, *username; 252 enum intparam comparam; 253 size_t comlen; 254 pid_t pid; 255 int argc, bg, clean, consfd, down, fib, i, injail, sjuser, timeout; |
256#if defined(INET) || defined(INET6) 257 char *addr; 258#endif |
|
256 257 static char *cleanenv; 258 259 /* Perform some operations that aren't actually commands */ 260 comparam = *j->comparam; 261 down = j->flags & (JF_STOP | JF_FAILED); 262 switch (comparam) { 263 case IP_STOP_TIMEOUT: --- 26 unchanged lines hidden (view full) --- 290 } 291 /* 292 * Collect exec arguments. Internal commands for network and 293 * mounting build their own argument lists. 294 */ 295 comstring = j->comstring; 296 bg = 0; 297 switch (comparam) { | 259 260 static char *cleanenv; 261 262 /* Perform some operations that aren't actually commands */ 263 comparam = *j->comparam; 264 down = j->flags & (JF_STOP | JF_FAILED); 265 switch (comparam) { 266 case IP_STOP_TIMEOUT: --- 26 unchanged lines hidden (view full) --- 293 } 294 /* 295 * Collect exec arguments. Internal commands for network and 296 * mounting build their own argument lists. 297 */ 298 comstring = j->comstring; 299 bg = 0; 300 switch (comparam) { |
301#ifdef INET |
|
298 case IP__IP4_IFADDR: 299 argv = alloca(8 * sizeof(char *)); 300 *(const char **)&argv[0] = _PATH_IFCONFIG; 301 if ((cs = strchr(comstring->s, '|'))) { 302 argv[1] = alloca(cs - comstring->s + 1); 303 strlcpy(argv[1], comstring->s, cs - comstring->s + 1); 304 addr = cs + 1; 305 } else { --- 15 unchanged lines hidden (view full) --- 321 argc = 6; 322 } else { 323 argv[3] = addr; 324 argc = 4; 325 } 326 *(const char **)&argv[argc] = down ? "-alias" : "alias"; 327 argv[argc + 1] = NULL; 328 break; | 302 case IP__IP4_IFADDR: 303 argv = alloca(8 * sizeof(char *)); 304 *(const char **)&argv[0] = _PATH_IFCONFIG; 305 if ((cs = strchr(comstring->s, '|'))) { 306 argv[1] = alloca(cs - comstring->s + 1); 307 strlcpy(argv[1], comstring->s, cs - comstring->s + 1); 308 addr = cs + 1; 309 } else { --- 15 unchanged lines hidden (view full) --- 325 argc = 6; 326 } else { 327 argv[3] = addr; 328 argc = 4; 329 } 330 *(const char **)&argv[argc] = down ? "-alias" : "alias"; 331 argv[argc + 1] = NULL; 332 break; |
333#endif |
|
329 330#ifdef INET6 331 case IP__IP6_IFADDR: 332 argv = alloca(8 * sizeof(char *)); 333 *(const char **)&argv[0] = _PATH_IFCONFIG; 334 if ((cs = strchr(comstring->s, '|'))) { 335 argv[1] = alloca(cs - comstring->s + 1); 336 strlcpy(argv[1], comstring->s, cs - comstring->s + 1); --- 518 unchanged lines hidden --- | 334 335#ifdef INET6 336 case IP__IP6_IFADDR: 337 argv = alloca(8 * sizeof(char *)); 338 *(const char **)&argv[0] = _PATH_IFCONFIG; 339 if ((cs = strchr(comstring->s, '|'))) { 340 argv[1] = alloca(cs - comstring->s + 1); 341 strlcpy(argv[1], comstring->s, cs - comstring->s + 1); --- 518 unchanged lines hidden --- |