New: afio backups, directory ownership?

Leslie Mikesell les at chinet.UUCP
Fri Jun 17 12:16:46 AEST 1988


In article <11269 at steinmetz.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>  Please post the patch....

There seems to be a lot of interest in afio currently and apparently
some people missed the patches that were posted for it. 
Here is a re-post of the patch that restores directory permissions.
(There was another one dealing with wildcards in the -y and -Y flags). 

original patch follows....
==============
>From: mjy at sdti.UUCP (Michael J. Young)
>Subject: Minor problem with afio
>Date: 9 Dec 87 00:43:26 GMT
>Organization: Software Development Technologies, Sudbury MA


After running into some problems with cpio on my Microport system, I decided
to finally give Mark Brukhartz's afio program a try.  I was pleasantly
surprised to find that it not only does not suffer from cpio's limitation on
archive size (cpio as distributed by Microport seems to have problems on
archives over about 16 megabytes), but it's a little bit faster as well.  So
it quickly replaced cpio as my preferred method of doing backups.

However, I think I discovered a minor bug (the hard way!):

When doing backups, I use the following command:
	find . -depth -print | afio ....
(The -depth argument is recommended by Microport in their manual).
This causes afio to archive directories AFTER their files, as expected.
Unfortunately, when restoring such an archive, these directories are
restored with the wrong owner and group, even if I use the -x flag!

I had the pleasure of restoring an entire file system the other day, only
to find out that all subdirectories of /usr had root,sys ownership!  I
first noticed it when news started dropping all incoming messages on the
floor!

The problem seems to be that openo() does not change the directory
owner/group if the directory already exists.  I made the following changes
to correct the situation.  I make no claims for the accuracy or completeness
of my solution, but it seems to work the way I expect it to now.

*** afio.c.orig	Tue Dec  8 16:08:48 1987
--- afio.c	Tue Dec  8 16:36:25 1987
***************
*** 1711,1716
  	reg int		fd;
  	reg ushort	perm;
  	ushort		operm;
  	Path		*path;
  	auto Stat	osb;
  #ifdef	S_IFLNK

--- 1711,1718 -----
  	reg int		fd;
  	reg ushort	perm;
  	ushort		operm;
+ 	ushort		ouid;
+ 	ushort		ogid;
  	Path		*path;
  	auto Stat	osb;
  #ifdef	S_IFLNK
***************
*** 1750,1755
  		linkalso(linkp, name);
  	}
  	perm = asb->sb_mode & (xflag ? S_IPERM : S_IPOPN);
  	switch (asb->sb_mode & S_IFMT) {
  	case S_IFBLK:
  	case S_IFCHR:

--- 1752,1761 -----
  		linkalso(linkp, name);
  	}
  	perm = asb->sb_mode & (xflag ? S_IPERM : S_IPOPN);
+ 	if (exists){
+ 		ouid = osb.sb_uid;
+ 		ogid = osb.sb_gid;
+ 	}
  	switch (asb->sb_mode & S_IFMT) {
  	case S_IFBLK:
  	case S_IFCHR:
***************
*** 1773,1778
  	case S_IFDIR:
  		if (exists)
  			if (perm != operm && chmod(name, perm) < 0)
  				return (warn(name, syserr()));
  			else
  				;

--- 1779,1787 -----
  	case S_IFDIR:
  		if (exists)
  			if (perm != operm && chmod(name, perm) < 0)
+ 				return (warn(name, syserr()));
+ 			else if (xflag && (asb->sb_uid != ouid || asb->sb_gid != ogid) &&
+ 				chown(name, asb->sb_uid, asb->sb_gid) < 0)
  				return (warn(name, syserr()));
  			else
  				;
-- 



More information about the Comp.unix.xenix mailing list