This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug in chown()


In trying to get the newly released coreutils 5.3.0 tarball working on
cygwin, I discovered that cygwin chown() has a bug.  Background:
http://lists.gnu.org/archive/html/bug-coreutils/2005-01/msg00064.html

POSIX requires that "chown() shall mark for update the st_ctime field of
the file" if successful and at least one of owner or group was not -1.
http://www.opengroup.org/onlinepubs/009695399/functions/chown.html

However, in cygwin, chown() appears to have no effect whatsoever on the
change time.  (gid_t)0 is the 'root' group.  I tested this on a WinXP
machine, since it appears that cygwin does not support multiple groups on
my Win98 box.  The printouts in the test program allow me to narrow in on
the relevant section of the strace.

$ cd /tmp
$ cat chowntest.c
#include <unistd.h>
int main()
{
  int ret = 0;
  write(1, "~~~Start\n", 9);
  if (chown("f", (uid_t)-1, (gid_t)0))
    {
      perror("failed to chown\n");
      ret = 1;
    }
  write(1, "~~~End\n", 7);
  return ret;
}
$ touch f
$ stat f
  File: `f'
  Size: 0               Blocks: 0          IO Block: 1024   regular empty file
Device: d47c93feh/-730033154d   Inode: 61328       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1007/  eblake)   Gid: (  513/    None)
Access: 2005-01-13 06:21:53.936500000 -0700
Modify: 2005-01-13 06:21:53.936500000 -0700
Change: 2005-01-13 06:21:53.920875000 -0700
$ chowntest.exe f
~~~Start
~~~End
$ stat f
  File: `f'
  Size: 0               Blocks: 0          IO Block: 1024   regular empty file
Device: d47c93feh/-730033154d   Inode: 61328       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1007/  eblake)   Gid: (    0/    root)
Access: 2005-01-13 06:21:53.936500000 -0700
Modify: 2005-01-13 06:21:53.936500000 -0700
Change: 2005-01-13 06:21:53.920875000 -0700
$ cygcheck -c cygwin
Cygwin Package Information
Package              Version        Status
cygwin               1.5.12-1       OK
$ uname -a
CYGWIN_NT-5.1 EBLAKE 1.5.12(0.116/4/2) 2004-11-10 08:34 i686 unknown
unknown Cygwin
$ strace chowntest 2>&1 | sed -e '/^~~~Start/,/^~~~End/!d' > chowntest.trace

-- 
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
~~~Start
   31   19799 [main] chowntest 3976 fhandler_base::write: 9 = write (0x402000, 9)
   29   19828 [main] chowntest 3976 writev: 9 = write (1, 0x22EF80, 1), errno 0
   34   19862 [main] chowntest 3976 normalize_posix_path: src f
   28   19890 [main] chowntest 3976 cwdstuff::get: posix /tmp
   35   19925 [main] chowntest 3976 cwdstuff::get: (/tmp) = cwdstuff::get (0x22EC90, 260, 1, 0), errno 0
   28   19953 [main] chowntest 3976 normalize_posix_path: /tmp/f = normalize_posix_path (f)
   29   19982 [main] chowntest 3976 mount_info::conv_to_win32_path: conv_to_win32_path (/tmp/f)
   32   20014 [main] chowntest 3976 set_flags: flags: binary (0x2)
   29   20043 [main] chowntest 3976 mount_info::conv_to_win32_path: src_path /tmp/f, dst c:\cygwin\tmp\f, flags 0xA, rc 0
   81   20124 [main] chowntest 3976 symlink_info::check: not a symlink
   30   20154 [main] chowntest 3976 symlink_info::check: 0 = symlink.check (c:\cygwin\tmp\f, 0x22E950) (0xA)
   31   20185 [main] chowntest 3976 path_conv::check: this->path(c:\cygwin\tmp\f), has_acls(1)
   31   20216 [main] chowntest 3976 build_fh_pc: fh 0x61791444
 1124   21340 [main] chowntest 3976 set_process_privilege: 0 = set_process_privilege (SeRestorePrivilege, 1)
  153   21493 [main] chowntest 3976 fhandler_base::open: (c:\cygwin\tmp\f, 0x110000)
   80   21573 [main] chowntest 3976 fhandler_base::set_flags: flags 0x110000, supplied_bin 0x10000
   31   21604 [main] chowntest 3976 fhandler_base::set_flags: O_TEXT/O_BINARY set in flags 0x10000
   29   21633 [main] chowntest 3976 fhandler_base::set_flags: filemode set to binary
   28   21661 [main] chowntest 3976 fhandler_base::open: 0 = NtCreateFile (0x700, E0000, c:\cygwin\tmp\f, io, NULL, 0, 7, 1, 4400, NULL, 0)
   30   21691 [main] chowntest 3976 fhandler_base::open: 1 = fhandler_base::open (c:\cygwin\tmp\f, 0x110000)
   30   21721 [main] chowntest 3976 fhandler_base::open_fs: 1 = fhandler_disk_file::open (c:\cygwin\tmp\f, 0x10000)
   33   21754 [main] chowntest 3976 get_file_attribute: file: c:\cygwin\tmp\f
   93   21847 [main] chowntest 3976 cygpsid::debug_print: get_sids_info: owner SID = S-1-5-21-854245398-1177238915-725345543-1007
   44   21891 [main] chowntest 3976 cygpsid::debug_print: get_sids_info: group SID = S-1-5-32-544
   52   21943 [main] chowntest 3976 get_info_from_sd: ACL 1A4, uid 1007, gid 0
  100   22043 [main] chowntest 3976 alloc_sd: uid -1, gid 0, attribute 1A4
   32   22075 [main] chowntest 3976 cygpsid::debug_print: alloc_sd: owner SID = S-1-5-21-854245398-1177238915-725345543-1007
   32   22107 [main] chowntest 3976 cygpsid::debug_print: alloc_sd: group SID = S-1-5-32-544
   46   22153 [main] chowntest 3976 alloc_sd: ACL-Size: 88
   80   22233 [main] chowntest 3976 alloc_sd: Created SD-Size: 152
   91   22324 [main] chowntest 3976 set_file_attribute: 0 = set_file_attribute (c:\cygwin\tmp\f, -1, 0, 0x1A4)
   35   22359 [main] chowntest 3976 fhandler_base::close: closing '/tmp/f' handle 0x700
  110   22469 [main] chowntest 3976 chown_worker: 0 = chown (f,...)
   36   22505 [main] chowntest 3976 writev: writev (1, 0x22EF80, 1)
   30   22535 [main] chowntest 3976 fhandler_base::write: binary write
~~~End

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]