From: Abigail Date: Mon, 26 Jan 2009 12:54:48 +0000 (+0100) Subject: Check for the group entry returned by getpwuid as well when testing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7fa8fd0b55ac97c02c8f3171c520b066aaf1bf7d;p=p5sagit%2Fp5-mst-13.2.git Check for the group entry returned by getpwuid as well when testing if a file belongs to the group the user is in. --- diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm index fc37ee6..620a2ea 100644 --- a/lib/File/Copy.pm +++ b/lib/File/Copy.pm @@ -317,8 +317,10 @@ sub cp { my $ok = $fromstat[5] == $tostat[5]; # group must match if ($ok) { # and we must be in group my $uname = (getpwuid($>))[0] || ''; - my(@members) = split /\s+/, (getgrgid($fromstat[5]))[3]; - $ok = grep { $_ eq $uname } @members; + my $group = (getpwuid($>))[3]; + $ok = $group && $group == $fromstat[5] || + grep { $_ eq $uname } + split /\s+/, (getgrgid($fromstat[5]))[3]; } $perm &= ~06000 unless $ok; }