Ownership

Paul Haas paulh at hamjudo.com
Wed Sep 8 20:52:51 GMT 2004


On Wed, 8 Sep 2004, Wayne Davison wrote:

> On Wed, Sep 08, 2004 at 10:30:44AM +0200, Essyug wrote:
>> Rsync seems to work as if I had used the --numeric-ids

> If rsync doesn't find a username match, it will fall-back to using the
> ID directly, so I would assume that the problem is that the ID names on
> your cygwin system aren't matching the ID names on your linux system
> (and perhaps they aren't what you think).

> I had originally misread your question as one wanting to get the cygwin
> rsync to set ownership of the files.  Towards this goal, I think we need
> a better "am I root" check for cygwin.  The attached patch attempts to
> provide this.  Is anyone familiar enough with cygwin to be able to
> comment on the appropriateness of this idiom?

It's only appropriate if /etc/group is correct.

People who use rsync to backup to Cygwin systems are probably inspired to 
keep their local /etc/group and /etc/passwd files in sync with the 
underlying OS. From personal experience, I know that I can't keep 
/etc/group current on all these Cygwin systems.  If only I could use a 
tool like rsync to fix a broken /etc/group. :-)

I don't think "am I root" is the correct check.  I think you want to know 
"can I chown".  Chownability varies with the filesystem and within a 
filesystem based on metadata beyond our control (well within cygwin 
anyway), such as acls.  As far as I know, the only reliable way to test if 
you can chown() a file, is to call chown().

I can think of 4 usefull modes:

1                    The default, don't try to chown().
2 --owner            If rsync thinks it is root, then try to chown()
3 --owner-whining    Always try to chown() and whine if it doesn't work.
4 --owner-no-whining Always try to chown(), don't whine if it doesn't work.

Where modes 1 and 2 are the current behaviour.  Changing the current 
behaviour would be bad.

If there are systems where failed chown() calls are really slow, then you 
may want a fifth mode:

5  --owner-try-once  Try to chown(), if it fails on the first call, stop
                      trying.

Mode 4 is because the time consuming part of a failed chown() is the act 
of sending the error message.

Most of the above isn't specific to cygwin.  The man page on a handy Linux 
system says:

    "The chown() semantics are deliberately violated on NFS file systems ..."

Many network file systems have surprising chown() semantics.

I won't feel hurt if you don't like "whining" in the option names.

--
Paul Haas
paulh at Hamjudo.com


More information about the rsync mailing list