Deleted Added
full compact
command.c (231238) command.c (232242)
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 231238 2012-02-08 23:51:46Z jamie $");
28__FBSDID("$FreeBSD: projects/jailconf/usr.sbin/jail/command.c 232242 2012-02-27 22:37:35Z 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>

--- 375 unchanged lines hidden (view full) ---

412 argv[3] = argv[0];
413 }
414 *(const char **)&argv[0] = _PATH_MOUNT;
415 }
416 *(const char **)&argv[1] = "-t";
417 break;
418
419 case IP_MOUNT_DEVFS:
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>

--- 375 unchanged lines hidden (view full) ---

412 argv[3] = argv[0];
413 }
414 *(const char **)&argv[0] = _PATH_MOUNT;
415 }
416 *(const char **)&argv[1] = "-t";
417 break;
418
419 case IP_MOUNT_DEVFS:
420 argv = alloca(7 * sizeof(char *));
420 path = string_param(j->intparams[KP_PATH]);
421 if (path == NULL) {
422 jail_warnx(j, "mount.devfs: no path");
423 return -1;
424 }
425 devpath = alloca(strlen(path) + 5);
426 sprintf(devpath, "%s/dev", path);
427 if (check_path(j, "mount.devfs", devpath, 0,
428 down ? "devfs" : NULL) < 0)
429 return -1;
430 if (down) {
421 path = string_param(j->intparams[KP_PATH]);
422 if (path == NULL) {
423 jail_warnx(j, "mount.devfs: no path");
424 return -1;
425 }
426 devpath = alloca(strlen(path) + 5);
427 sprintf(devpath, "%s/dev", path);
428 if (check_path(j, "mount.devfs", devpath, 0,
429 down ? "devfs" : NULL) < 0)
430 return -1;
431 if (down) {
431 argv = alloca(3 * sizeof(char *));
432 *(const char **)&argv[0] = "/sbin/umount";
433 argv[1] = devpath;
434 argv[2] = NULL;
435 } else {
432 *(const char **)&argv[0] = "/sbin/umount";
433 argv[1] = devpath;
434 argv[2] = NULL;
435 } else {
436 argv = alloca(4 * sizeof(char *));
437 *(const char **)&argv[0] = _PATH_BSHELL;
438 *(const char **)&argv[1] = "-c";
439 ruleset = string_param(j->intparams
440 [IP_MOUNT_DEVFS_RULESET]);
441 argv[2] = alloca(strlen(path) +
442 (ruleset ? strlen(ruleset) + 1 : 0) + 56);
443 sprintf(argv[2], ". /etc/rc.subr; load_rc_config .; "
444 "devfs_mount_jail %s/dev%s%s", path,
445 ruleset ? " " : "", ruleset ? ruleset : "");
446 argv[3] = NULL;
436 *(const char **)&argv[0] = _PATH_MOUNT;
437 *(const char **)&argv[1] = "-t";
438 *(const char **)&argv[2] = "devfs";
439 ruleset = string_param(j->intparams[KP_DEVFS_RULESET]);
440 if (!ruleset)
441 ruleset = "4"; /* devfsrules_jail */
442 argv[3] = alloca(11 + strlen(ruleset));
443 sprintf(argv[3], "-oruleset=%s", ruleset);
444 *(const char **)&argv[4] = ".";
445 argv[5] = devpath;
446 argv[6] = NULL;
447 }
448 break;
449
450 case IP_COMMAND:
451 if (j->name != NULL)
452 goto default_command;
453 argc = 0;
454 TAILQ_FOREACH(s, &j->intparams[IP_COMMAND]->val, tq)

--- 403 unchanged lines hidden ---
447 }
448 break;
449
450 case IP_COMMAND:
451 if (j->name != NULL)
452 goto default_command;
453 argc = 0;
454 TAILQ_FOREACH(s, &j->intparams[IP_COMMAND]->val, tq)

--- 403 unchanged lines hidden ---