From ddb7cd19d852b1c44d9d03041e8ed3b95b82eff5 Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Thu, 13 Mar 2008 19:56:25 +0000 Subject: [PATCH] Drop privileges properly (Radu Greab) git-svn-id: https://svn.perl.org/qpsmtpd/trunk@856 958fd67b-6ff1-0310-b445-bb7760255be9 --- qpsmtpd-async | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qpsmtpd-async b/qpsmtpd-async index 84f9c62..392c9fe 100755 --- a/qpsmtpd-async +++ b/qpsmtpd-async @@ -264,7 +264,15 @@ sub run_as_server { # Drop priviledges my (undef, undef, $quid, $qgid) = getpwnam $USER or 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 die "unable to change gid: $!\n"; POSIX::setuid($quid) or