diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-01-09 11:44:17 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-01-09 11:44:17 +0000 |
commit | 3eb27a4e9e4ee13b23c5d9a21e702d939f43f46a (patch) | |
tree | b749815bdd3bc60934b3442b95b993400acff69a | |
parent | 85ba109de7c313449a8d4cd8bcc7b0606d0f15ec (diff) | |
download | newlib-3eb27a4e9e4ee13b23c5d9a21e702d939f43f46a.zip newlib-3eb27a4e9e4ee13b23c5d9a21e702d939f43f46a.tar.gz newlib-3eb27a4e9e4ee13b23c5d9a21e702d939f43f46a.tar.bz2 |
* security.cc (get_nt_attribute): Always return -1 when read_sd()
fails.
(get_file_attribute): Set permissions to 0 and owner/group to -1
if security descriptor is unreadable.
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/security.cc | 16 |
2 files changed, 20 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f0d86c1..93b993c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2003-01-09 Corinna Vinschen <corinna@vinschen.de> + + * security.cc (get_nt_attribute): Always return -1 when read_sd() + fails. + (get_file_attribute): Set permissions to 0 and owner/group to -1 + if security descriptor is unreadable. + 2003-01-09 Christopher Faylor <cgf@redhat.com> Use isdirsep rather than SLASH_P throughout. diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 1416ad5..777f408 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1322,7 +1322,7 @@ get_nt_attribute (const char *file, int *attribute, if ((ret = read_sd (file, psd, &sd_size)) <= 0) { debug_printf ("read_sd %E"); - return ret; + return -1; } PSID owner_sid; @@ -1381,9 +1381,19 @@ get_file_attribute (int use_ntsec, const char *file, if (use_ntsec && allow_ntsec) { res = get_nt_attribute (file, attribute, uidret, gidret); - if (attribute && (*attribute & S_IFLNK) == S_IFLNK) + if (res) + { + /* If reading the security descriptor failed, treat the file + as unreadable. */ + *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO); + if (uidret) + *uidret = ILLEGAL_UID; + if (gidret) + *gidret = ILLEGAL_GID; + } + else if (attribute && (*attribute & S_IFLNK) == S_IFLNK) *attribute |= S_IRWXU | S_IRWXG | S_IRWXO; - return res; + return 0; } if (uidret) |