[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

r826 - in /trunk: ChangeLog debian/changelog scripts/dpkg-source.pl



Author: djpig
Date: Sat Jun 30 23:35:58 2007
New Revision: 826

URL: http://svn.debian.org/wsvn/dpkg/?sc=3D1&rev=3D826
Log:
correct permission and owner/group handling when extracting
tar balls to match more the user's preferences instead of
ours or the ones from the originator of the tar ball. Patch
by Ian Jackson. Closes: #390915, #207289

Modified:
    trunk/ChangeLog
    trunk/debian/changelog
    trunk/scripts/dpkg-source.pl

Modified: trunk/ChangeLog
URL: http://svn.debian.org/wsvn/dpkg/trunk/ChangeLog?rev=3D826&op=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sat Jun 30 23:35:58 2007
@@ -1,3 +1,19 @@
+2007-07-01  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+	* scripts/dpkg-source.pl: Don't remove setgid bits
+	on directories when extracting the .orig tarball
+	since the user might prefer to have them. Also don't
+	manually override user and group for extracted
+	directories. Instead we will take tar take of most
+	of that.
+	(extracttar): Explicetly specify --no-same-owner
+	and --no-same-permissions. They are default anyway
+	for non-root users, but no need to handle the source
+	differently (i.e. more carelessly) if working as root.
+	Since tar still insists on honoring the file permissions in the
+	tar ball, fix them up so that they match what the user would
+	expect according to his umask.
+
 2007-06-12  Ji=C3=85=C2=99=C3=83=C2=AD Pale=C3=84=C2=8Dek  <jpalecek@web.d=
e>
 =

 	* dpkg-shlibdeps.pl: Support colon separated list of paths in the

Modified: trunk/debian/changelog
URL: http://svn.debian.org/wsvn/dpkg/trunk/debian/changelog?rev=3D826&op=3D=
diff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/debian/changelog (original)
+++ trunk/debian/changelog Sat Jun 30 23:35:58 2007
@@ -25,6 +25,10 @@
   [ Frank Lichtenheld ]
   * Fix typo in German translation of start-stop-daemon(8).
     Noted by Joachim Breitner. Closes: #430008
+  * Correct permission and owner/group handling when extracting
+    tar balls to match more the user's preferences instead of
+    ours or the ones from the originator of the tar ball. Patch
+    by Ian Jackson. Closes: #390915, #207289
   =

   [ Updated dselect translations ]
   * French (Christian Perrier)

Modified: trunk/scripts/dpkg-source.pl
URL: http://svn.debian.org/wsvn/dpkg/trunk/scripts/dpkg-source.pl?rev=3D826=
&op=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/scripts/dpkg-source.pl (original)
+++ trunk/scripts/dpkg-source.pl Sat Jun 30 23:35:58 2007
@@ -817,10 +817,8 @@
 	(my $t =3D $target) =3D~ s!.*/!!;
 =

 	mkdir($tmp,0700) || &syserr(sprintf(_g("unable to create `%s'"), $tmp));
-	system "chmod", "g-s", $tmp;
 	printf(_g("%s: unpacking %s")."\n", $progname, $tarfile);
 	extracttar("$dscdir/$tarfile",$tmp,$t);
-	system "chown", '-R', '-f', join(':', getfowner()), "$tmp/$t";
 	rename("$tmp/$t",$target)
 	    || &syserr(sprintf(_g("unable to rename `%s' to `%s'"), "$tmp/$t", $t=
arget));
 	rmdir($tmp)
@@ -1298,18 +1296,48 @@
 =

 sub extracttar {
     my ($tarfileread,$dirchdir,$newtopdir) =3D @_;
+    my ($mode, $modes_set, $i, $j);
     &forkgzipread("$tarfileread");
     defined(my $c2 =3D fork) || syserr(_g("fork for tar -xkf -"));
     if (!$c2) {
         open(STDIN,"<&GZIP") || &syserr(_g("reopen gzip for tar -xkf -"));
         &cpiostderr;
         chdir($dirchdir) || &syserr(sprintf(_g("cannot chdir to `%s' for t=
ar extract"), $dirchdir));
-        exec('tar','-xkf','-') or &syserr(_g("exec tar -xkf -"));
+	exec('tar','--no-same-owner','--no-same-permissions',
+	     '-xkf','-') or &syserr(_g("exec tar -xkf -"));
     }
     close(GZIP);
     $c2 =3D=3D waitpid($c2,0) || &syserr(_g("wait for tar -xkf -"));
     $? && subprocerr("tar -xkf -");
     &reapgzip;
+
+    # Unfortunately tar insists on applying our umask _to the original
+    # permissions_ rather than mostly-ignoring the original
+    # permissions.  We fix it up with chmod -R (which saves us some
+    # work) but we have to construct a u+/- string which is a bit
+    # of a palaver.  (Numeric doesn't work because we need [ugo]+X
+    # and [ugo]=3D<stuff> doesn't work because that unsets sgid on dirs.)
+    #
+    # We still need --no-same-permissions because otherwise tar might
+    # extract directory setgid (which we want inherited, not
+    # extracted); we need --no-same-owner because putting the owner
+    # back is tedious - in particular, correct group ownership would
+    # have to be calculated using mount options and other madness.
+    #
+    # It would be nice if tar could do it right, or if pax could cope
+    # with GNU format tarfiles with long filenames.
+    #
+    $mode=3D 0777 & ~umask;
+    for ($i=3D0; $i<9; $i+=3D3) {
+	$modes_set.=3D ',' if $i;
+	$modes_set.=3D qw(u g o)[$i/3];
+	for ($j=3D0; $j<3; $j++) {
+	    $modes_set.=3D $mode & (0400 >> ($i+$j)) ? '+' : '-';
+	    $modes_set.=3D qw(r w X)[$j];
+	}
+    }
+    system 'chmod','-R',$modes_set,'--',$dirchdir;
+    $? && subprocerr("chmod -R $modes_set $dirchdir");
 =

     opendir(D,"$dirchdir") || &syserr(sprintf(_g("Unable to open dir %s"),=
 $dirchdir));
     my @dirchdirfiles =3D grep($_ ne "." && $_ ne "..", readdir(D));




Reply to: