https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ef89ddedbaa143a0c0fba29d4a383cf31135cc29
commit ef89ddedbaa143a0c0fba29d4a383cf31135cc29 Author: Corinna Vinschen <[email protected]> AuthorDate: Tue Feb 3 00:11:09 2026 +0100 Commit: Corinna Vinschen <[email protected]> CommitDate: Tue Feb 3 00:14:26 2026 +0100 Cygwin: accounts: (re-)add flag for unix uid/gid caching Commit b39fa2c88da8 ("* autoload.cc (CheckTokenMembership): Import.") introduced a method to recycle a ldap connection throughout a call stack. This broke caching the mapping from remote NFS or Samba uid/gid values to Cygwin uid/gid values partially. The pldap pointer given to pwdgrp::fetch_account_from_windows() was supposed to be NULL if not called from getpwent/getgrent, but in fact it was set to non-NULL in many callers for performance reasons. Re-introduce a bool argument telling pwdgrp::fetch_account_from_windows() if caching is desired or not, and set it to false only when called from getpwent/getgrent. Fixes: b39fa2c88da8 ("* autoload.cc (CheckTokenMembership): Import.") Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit 2ca642dd6a6322915c4277b80d8c7c30058a434b) Diff: --- winsup/cygwin/local_includes/pwdgrp.h | 1 + winsup/cygwin/passwd.cc | 2 +- winsup/cygwin/release/3.6.7 | 3 +++ winsup/cygwin/uinfo.cc | 15 ++++++++------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/local_includes/pwdgrp.h b/winsup/cygwin/local_includes/pwdgrp.h index 8f3ef3adb03e..5bc8bcf22f75 100644 --- a/winsup/cygwin/local_includes/pwdgrp.h +++ b/winsup/cygwin/local_includes/pwdgrp.h @@ -105,6 +105,7 @@ class pwdgrp char *fetch_account_from_line (fetch_user_arg_t &arg, const char *line); char *fetch_account_from_file (fetch_user_arg_t &arg); char *fetch_account_from_windows (fetch_user_arg_t &arg, + bool ugid_caching = false, cyg_ldap *pldap = NULL); char *fetch_account_from_cygserver (fetch_user_arg_t &arg); diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index b8457a46f963..35cc39d5aa54 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -627,7 +627,7 @@ pg_ent::enumerate_ad () full.acc_type = SidTypeAlias; else full.acc_type = group ? SidTypeGroup : SidTypeUser; - char *line = pg.fetch_account_from_windows (arg, &cldap); + char *line = pg.fetch_account_from_windows (arg, false, &cldap); if (line) return pg.add_account_post_fetch (line, false); ret = EIO; diff --git a/winsup/cygwin/release/3.6.7 b/winsup/cygwin/release/3.6.7 index 5285ba042a44..1ef4e3023e00 100644 --- a/winsup/cygwin/release/3.6.7 +++ b/winsup/cygwin/release/3.6.7 @@ -10,3 +10,6 @@ Fixes: - Correctly handle i->İ, I->ı conversion in turk lnd azerbaijani languages (LC_CTYPE=tr_TR, tr_CY, az_AZ). + +- Fix uid/gid mapping from unix id to Cygwin id in certain scenarios when + accessing Samba or NFS shares on unixoid OS. diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 73e61cbffc82..57bb6d098d8b 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -1616,7 +1616,7 @@ pwdgrp::add_account_from_windows (cygpsid &sid, cyg_ldap *pldap) fetch_user_arg_t arg; arg.type = SID_arg; arg.sid = &sid; - char *line = fetch_account_from_windows (arg, pldap); + char *line = fetch_account_from_windows (arg, true, pldap); if (!line) return NULL; return add_account_post_fetch (line, true); @@ -1628,7 +1628,7 @@ pwdgrp::add_account_from_windows (const char *name, cyg_ldap *pldap) fetch_user_arg_t arg; arg.type = NAME_arg; arg.name = name; - char *line = fetch_account_from_windows (arg, pldap); + char *line = fetch_account_from_windows (arg, true, pldap); if (!line) return NULL; return add_account_post_fetch (line, true); @@ -1640,7 +1640,7 @@ pwdgrp::add_account_from_windows (uint32_t id, cyg_ldap *pldap) fetch_user_arg_t arg; arg.type = ID_arg; arg.id = id; - char *line = fetch_account_from_windows (arg, pldap); + char *line = fetch_account_from_windows (arg, true, pldap); if (!line) return NULL; return add_account_post_fetch (line, true); @@ -1653,7 +1653,7 @@ pwdgrp::add_group_from_windows (fetch_acc_t &full_acc, cyg_ldap *pldap) fetch_user_arg_t arg; arg.type = FULL_acc_arg; arg.full_acc = &full_acc; - char *line = fetch_account_from_windows (arg, pldap); + char *line = fetch_account_from_windows (arg, true, pldap); if (!line) return NULL; return (struct group *) add_account_post_fetch (line, true); @@ -1939,7 +1939,7 @@ pwdgrp::construct_sid_from_name (cygsid &sid, wchar_t *name, wchar_t *sep) } char * -pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) +pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool ugid_caching, cyg_ldap *pldap) { /* Used in LookupAccount calls. */ WCHAR namebuf[DNLEN + 1 + UNLEN + 1], *name = namebuf; @@ -2500,7 +2500,7 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) name, fully_qualified_name); /* Check and, if necessary, add unix<->windows id mapping on the fly, unless we're called from getpwent. */ - if (!pldap && cldap->is_open ()) + if (ugid_caching && cldap->is_open ()) { id_val = cldap->get_unix_uid (); if (id_val != ILLEGAL_UID @@ -2584,7 +2584,8 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) gid = gr->gr_gid; } char *e; - if (!pldap && uxid && ((id_val = strtoul (uxid, &e, 10)), !*e)) + if (ugid_caching && uxid + && ((id_val = strtoul (uxid, &e, 10)), !*e)) { if (acc_type == SidTypeUser) {
