faubackup faubackup-scatter.c,1.11,1.12

[email protected]
Newsgroups gmane.comp.sysutils.backup.faubackup.cvs
Message-ID <[email protected]>
Update of /cvsroot/faubackup/faubackup
In directory sc8-pr-cvs1:/tmp/cvs-serv29473

Modified Files:
	faubackup-scatter.c 
Log Message:
check difference in uid/gid only after we tried to set them,
as we must not check for them when we are unable to change ownership,
which may happen when we are not called by root


Index: faubackup-scatter.c
===================================================================
RCS file: /cvsroot/faubackup/faubackup/faubackup-scatter.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** faubackup-scatter.c	15 Oct 2003 12:15:25 -0000	1.11
--- faubackup-scatter.c	15 Oct 2003 14:01:06 -0000	1.12
***************
*** 44,47 ****
--- 44,50 ----
  
  
+ static int can_set_owner = 1;
+ 
+ 
  static int
  recv_buf(void *buf, long long len, int mayfail)
***************
*** 349,364 ****
  }
  
- 
  static void
! permission(void)
  {
! 	static int warned = 0;
! 
! 	if( warned ) {
  		return;
  	}
! 	fprintf( stderr, "%s: WARNING: only root can set uid/gid\n",
  			progname );
! 	warned = 1;
  }
  
--- 352,365 ----
  }
  
  static void
! cannot_set_owner(void)
  {
! 	if( !can_set_owner ) {
! 		/* only print warning once */
  		return;
  	}
! 	fprintf( stderr, "%s: WARNING: cannot set ownership of files\n",
  			progname );
! 	can_set_owner = 0;
  }
  
***************
*** 395,399 ****
  		ret = lchown(path, st->st_uid, st->st_gid);
  		if( ret < 0 && errno == EPERM ) {
! 			permission();
  			mode &= ~06000;
  		} else if( ret < 0 ) {
--- 396,400 ----
  		ret = lchown(path, st->st_uid, st->st_gid);
  		if( ret < 0 && errno == EPERM ) {
! 			cannot_set_owner();
  			mode &= ~06000;
  		} else if( ret < 0 ) {
***************
*** 502,507 ****
  	/* !! do _not_ check atime; will be changed by backup itself !! */
  	if( st->st_mode != oldst.st_mode
- 	 || st->st_uid != oldst.st_uid
- 	 || st->st_gid != oldst.st_gid
  	 || st->st_size != oldst.st_size
  	 /* || st->st_atime != oldst.st_atime */
--- 503,506 ----
***************
*** 630,633 ****
--- 629,642 ----
  
  	set_perms( actfile, st, SET_ALL );
+ 
+ 	/*
+ 	 * check difference in uid/gid only after we tried to set
+ 	 * them, as we must not check for them when we are unable
+ 	 * to change ownership, which may happen when we are not
+ 	 * called by root
+ 	 */
+ 	if( st->st_uid != oldst.st_uid || st->st_gid != oldst.st_gid ) {
+ 		if( can_set_owner ) equal = 0;
+ 	}
  
  	if( equal ) {




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.