chown

Pierre A. Humblet Pierre.Humblet@ieee.org
Thu Apr 15 16:12:00 GMT 2004


Corinna,

/> uname -a
CYGWIN_NT-4.0 usched40576 1.5.10(0.114/4/2) 2004-04-14 23:21 i686 unknown unknown Cygwin
/> touch xxx
/> chown testuser xxx
/> chown phumblet xxx
chown: changing ownership of `xxx': Permission denied

   99   81155 [main] chown 332 fhandler_base::open: (d:\cygwin\xxx, 0x110000) query_open 3
  433   81588 [main] chown 332 seterrno_from_win_error: ../../../../src/winsup/cygwin/fhandler.cc:546 windows error 5
  134   81722 [main] chown 332 geterrno_from_win_error: windows error 5 == errno 13

The problem is that I won't be privileged until write_sd.
It may be better to first call with query_read_control and to
retry in write_sd. 

I am wondering if we need a CreateFile with FILE_FLAG_BACKUP_SEMANTICS
or if a simple DuplicateHandle would also work, after becoming privileged.

Also BackupWrite was not atomic, the ACL would change while the owner
didn't. Do you know if NtSetSecurityObject is atomic? If so, the test
if (res == 1)
    {
      BOOL dummy;
      cygpsid owner;
could be removed.

Pierre

P.S.: I have just updated in cvs and saw your fresh change.
Now CreateFile might be called up to 3 times.
An alternative is to become privileged before the initial
open, but that won't work with fchown and there is still the
issue of  FILE_FLAG_BACKUP_SEMANTICS. Bummer.



More information about the Cygwin-developers mailing list