From 7c0019fd3084503b16686588e9e052c1a6b6c371 Mon Sep 17 00:00:00 2001 From: jamie Date: Wed, 24 Jun 2009 18:18:35 +0000 Subject: Add libjail, a (somewhat) simpler interface to the jail_set and jail_get system calls and the security.jail.param sysctls. Approved by: bz (mentor) --- usr.sbin/jexec/Makefile | 4 ++-- usr.sbin/jexec/jexec.c | 20 ++++++-------------- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'usr.sbin/jexec') diff --git a/usr.sbin/jexec/Makefile b/usr.sbin/jexec/Makefile index 2bf817c..d55ea0fc 100644 --- a/usr.sbin/jexec/Makefile +++ b/usr.sbin/jexec/Makefile @@ -2,8 +2,8 @@ PROG= jexec MAN= jexec.8 -DPADD= ${LIBUTIL} -LDADD= -lutil +DPADD= ${LIBJAIL} ${LIBUTIL} +LDADD= -ljail -lutil WARNS?= 6 .include diff --git a/usr.sbin/jexec/jexec.c b/usr.sbin/jexec/jexec.c index 0d82e28..8c15ebe 100644 --- a/usr.sbin/jexec/jexec.c +++ b/usr.sbin/jexec/jexec.c @@ -31,13 +31,13 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -67,14 +67,13 @@ static void usage(void); int main(int argc, char *argv[]) { - struct iovec params[2]; int jid; login_cap_t *lcap = NULL; struct passwd *pwd = NULL; gid_t *groups = NULL; int ch, ngroups, uflag, Uflag; long ngroups_max; - char *ep, *username; + char *username; ch = uflag = Uflag = 0; username = NULL; @@ -107,18 +106,11 @@ main(int argc, char *argv[]) usage(); if (uflag) GET_USER_INFO; - jid = strtoul(argv[0], &ep, 10); - if (!*argv[0] || *ep) { - *(const void **)¶ms[0].iov_base = "name"; - params[0].iov_len = sizeof("name"); - params[1].iov_base = argv[0]; - params[1].iov_len = strlen(argv[0]) + 1; - jid = jail_get(params, 2, 0); - if (jid < 0) - errx(1, "Unknown jail: %s", argv[0]); - } + jid = jail_getid(argv[0]); + if (jid < 0) + errx(1, "%s", jail_errmsg); if (jail_attach(jid) == -1) - err(1, "jail_attach(): %d", jid); + err(1, "jail_attach(%d)", jid); if (chdir("/") == -1) err(1, "chdir(): /"); if (username != NULL) { -- cgit v1.1