summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jail/jail.c
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2003-04-09 03:04:12 +0000
committermike <mike@FreeBSD.org>2003-04-09 03:04:12 +0000
commit6067525913c2a13f7785f6d88dc81df85cde5812 (patch)
tree058bbdc564bcc891a28e1adb5f67a45e806274e2 /usr.sbin/jail/jail.c
parent79d60009e2bdcbd2cc1dacebff7139856d04ee1a (diff)
downloadFreeBSD-src-6067525913c2a13f7785f6d88dc81df85cde5812.zip
FreeBSD-src-6067525913c2a13f7785f6d88dc81df85cde5812.tar.gz
o Add jls(8) for listing active jails.
o Add jexec(8) to execute a command in an existing jail. o Add -j option for killall(1) to kill all processes in a specified jail. o Add -i option to jail(8) to output jail ID of newly created jail.
Diffstat (limited to 'usr.sbin/jail/jail.c')
-rw-r--r--usr.sbin/jail/jail.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c
index 332be28..87bc483 100644
--- a/usr.sbin/jail/jail.c
+++ b/usr.sbin/jail/jail.c
@@ -34,20 +34,24 @@ main(int argc, char **argv)
struct jail j;
struct passwd *pwd;
struct in_addr in;
- int ch, groups[NGROUPS], ngroups;
+ int ch, groups[NGROUPS], i, iflag, ngroups;
char *username;
+ iflag = 0;
username = NULL;
- while ((ch = getopt(argc, argv, "u:")) != -1)
+ while ((ch = getopt(argc, argv, "iu:")) != -1) {
switch (ch) {
+ case 'i':
+ iflag = 1;
+ break;
case 'u':
username = optarg;
break;
default:
usage();
- break;
}
+ }
argc -= optind;
argv += optind;
if (argc < 4)
@@ -73,8 +77,11 @@ main(int argc, char **argv)
if (inet_aton(argv[2], &in) == 0)
errx(1, "Could not make sense of ip-number: %s", argv[2]);
j.ip_number = ntohl(in.s_addr);
- if (jail(&j) != 0)
+ i = jail(&j);
+ if (i == -1)
err(1, "jail");
+ if (iflag)
+ printf("%d\n", i);
if (username != NULL) {
if (setgroups(ngroups, groups) != 0)
err(1, "setgroups");
@@ -87,14 +94,14 @@ main(int argc, char **argv)
}
if (execv(argv[3], argv + 3) != 0)
err(1, "execv: %s", argv[3]);
- exit (0);
+ exit(0);
}
static void
usage(void)
{
- (void)fprintf(stderr, "%s\n",
- "Usage: jail [-u username] path hostname ip-number command ...");
+ (void)fprintf(stderr,
+ "usage: jail [-i] [-u username] path hostname ip-number command ...\n");
exit(1);
}
OpenPOWER on IntegriCloud