From 55f13c0012c4cc9fc84c195862885725c93c5a0a Mon Sep 17 00:00:00 2001 From: corinna Date: Thu, 19 Jul 2007 17:42:11 +0000 Subject: [PATCH] * security.cc (set_nt_attribute): Remove. (set_file_attribute): Do it yourself instead of calling set_nt_attribute. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/security.cc | 31 ++++++++++--------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index df3efaa258..47f009c7ed 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2007-07-19 Corinna Vinschen + * security.cc (set_nt_attribute): Remove. + (set_file_attribute): Do it yourself instead of calling + set_nt_attribute. + +2007-07-19 Corinna Vinschen + * fhandler_disk_file.cc (fhandler_base::fstat_by_name): Use NtQueryFullAttributesFile instead of FindFirstFile. (fhandler_base::fstat_fs): Drop check for exec_state. Drop check for diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index df4953a443..5fca3d8ed9 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1892,32 +1892,21 @@ set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa, attribute, sd); } -static int -set_nt_attribute (HANDLE handle, const char *file, - __uid32_t uid, __gid32_t gid, int attribute) -{ - security_descriptor sd; - - if ((!handle || get_nt_object_security (handle, SE_FILE_OBJECT, sd)) - && read_sd (file, sd) <= 0) - { - debug_printf ("read_sd %E"); - return -1; - } - - if (!alloc_sd (uid, gid, attribute, sd)) - return -1; - - return write_sd (handle, file, sd); -} - int set_file_attribute (bool use_ntsec, HANDLE handle, const char *file, __uid32_t uid, __gid32_t gid, int attribute) { - int ret; + int ret = -1; + if (use_ntsec && allow_ntsec) - ret = set_nt_attribute (handle, file, uid, gid, attribute); + { + security_descriptor sd; + + if (((handle && !get_nt_object_security (handle, SE_FILE_OBJECT, sd)) + || read_sd (file, sd) > 0) + && alloc_sd (uid, gid, attribute, sd)) + ret = write_sd (handle, file, sd); + } else ret = 0; syscall_printf ("%d = set_file_attribute (%s, %d, %d, %p)", -- 2.11.0