summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2014-12-27 02:17:35 +0000
committerjamie <jamie@FreeBSD.org>2014-12-27 02:17:35 +0000
commit799361e237fdb276321038f0ef7f547ad2a0a863 (patch)
treea0ecdbb10de58f4822eb41d27c056a43caa34334 /usr.sbin
parentdda8b6a9a420cd544ef8f0f08eb23434c36a844f (diff)
downloadFreeBSD-src-799361e237fdb276321038f0ef7f547ad2a0a863.zip
FreeBSD-src-799361e237fdb276321038f0ef7f547ad2a0a863.tar.gz
MFC r275906:
Setgid before running a command as a specified user. Previously only initgroups(3) was called, what isn't quite enough. This brings jail(8) in line with jexec(8), which was already doing the right thing. PR: 195984
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/jail/command.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.sbin/jail/command.c b/usr.sbin/jail/command.c
index 0d1c898..390be80 100644
--- a/usr.sbin/jail/command.c
+++ b/usr.sbin/jail/command.c
@@ -668,6 +668,11 @@ run_command(struct cfjail *j)
if (term != NULL)
setenv("TERM", term, 1);
}
+ if (setgid(pwd->pw_gid) < 0) {
+ jail_warnx(j, "setgid %d: %s", pwd->pw_gid,
+ strerror(errno));
+ exit(1);
+ }
if (setusercontext(lcap, pwd, pwd->pw_uid, username
? LOGIN_SETALL & ~LOGIN_SETGROUP & ~LOGIN_SETLOGIN
: LOGIN_SETPATH | LOGIN_SETENV) < 0) {
OpenPOWER on IntegriCloud