summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-02-13 11:10:55 +0100
committerCorinna Vinschen <corinna@vinschen.de>2019-02-13 11:13:28 +0100
commit9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693 (patch)
treedf01fe6a25a9cc14b8b4654c0cffaf8b8f6c9034
parent43fa1aafa6cec04d85ca0c08a9a293ada9bd3aad (diff)
downloadcygnal-9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693.tar.gz
cygnal-9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693.tar.bz2
cygnal-9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693.zip
Cygwin: passwd/group: store account name case correct
When looking up valid accounts by name, LookupAccountName returns a SID and a case-correct domain name. However, the name was input and LookupAccountName is case-insensitive, so the name is not necessarily written the same way as in SAM or AD. Fix that by doing a reverse lookup on the just fetched SID. This fetches the account name in the correct case. Override the incoming name with the case correct name from LookupAccountSid. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/release/3.04
-rw-r--r--winsup/cygwin/uinfo.cc10
2 files changed, 14 insertions, 0 deletions
diff --git a/winsup/cygwin/release/3.0 b/winsup/cygwin/release/3.0
index da357558d..444e71a94 100644
--- a/winsup/cygwin/release/3.0
+++ b/winsup/cygwin/release/3.0
@@ -109,3 +109,7 @@ Bug Fixes
- Fix O_APPEND handling on files when calling non-Cygwin applications
Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00081.html
+
+- Fix case correctness of passwd/group entries fetched via getpwnam
+ or getgrnam.
+ Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00109.html
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 22cae5e04..4a5fa3470 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -2046,6 +2046,16 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap)
/* We can skip the backslash in the rest of this function. */
if (p)
name = p + 1;
+ /* Reverse lookup name from sid to make sure the username in
+ our passwd/group data is written exactly as in the user DB. */
+ nlen = UNLEN + 1;
+ dlen = DNLEN + 1;
+ ret = LookupAccountSidW (NULL, sid, name, &nlen, dom, &dlen, &acc_type);
+ if (!ret)
+ {
+ system_printf ("LookupAccountNameW (%W), %E", name);
+ return NULL;
+ }
/* Last but not least, some validity checks on the name style. */
if (!fq_name)
{