public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: don't return valid acl entry type for unknown SID
Date: Mon, 27 Aug 2018 16:31:00 -0000	[thread overview]
Message-ID: <20180827163126.123122.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fcfcc288c4d3e9ad3bca4d0c9dd79ee1c88a99f9

commit fcfcc288c4d3e9ad3bca4d0c9dd79ee1c88a99f9
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Aug 27 13:30:55 2018 +0200

    Cygwin: don't return valid acl entry type for unknown SID
    
    cygpsid::get_id neglects to set the type to 0 (ACL_UNDEFINED_TAG
    in POSIX speak) if the SID can not be translated into a valid
    uid or gid.  This in turn leads to incorrect handling of uid/gid -1
    entries.
    
    Fix this by setting type to 0 if the id is unknown.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/sec_helper.cc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc
index a1d8cba..373b1df 100644
--- a/winsup/cygwin/sec_helper.cc
+++ b/winsup/cygwin/sec_helper.cc
@@ -169,10 +169,16 @@ cygpsid::get_id (BOOL search_grp, int *type, cyg_ldap *pldap)
 	}
       else if ((pw = internal_getpwsid (*this, pldap)))
 	id = pw->pw_uid;
-      if (id != ILLEGAL_UID && type)
-	*type = USER;
+      if (id != ILLEGAL_UID)
+	{
+	  if (type)
+	    *type = USER;
+	  return id;
+	}
     }
-  return id;
+  if (type)
+    *type = 0; /* undefined type */
+  return ILLEGAL_UID;
 }
 
 PWCHAR


                 reply	other threads:[~2018-08-27 16:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180827163126.123122.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).