Skip to content

Commit 48e7d63

Browse files
committed
Cygwin: fetch_account_from_windows: skip LookupAccountSid for SIDs known to fail
LookupAccountSid might take a long time if an SID cannot be resolved. While we know some SIDs never resolved by LookupAccountSid, we call it anyway and only handle them after it returned with error. (Partially?) fix this latency problem by skipping the LookupAccountSid call for SID groups never resolved anyway. Reported-by: Lluís Batlle i Rossell <[email protected]> Fixes: 1ca20a1 ("Introduce reading passwd/group entries from SAM/AD.") Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit 008a02bc722569fc492b757a2cb2f6ef1c17a6a3)
1 parent 17765ac commit 48e7d63

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

winsup/cygwin/release/3.6.2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Fixes:
2+
------
3+
4+
- Fix a high latency problem when trying to fetch SID info for SIDs
5+
not resolved by Windows functions anyway.
6+
Addresses: https://cygwin.com/pipermail/cygwin/2025-April/257916.html

winsup/cygwin/uinfo.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,27 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap)
19831983
break;
19841984
case SID_arg:
19851985
sid = *arg.sid;
1986+
1987+
/* SIDs we want to filter out before hitting LookupAccountSidW.
1988+
If the latency of the AD connection is high, LookupAccountSidW
1989+
might take a long time before returning with ERROR_NONE_MAPPED. */
1990+
1991+
/* Capability SIDs, just drop out, we don't handle them */
1992+
if (sid_id_auth (sid) == 15 /* SECURITY_APP_PACKAGE_AUTHORITY */
1993+
&& sid_sub_auth (sid, 0) == SECURITY_CAPABILITY_BASE_RID)
1994+
return NULL;
1995+
/* IIS APPPOOL */
1996+
if (sid_id_auth (sid) == 5 /* SECURITY_NT_AUTHORITY */
1997+
&& sid_sub_auth (sid, 0) == SECURITY_APPPOOL_ID_BASE_RID)
1998+
break;
1999+
/* AzureAD SIDs */
2000+
if (sid_id_auth (sid) == 12 /* AzureAD ID */
2001+
&& sid_sub_auth (sid, 0) == 1 /* Azure ID base RID */)
2002+
break;
2003+
/* Samba user/group SIDs */
2004+
if (sid_id_auth (sid) == 22)
2005+
break;
2006+
19862007
ret = LookupAccountSidW (NULL, sid, name, &nlen, dom, &dlen, &acc_type);
19872008
if (!ret
19882009
&& cygheap->dom.member_machine ()

0 commit comments

Comments
 (0)