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
This commit is contained in:
parent
b9a2a3f1cf
commit
eb28afe422
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user