1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

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:
Mike Pritchard 1995-09-02 17:53:14 +00:00
parent c3899f8d3c
commit b406e662aa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10530
2 changed files with 18 additions and 2 deletions

View File

@ -1072,6 +1072,7 @@ dofork(action)
int action; int action;
{ {
register int i, pid; register int i, pid;
struct passwd *pwd;
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
if ((pid = fork()) < 0) { if ((pid = fork()) < 0) {
@ -1081,8 +1082,15 @@ dofork(action)
/* /*
* Child should run as daemon instead of root * Child should run as daemon instead of root
*/ */
if (pid == 0) if (pid == 0) {
if ((pwd = getpwuid(DU)) == NULL) {
syslog(LOG_ERR, "Can't lookup default uid in password file");
break;
}
initgroups(pwd->pw_name, pwd->pw_gid);
setgid(pwd->pw_gid);
setuid(DU); setuid(DU);
}
return(pid); return(pid);
} }
syslog(LOG_ERR, "can't fork"); syslog(LOG_ERR, "can't fork");

View File

@ -1072,6 +1072,7 @@ dofork(action)
int action; int action;
{ {
register int i, pid; register int i, pid;
struct passwd *pwd;
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
if ((pid = fork()) < 0) { if ((pid = fork()) < 0) {
@ -1081,8 +1082,15 @@ dofork(action)
/* /*
* Child should run as daemon instead of root * Child should run as daemon instead of root
*/ */
if (pid == 0) if (pid == 0) {
if ((pwd = getpwuid(DU)) == NULL) {
syslog(LOG_ERR, "Can't lookup default uid in password file");
break;
}
initgroups(pwd->pw_name, pwd->pw_gid);
setgid(pwd->pw_gid);
setuid(DU); setuid(DU);
}
return(pid); return(pid);
} }
syslog(LOG_ERR, "can't fork"); syslog(LOG_ERR, "can't fork");