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>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user