From a653f600f5dd6a6d7ede4b2969659f500804233d Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 14 Apr 2004 20:16:29 +0000 Subject: [PATCH] * sec_acl.cc (getacl): Avoid compiler warning. * security.cc (write_sd): Ditto. Fix error handling. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/sec_acl.cc | 5 ++--- winsup/cygwin/security.cc | 16 +++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index da6527222..ef11031dd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2004-04-14 Corinna Vinschen + + * sec_acl.cc (getacl): Avoid compiler warning. + * security.cc (write_sd): Ditto. Fix error handling. + 2004-04-14 Corinna Vinschen * syscalls.cc (fstat64): Use get_namehash instead of hash_path_name. diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index e5e058983..ed1446e2e 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -261,12 +261,11 @@ getacl (HANDLE handle, const char *file, DWORD attr, int nentries, { security_descriptor sd; - int ret; if (!handle || get_nt_object_security (handle, SE_FILE_OBJECT, sd) - && (ret = read_sd (file, sd)) <= 0) + && read_sd (file, sd) <= 0) { debug_printf ("read_sd %E"); - return ret; + return -1; } cygpsid owner_sid; diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index c0ad954b7..239505128 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1148,8 +1148,9 @@ write_sd (HANDLE fh, const char *file, security_descriptor &sd) return -1; } } - NTSTATUS ret; + NTSTATUS ret = STATUS_SUCCESS; int retry = 0; + res = -1; for (; retry < 2; ++retry) { if (retry && (fh = CreateFile (file, WRITE_OWNER | WRITE_DAC, @@ -1168,12 +1169,13 @@ write_sd (HANDLE fh, const char *file, security_descriptor &sd) } if (retry && fh != INVALID_HANDLE_VALUE) CloseHandle (fh); - if (ret != STATUS_SUCCESS) - { - __seterrno_from_win_error (RtlNtStatusToDosError (ret)); - return -1; - } - return 0; + if (fh == INVALID_HANDLE_VALUE) /* CreateFile failed */ + __seterrno (); + else if (ret != STATUS_SUCCESS) /* NtSetSecurityObject failed */ + __seterrno_from_win_error (RtlNtStatusToDosError (ret)); + else /* Everything's fine. */ + res = 0; + return res; } static void