diff options
author | mpp <mpp@FreeBSD.org> | 1995-09-02 17:53:14 +0000 |
---|---|---|
committer | mpp <mpp@FreeBSD.org> | 1995-09-02 17:53:14 +0000 |
commit | 2f44cdc7e1a2b2a57c4ddfb6e937304a6baac01f (patch) | |
tree | 348b620505871351720533e60028b38db03bfd48 /usr.sbin/lpr/lpd | |
parent | 9a28cf053e0253a84225e0cd75dda5047d6bba8c (diff) | |
download | FreeBSD-src-2f44cdc7e1a2b2a57c4ddfb6e937304a6baac01f.zip FreeBSD-src-2f44cdc7e1a2b2a57c4ddfb6e937304a6baac01f.tar.gz |
Initialize the group list so that any filter programs that are
run by lpd are not run with root's groups.
Diffstat (limited to 'usr.sbin/lpr/lpd')
-rw-r--r-- | usr.sbin/lpr/lpd/printjob.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index a719b55..7e6c3c5 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -1072,6 +1072,7 @@ dofork(action) int action; { register int i, pid; + struct passwd *pwd; for (i = 0; i < 20; i++) { if ((pid = fork()) < 0) { @@ -1081,8 +1082,15 @@ dofork(action) /* * 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); + } return(pid); } syslog(LOG_ERR, "can't fork"); |