From: Corinna Vinschen Date: Wed, 21 Dec 2005 13:01:27 +0000 (+0000) Subject: * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix inode number X-Git-Tag: gdb-csl-20060226-branchpoint~264 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=0786c42a9ce31bfbd48b8887e509dab09a6974a0;p=newlib-cygwin.git * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix inode number debug output. (fhandler_disk_file::fchown): Always set sensible permission values when creating the ACL for symlinks. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index aa6cd5a65..256788da6 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2005-12-21 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix inode number + debug output. + (fhandler_disk_file::fchown): Always set sensible permission values + when creating the ACL for symlinks. + 2005-12-20 Corinna Vinschen * winsup.h (flush_file_buffers): Define as inline function. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 5b684e5e7..d8fc42b42 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -452,9 +452,9 @@ fhandler_base::fstat_helper (struct __stat64 *buf, } done: - syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%D, st_mode=%p, st_ino=%d, sizeof=%d", + syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%D, st_mode=%p, st_ino=%D, sizeof=%d", buf, buf->st_atime, buf->st_size, buf->st_mode, - (int) buf->st_ino, sizeof (*buf)); + buf->st_ino, sizeof (*buf)); return 0; } @@ -562,9 +562,23 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid) attrib |= S_IFDIR; int res = get_file_attribute (pc.has_acls (), get_io_handle (), pc, &attrib); if (!res) - res = set_file_attribute (pc.has_acls (), get_io_handle (), pc, - uid, gid, attrib); - + { + /* Typical Windows default ACLs can contain permissions for one + group, while being owned by another user/group. The permission + bits returned above are pretty much useless then. Creating a + new ACL with these useless permissions results in a potentially + broken symlink. So what we do here is to set the underlying + permissions of symlinks to a sensible value which allows the + world to read the symlink and only the new owner to change it. + As for the execute permissions... they *seem* to be not + necessary, but for the sake of comleteness and to avoid + struggling with yet another Windows weirdness, the execute bits + are added as well. */ + if (pc.issymlink ()) + attrib = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + res = set_file_attribute (pc.has_acls (), get_io_handle (), pc, + uid, gid, attrib); + } if (oret) close ();