Re-implement my fix from rev 1.6 (same rev for both files being committed)
that was lost during the lite-2 merge. From the original commit message: Initialize the group list so that any filter programs that are run by lpd are not run with root's groups.
This commit is contained in:
parent
4efe647d8b
commit
50545e9e59
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60871
@ -1317,6 +1317,7 @@ dofork(pp, action)
|
||||
int action;
|
||||
{
|
||||
register int i, pid;
|
||||
struct passwd *pwd;
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
if ((pid = fork()) < 0) {
|
||||
@ -1326,8 +1327,16 @@ dofork(pp, action)
|
||||
/*
|
||||
* Child should run as daemon instead of root
|
||||
*/
|
||||
if (pid == 0)
|
||||
if (pid == 0) {
|
||||
if ((pwd = getpwuid(pp->daemon_user)) == NULL) {
|
||||
syslog(LOG_ERR, "Can't lookup default daemon uid (%d) in password file",
|
||||
pp->daemon_user);
|
||||
break;
|
||||
}
|
||||
initgroups(pwd->pw_name, pwd->pw_gid);
|
||||
setgid(pwd->pw_gid);
|
||||
setuid(pp->daemon_user);
|
||||
}
|
||||
return(pid);
|
||||
}
|
||||
syslog(LOG_ERR, "can't fork");
|
||||
|
@ -1307,6 +1307,7 @@ dofork(pp, action)
|
||||
int action;
|
||||
{
|
||||
register int i, pid;
|
||||
struct passwd *pwd;
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
if ((pid = fork()) < 0) {
|
||||
@ -1316,8 +1317,16 @@ dofork(pp, action)
|
||||
/*
|
||||
* Child should run as daemon instead of root
|
||||
*/
|
||||
if (pid == 0)
|
||||
if (pid == 0) {
|
||||
if ((pwd = getpwuid(pp->daemon_user)) == NULL) {
|
||||
syslog(LOG_ERR, "Can't lookup default daemon uid (%d) in password file",
|
||||
pp->daemon_user);
|
||||
break;
|
||||
}
|
||||
initgroups(pwd->pw_name, pwd->pw_gid);
|
||||
setgid(pwd->pw_gid);
|
||||
setuid(pp->daemon_user);
|
||||
}
|
||||
return(pid);
|
||||
}
|
||||
syslog(LOG_ERR, "can't fork");
|
||||
|
Loading…
Reference in New Issue
Block a user