diff --git a/Alien/Package/Rpm.pm b/Alien/Package/Rpm.pm index 8ae808e..d862072 100644 --- a/Alien/Package/Rpm.pm +++ b/Alien/Package/Rpm.pm @@ -176,6 +176,30 @@ sub unpack { or die "error moving unpacked files into the default prefix directory: $!"; } + if ($> == 0) { + # rpm files have two sets of permissions; the set in the cpio + # archive, and the set in the control data; which override them. + # The set in the control data are more correct, so let's use those. + open (GETPERMS, 'rpm --queryformat \'[%{FILEMODES} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]\' -qp '.$this->filename.' |'); + while () { + chomp; + my ($mode, $owner, $group, $file) = split(/ /, $_, 4); + $mode = $mode & 07777; # remove filetype + my $uid = getpwnam($owner); + if (! defined $uid) { + print STDERR "WARNING: $file is owned by a user ($owner) not on this system; using root instead"; + $uid=0; + } + my $gid = getgrnam($group); + if (! defined $gid) { + print STDERR "WARNING: $file is owned by a group ($group) not on this system; using group root instead"; + $gid=0; + } + chown($uid, $gid, $file) || die "failed chowning $file to $uid\:$gid\: $!"; + chmod($mode, $file) || die "failed changing mode of $file to $mode\: $!"; + } + } + # When cpio extracts the file, any child directories that are # present, but whose parent directories are not, end up mode 700. # This next block corrects that to 755, which is more reasonable. diff --git a/alien.pl b/alien.pl index 1351df0..87d712e 100755 --- a/alien.pl +++ b/alien.pl @@ -364,7 +364,7 @@ unless (@ARGV) { if (! -w '.') { die("Cannot write to current directory. Try moving to /tmp and re-running alien.\n"); } -if ($> ne 0) { +if ($> != 0) { if ($destformats{deb} && ! $generate && ! $single) { die "Must run as root to convert to deb format (or you may use fakeroot).\n"; } diff --git a/debian/changelog b/debian/changelog index 0bc0a54..2da16d8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +alien (8.15) unstable; urgency=low + + * Fix a longstanding bug I was only recently told about: When converting + from rpm, ignore the icky file owners and perms from the cpio archive, + and query rpm for the real set that it overrides in the control data + structure. Closes: #151546 + + -- Joey Hess Mon, 8 Jul 2002 20:52:48 -0400 + alien (8.14) unstable; urgency=low * Enabled Getopt::Long Bundling, see comment in alien.pl. Closes: #152148