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 $");
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 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) {
431 argv = alloca(3 * sizeof(char *));
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;
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 ---
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 $");
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 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) {
431 argv = alloca(3 * sizeof(char *));
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;
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 ---