summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jexec
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2009-06-24 18:18:35 +0000
committerjamie <jamie@FreeBSD.org>2009-06-24 18:18:35 +0000
commit7c0019fd3084503b16686588e9e052c1a6b6c371 (patch)
treea9cec75f7b2e1076b5455019e71bbc78faac9225 /usr.sbin/jexec
parentbd3587c757355e28ac6abbaf11703661599270bb (diff)
downloadFreeBSD-src-7c0019fd3084503b16686588e9e052c1a6b6c371.zip
FreeBSD-src-7c0019fd3084503b16686588e9e052c1a6b6c371.tar.gz
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)
Diffstat (limited to 'usr.sbin/jexec')
-rw-r--r--usr.sbin/jexec/Makefile4
-rw-r--r--usr.sbin/jexec/jexec.c20
2 files changed, 8 insertions, 16 deletions
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 <bsd.prog.mk>
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 <sys/jail.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
-#include <sys/uio.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <err.h>
#include <errno.h>
+#include <jail.h>
#include <limits.h>
#include <login_cap.h>
#include <stdio.h>
@@ -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 **)&params[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) {
OpenPOWER on IntegriCloud