🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #872

gnu tar 1.11.1 - owner/group not preserved for directories on extract.

#872
From: stuart
Date: Thu, 08 Oct 1992 11:55
51 lines
2474 bytes
Utility:	gnu tar 1.11.1
System:		Sequent Symmetry S27
OS: 		dynix 3.0.17.9
Source:		ftp.uu.net:packages/gnu/tar-1.11.1.tar.Z

When extracting files from an archive as root (tar xvpf), the owner
and group are not preserved on directories.  This makes it impossible
to use gnu tar to copy a directory subtree to another location:

	cd /foo ; tar cvf - . | (cd /bar; tar xvpf -)

NOTE:  If the -m flag is included to the tar extract command (tar
xvpmf), owner & group are preserved, but modification times aren't.

Included below is a patch which I think will fix the problem.

-stuart

--
Stuart Pearlman                                 stuart@oasys.dt.navy.mil
Trandes Corporation                             +1 301 459 0200
On-Contract-To: David Taylor Research Center    +1 301 227 1428
---------------------------------------------------------------------------
*** /tmp/,RCSt1013898	Thu Oct  8 15:37:32 1992
--- extract.c	Thu Oct  8 15:33:12 1992
***************
*** 652,657
  
  		if (f_modified)
  		  goto set_filestat;
  		tmp = (struct saved_dir_info *) malloc (sizeof (struct saved_dir_info));
  		tmp->path = malloc (strlen (skipcrud + current_file_name) + 1);
  		strcpy (tmp->path, skipcrud + current_file_name);

--- 652,667 -----
  
  		if (f_modified)
  		  goto set_filestat;
+ 
+                 if (we_are_root || f_do_chown) {
+                         if (chown(skipcrud + current_file_name,
+                                   hstat.st_uid, hstat.st_gid) < 0) {
+                           msg_perror("cannot chown file %s to uid %d gid %d",
+                                      skipcrud + current_file_name,
+                                      hstat.st_uid,hstat.st_gid);
+ 			}
+ 		}
+ 
  		tmp = (struct saved_dir_info *) malloc (sizeof (struct saved_dir_info));
  		tmp->path = malloc (strlen (skipcrud + current_file_name) + 1);
  		strcpy (tmp->path, skipcrud + current_file_name);
Technical Details
Message-ID: <9210081955.AA16499@oasys.dt.navy.mil>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!sun-barr!ames!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!oasys.dt.navy.mil!stuart

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!sun-barr!ames!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!oasys.dt.navy.mil!stuart
From: stuart@oasys.dt.navy.mil
Subject: gnu tar 1.11.1 - owner/group not preserved for directories on extract.
Message-ID: <9210081955.AA16499@oasys.dt.navy.mil>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 8 Oct 1992 11:55:19 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 53