Drop privileges properly (Radu Greab)
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@856 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
ce5b41df9f
commit
ddb7cd19d8
@ -264,7 +264,15 @@ sub run_as_server {
|
|||||||
# Drop priviledges
|
# Drop priviledges
|
||||||
my (undef, undef, $quid, $qgid) = getpwnam $USER or
|
my (undef, undef, $quid, $qgid) = getpwnam $USER or
|
||||||
die "unable to determine uid/gid for $USER\n";
|
die "unable to determine uid/gid for $USER\n";
|
||||||
$) = "";
|
my $groups = "$qgid $qgid";
|
||||||
|
while (my (undef, undef, $gid, $members) = getgrent) {
|
||||||
|
my @m = split(/ /, $members);
|
||||||
|
if (grep { $_ eq $USER } @m) {
|
||||||
|
$groups .= " $gid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endgrent;
|
||||||
|
$) = $groups;
|
||||||
POSIX::setgid($qgid) or
|
POSIX::setgid($qgid) or
|
||||||
die "unable to change gid: $!\n";
|
die "unable to change gid: $!\n";
|
||||||
POSIX::setuid($quid) or
|
POSIX::setuid($quid) or
|
||||||
|
Loading…
Reference in New Issue
Block a user