From 5fbc1b52bc9b2c38accbd536c5cd8ae1c4237539 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 9 May 2000 21:42:41 +0000 Subject: [PATCH] * When reloating files from a rpm, run the mv command directly, not in a subshell; this is safer especially if odd filenames are involved. * When converting from rpm, only chmod each directory once, it was doing it many times for some directories before. * Fixed chmodding to use the correct path to the directory. This fixes file permissions in rpm's converted to other formats, a bug introduced at 7.0. * Fixed some undefined value warnings (which pointed out real but rare bugs). * Fixed a rare, but bad little bug. If you ran alien in a directory that had the suid/sgid bit set (as my home directory does), and generated debs and probably other formats, it generated packages with the root directory suid/sgid. --- Alien/Package.pm | 4 ++++ Alien/Package/Deb.pm | 2 +- Alien/Package/Rpm.pm | 20 ++++++++++++-------- debian/changelog | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Alien/Package.pm b/Alien/Package.pm index 9319501..a4e8520 100644 --- a/Alien/Package.pm +++ b/Alien/Package.pm @@ -237,6 +237,10 @@ sub unpack { my $workdir = $this->name."-".$this->version; mkdir $workdir, 0755 || die "unable to mkdir $workdir: $!"; + # If the parent directory is suid/sgid, mkdir will make the root + # directory of the package inherit those bits. That is a bad thing, + # so explicitly force perms to 755. + chmod 0755, $workdir; $this->unpacked_tree($workdir); } diff --git a/Alien/Package/Deb.pm b/Alien/Package/Deb.pm index 02f8634..c656e44 100644 --- a/Alien/Package/Deb.pm +++ b/Alien/Package/Deb.pm @@ -213,7 +213,7 @@ sub getpatch { my @patches; foreach my $dir (@_) { - push @patches,glob("$dir/".$this->name."_".$this->version."-".$this->revision."*.diff.gz"); + push @patches, glob("$dir/".$this->name."_".$this->version."-".$this->release."*.diff.gz"); } unless (@patches) { # Try not matching the revision, see if that helps. diff --git a/Alien/Package/Rpm.pm b/Alien/Package/Rpm.pm index 5a83232..faa0f91 100644 --- a/Alien/Package/Rpm.pm +++ b/Alien/Package/Rpm.pm @@ -84,7 +84,8 @@ sub scan { foreach my $field (keys(%fieldtrans)) { $_=`LANG=C rpm -qp $file --queryformat \%{$field}`; $field=$fieldtrans{$field}; - $this->$field($_) if $_ ne '(none)'; + $_='' if $_ eq '(none)'; + $this->$field($_); } # Get the conffiles list. @@ -136,7 +137,7 @@ sub unpack { my $this=shift; $this->SUPER::unpack(@_); my $workdir=$this->unpacked_tree; - + system ("rpm2cpio ".$this->filename." | (cd $workdir; cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time) 2>/dev/null") && die "Unpacking of `".$this->filename."' failed"; @@ -153,31 +154,32 @@ sub unpack { # Test to see if the package contains the prefix directory already. if (defined $this->prefixes && ! -e "$workdir/".$this->prefixes) { # Get the files to move. - my $filelist=join ' ',glob("$workdir/*"); + my @filelist=glob("$workdir/*"); # Now, make the destination directory. my $collect=$workdir; foreach (split m:/:, $this->prefixes) { - if ($_ ne undef) { # this keeps us from using anything but relative paths. + if ($_ ne '') { # this keeps us from using anything but relative paths. $collect.="$_/"; mkdir $collect,0755 || die "unable to mkdir $collect: $!"; } } # Now move all files in the package to the directory we made. - system "mv $filelist $workdir/".$this->prefixes && + system "mv", @filelist, "$workdir/".$this->prefixes && die "error moving unpacked files into the default prefix directory: $!"; } # When cpio extracts the file, any child directories that are # present, but whose parent directories are not, end up mode 700. - # This next block correctsthat to 755, which is more reasonable. + # This next block corrects that to 755, which is more reasonable. # # Of course, this whole thing assumes we get the filelist in sorted # order. my $lastdir=''; + my %tochmod; foreach my $file (@{$this->filelist}) { $file=~s/^\///; - if (($lastdir && $file=~m:^\Q$lastdir\E/[^/]*$: eq undef) || !$lastdir) { + if (($lastdir && $file !~ m:^\Q$lastdir\E/[^/]*$:) || !$lastdir) { # We've found one of the nasty directories. Fix it # up. # @@ -191,11 +193,13 @@ sub unpack { my $dircollect=''; foreach my $dir (split(/\//,$file)) { $dircollect.="$dir/"; - chmod 0755,$dircollect; # TADA! + # Use a hash to prevent duplicate chmods. + $tochmod{"$workdir/$dircollect"}=1; } } $lastdir=$file if -d "./$file"; } + chmod 0755, keys %tochmod if %tochmod; return 1; } diff --git a/debian/changelog b/debian/changelog index 794f49f..0e760f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,22 @@ +alien (7.2) unstable; urgency=low + + * When reloating files from a rpm, run the mv command directly, + not in a subshell; this is safer especially if odd filenames are + involved. + * When converting from rpm, only chmod each directory once, it was doing + it many times for some directories before. + * Fixed chmodding to use the correct path to the directory. This fixes + file permissions in rpm's converted to other formats, a bug introduced + at 7.0. + * Fixed some undefined value warnings (which pointed out real but rare + bugs). + * Fixed a rare, but bad little bug. If you ran alien in a directory that + had the suid/sgid bit set (as my home directory does), and generated + debs and probably other formats, it generated packages with the root + directory suid/sgid. + + -- Joey Hess Tue, 9 May 2000 14:13:15 -0700 + alien (7.1) unstable; urgency=low * Corrected checking of system() in Deb::prep. Closes: #63396