bug-gnu-utils
[Top][All Lists]
Advanced

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

tar --no-same-owner (design bug)


From: Clifford Wolf
Subject: tar --no-same-owner (design bug)
Date: Mon, 3 Jun 2002 15:35:01 +0200 (CEST)

Hi,

when extracting a tar file as root user, the tar program is behaving like
--same-owner has been specified. (which is a standard I assume?)

This behavior is what the user usually wants when using 'tar' for
backups. But it's not what the user wants when extracting a package
source archive.

The problem is that package maintainers almost never use "--owner root
--group root" for creating package tar files. When root is extracting
them, the files get random uids and gids (e.g. 1011/1011 or 1011/903
in case of tar-1.13.tar.gz). Almost every tar file available on the net
has set file uids/gids != 0.

One possible solution would be if all maintainers would use "--owner root
--group root" for creating their source tars (which should be done
anyways). But since it looks like even the maintainers of GNU tar do
forget that, an option is needed to suppress the chown() calls even if
root is extracting the tar archive. Here is a possible solution which
adds the --no-same-owner option:

--- ./src/extract.c.orig        Mon Jun  3 14:56:04 2002
+++ ./src/extract.c     Mon Jun  3 14:56:57 2002
@@ -162,7 +162,7 @@
      extract as the original owner.  Or else, if we are running as a user,
      leave the owner and group as they are, so we extract as that user.  */

-  if (we_are_root || same_owner_option)
+  if (!no_same_owner_option && (we_are_root || same_owner_option))
     {
 #if HAVE_LCHOWN

--- ./src/common.h.orig Mon Jun  3 14:57:49 2002
+++ ./src/common.h      Mon Jun  3 15:13:56 2002
@@ -196,6 +196,9 @@
 GLOBAL int no_recurse_option;

 /* Boolean value.  */
+GLOBAL int no_same_owner_option;
+
+/* Boolean value.  */
 GLOBAL int numeric_owner_option;

 /* Boolean value.  */
--- ./src/tar.c.orig    Mon Jun  3 15:13:28 2002
+++ ./src/tar.c Mon Jun  3 15:15:53 2002
@@ -205,6 +205,7 @@
   {"newer-mtime", required_argument, NULL, NEWER_MTIME_OPTION},
   {"null", no_argument, NULL, NULL_OPTION},
   {"no-recursion", no_argument, NULL, NO_RECURSE_OPTION},
+  {"no-same-owner", no_argument, &no_same_owner_option, 1},
   {"numeric-owner", no_argument, &numeric_owner_option, 1},
   {"old-archive", no_argument, NULL, 'o'},
   {"one-file-system", no_argument, NULL, 'l'},
@@ -305,6 +306,7 @@
       --atime-preserve         don't change access times on dumped files\n\
   -m, --modification-time      don't extract file modified time\n\
       --same-owner             try extracting files with the same ownership\n\
+      --no-same-owner          don't extract files with the same ownership\n\
       --numeric-owner          always use numbers for user/group names\n\
   -p, --same-permissions       extract all protection information\n\
       --preserve-permissions   same as -p\n\

yours,
 - clifford

-- 
| Clifford Wolf ............ www.clifford.at . . . IRC: http://opirc.nu/
| ROCK Linux Workgroup ..... www.rocklinux.org . . Tel: +43-699-10063494
| NTx Consulting Group ..... www.ntx.at  . . . . . Fax: +43-2235-42788-4
+------=[ Usenet Compliant Signature (RFC 2646) ]=---> www.rocklinux.net

Linux is a wigwam: No Windows, No Gates, Apache inside.

Reality corrupted. Reboot universe? (Y/N)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]