* Patch from aj to fix permissions of setuid files that have their owners

created in the preinst.
   * Alien's repository has moved from CVS to subversion.
This commit is contained in:
joey
2003-10-15 20:02:38 +00:00
parent 4531625657
commit ec560cf2a2
5 changed files with 18 additions and 6 deletions

View File

@@ -709,7 +709,7 @@ sub username {
=item postinst
Returns the postinst. This may include generated shell code to set owners
and groups from the owninfo field.
and groups from the owninfo field, and update modes from the modeinfo field.
=cut
@@ -717,6 +717,7 @@ sub postinst {
my $this=shift;
my $owninfo = $this->owninfo;
my $modeinfo = $this->modeinfo;
my $postinst = $this->{postinst};
return $postinst unless ref $owninfo;
@@ -730,10 +731,12 @@ sub postinst {
}
my $permscript="# alien added permissions fixup code\n";
foreach my $file (keys %$owninfo) {
foreach my $file (sort keys %$owninfo) {
my $quotedfile=$file;
$quotedfile=~s/'/'"'"'/g; # no single quotes in single quotes..
$permscript.="chown '$owninfo->{$file}' '$quotedfile'\n";
$permscript.="chmod '$modeinfo->${file}' '$quotedfile'\n"
if (defined $modeinfo->{$file});
}
return "$firstline\n$permscript\n$rest";
}

View File

@@ -195,6 +195,7 @@ sub unpack {
# Some permissions setting may have to be postponed until the
# postinst.
my %owninfo = ();
my %modeinfo = ();
open (GETPERMS, 'rpm --queryformat \'[%{FILEMODES} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]\' -qp '.$this->filename.' |');
while (<GETPERMS>) {
chomp;
@@ -215,6 +216,9 @@ sub unpack {
}
$gid=0;
}
if (defined($owninfo{$file}) && ($mode & 07000 > 0)) {
$modeinfo{$file} = $mode;
}
next unless -e "$workdir/$file"; # skip broken links
if ($> == 0) {
$this->do("chown", "$uid:$gid", "$workdir/$file")
@@ -224,6 +228,7 @@ sub unpack {
|| die "failed changing mode of $file to $mode\: $!";
}
$this->owninfo(\%owninfo);
$this->modeinfo(\%modeinfo);
return 1;
}