Not fail if can't set permissions ?

Andre Majorel aym-cnysr at teaser.fr
Mon Oct 9 15:39:55 GMT 2006


I'm adding files to an existing tree via rsync -aO. Some of the
directories on the remote are owned by a different user. I have
rwx permissions on them but when rsync tries to set the
permissions for those directories, it fails and exits with a
non-zero status.

This is expected but it complicates error detection on my end. Is
there a way to make rsync not consider it an error when chmod()
fails on a directory owned by someone else ? Possibly warn about
it, but still exit with a zero status.

    stat (destpathname, &deststat);
    if ((deststat.st_mode & mask) != (srcstat.st_mode & mask))
    {
	if (chmod (pathname, srcstat.st_mode) != 0)
	{
	    if (errno == EPERM
	      && deststat.st_uid != geteuid ()
	      && option_ignore_non_owner)
	    {
		/* Expected error - just warn about it */
		;
	    }
	    else
	    {
		/* Unexpected error - fail */
		exit_with_non_zero_status = 1;
	    }
	}
    }

-- 
André Majorel <URL:http://www.teaser.fr/~amajorel/>
Do not use this account for regular correspondence.
See the URL above for contact information.


More information about the rsync mailing list