summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_disk_file.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-04-20 15:51:24 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-04-20 15:51:24 +0000
commitc8daf9983b445c9a2a0238af2d6e3ae23d0f3411 (patch)
treef836ae20b5aa189f864d6448c7a205c6ba7e7fc2 /winsup/cygwin/fhandler_disk_file.cc
parent4cc12c56301d5092226264aa294674f17640448e (diff)
downloadcygnal-c8daf9983b445c9a2a0238af2d6e3ae23d0f3411.tar.gz
cygnal-c8daf9983b445c9a2a0238af2d6e3ae23d0f3411.tar.bz2
cygnal-c8daf9983b445c9a2a0238af2d6e3ae23d0f3411.zip
* fhandler_disk_file.cc (fhandler_base::open_fs): Change
set_file_attribute call to indicate that NT security isn't used. (fhandler_disk_file::fchmod): Rearrange to isolate 9x related statements. Do not set FILE_ATTRIBUTE_SYSTEM. (fhandler_disk_file::fchown): Check noop case first. * fhandler.cc (fhandler_base::open9x): Remove ntsec related statements. (fhandler_base::set_name): Do not set namehash. * fhandler.h (fhandler_base::get_namehash): Compute and set namehash if needed. * syscalls.cc (access): Verify that fh is not NULL. Do not set PC_FULL. (chmod): Ditto. (chown_worker): Ditto. (stat_worker): Ditto. Verify if the path exists.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc42
1 files changed, 20 insertions, 22 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index fcc4417e3..7b4866849 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -387,16 +387,19 @@ fhandler_disk_file::fchmod (mode_t mode)
if (!(oret = open_fs (O_BINARY, 0)))
return -1;
}
- }
- if (!allow_ntsec && allow_ntea) /* Not necessary when manipulating SD. */
- SetFileAttributes (pc, (DWORD) pc & ~FILE_ATTRIBUTE_READONLY);
- if (pc.isdir ())
- mode |= S_IFDIR;
- if (!set_file_attribute (pc.has_acls (), get_io_handle (), pc,
- ILLEGAL_UID, ILLEGAL_GID, mode)
- && allow_ntsec)
- res = 0;
+ if (!allow_ntsec && allow_ntea) /* Not necessary when manipulating SD. */
+ SetFileAttributes (pc, (DWORD) pc & ~FILE_ATTRIBUTE_READONLY);
+ if (pc.isdir ())
+ mode |= S_IFDIR;
+ if (!set_file_attribute (pc.has_acls (), get_io_handle (), pc,
+ ILLEGAL_UID, ILLEGAL_GID, mode)
+ && allow_ntsec)
+ res = 0;
+
+ if (oret)
+ close_fs ();
+ }
/* if the mode we want has any write bits set, we can't be read only. */
if (mode & (S_IWUSR | S_IWGRP | S_IWOTH))
@@ -404,18 +407,12 @@ fhandler_disk_file::fchmod (mode_t mode)
else
(DWORD) pc |= FILE_ATTRIBUTE_READONLY;
- if (!pc.is_lnk_symlink () && S_ISLNK (mode) || S_ISSOCK (mode))
- (DWORD) pc |= FILE_ATTRIBUTE_SYSTEM;
-
if (!SetFileAttributes (pc, pc))
__seterrno ();
else if (!allow_ntsec)
/* Correct NTFS security attributes have higher priority */
res = 0;
- if (oret)
- close_fs ();
-
return res;
}
@@ -424,6 +421,13 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
{
int oret = 0;
+ if (!pc.has_acls () || !allow_ntsec)
+ {
+ /* fake - if not supported, pretend we're like win95
+ where it just works */
+ return 0;
+ }
+
enable_restore_privilege ();
if (!get_io_handle ())
{
@@ -439,12 +443,6 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
if (!res)
res = set_file_attribute (pc.has_acls (), get_io_handle (), pc,
uid, gid, attrib);
- if (res && (!pc.has_acls () || !allow_ntsec))
- {
- /* fake - if not supported, pretend we're like win95
- where it just works */
- res = 0;
- }
if (oret)
close_fs ();
@@ -587,7 +585,7 @@ fhandler_base::open_fs (int flags, mode_t mode)
if (flags & O_CREAT
&& GetLastError () != ERROR_ALREADY_EXISTS
&& !allow_ntsec && allow_ntea)
- set_file_attribute (has_acls (), NULL, get_win32_name (), mode);
+ set_file_attribute (false, NULL, get_win32_name (), mode);
set_fs_flags (pc.fs_flags ());