summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjamie <jamie@FreeBSD.org>2014-12-18 18:10:39 +0000
committerjamie <jamie@FreeBSD.org>2014-12-18 18:10:39 +0000
commitcfa4b3bfed62875cbebbdaa6c7f9a19b8e2c378b (patch)
tree7bdd584c064d3ab633fd91af24502decb4a9ec84 /usr.sbin
parent4e730250dc0beaee6ce1521fc8694d4d941b559b (diff)
downloadFreeBSD-src-cfa4b3bfed62875cbebbdaa6c7f9a19b8e2c378b.zip
FreeBSD-src-cfa4b3bfed62875cbebbdaa6c7f9a19b8e2c378b.tar.gz
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 MFC after: 1 week
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 6101e07..6fefe41 100644
--- a/usr.sbin/jail/command.c
+++ b/usr.sbin/jail/command.c
@@ -667,6 +667,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