diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 05662d29d..523288f4b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2014-06-17 Corinna Vinschen + + * ldap.cc (CYG_LDAP_TIMEOUT): Define as timeout value. Set to 30 secs + for now. Use throughout. + * uinfo.cc (colon_to_semicolon): New local function. + (pwdgrp::fetch_account_from_windows): Convert all colons in AD gecos + entry to commas. + 2014-06-17 David Stacey * libc/rexec.cc (cygwin_rexec): Make ahostbuf static to avoid returning diff --git a/winsup/cygwin/ldap.cc b/winsup/cygwin/ldap.cc index cee07c333..4a1f25812 100644 --- a/winsup/cygwin/ldap.cc +++ b/winsup/cygwin/ldap.cc @@ -22,7 +22,9 @@ details. */ #include "dsgetdc.h" #include "tls_pbuf.h" -static LDAP_TIMEVAL tv = { 3, 0 }; +#define CYG_LDAP_TIMEOUT 30 /* seconds */ + +static LDAP_TIMEVAL tv = { CYG_LDAP_TIMEOUT, 0 }; static PWCHAR rootdse_attr[] = { @@ -75,7 +77,7 @@ PWCHAR rfc2307_gid_attr[] = bool cyg_ldap::connect_ssl (PCWSTR domain) { - ULONG ret, timelimit = 3; /* secs */ + ULONG ret, timelimit = CYG_LDAP_TIMEOUT; if (!(lh = ldap_sslinitW ((PWCHAR) domain, LDAP_SSL_PORT, 1))) { @@ -98,7 +100,7 @@ cyg_ldap::connect_ssl (PCWSTR domain) bool cyg_ldap::connect_non_ssl (PCWSTR domain) { - ULONG ret, timelimit = 3; /* secs */ + ULONG ret, timelimit = CYG_LDAP_TIMEOUT; if (!(lh = ldap_initW ((PWCHAR) domain, LDAP_PORT))) { @@ -291,7 +293,7 @@ cyg_ldap::enumerate_ad_accounts (PCWSTR domain, bool group) "(objectSid=*))"; srch_id = ldap_search_init_pageW (lh, rootdse, LDAP_SCOPE_SUBTREE, (PWCHAR) filter, sid_attr, 0, - NULL, NULL, 3, 100, NULL); + NULL, NULL, CYG_LDAP_TIMEOUT, 100, NULL); if (srch_id == NULL) { debug_printf ("ldap_search_init_pageW(%W,%W) error 0x%02x", diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 9c9428f64..2b91835f1 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -1162,6 +1162,16 @@ fetch_posix_offset (PDS_DOMAIN_TRUSTSW td, cyg_ldap *cldap) return td->PosixOffset; } +/* Helper function to replace colons with commas in pw_gecos field. */ +static PWCHAR +colon_to_semicolon (PWCHAR str) +{ + PWCHAR cp = str; + while ((cp = wcschr (cp, L':')) != NULL) + *cp++ = L';'; + return str; +} + /* CV 2014-05-08: USER_INFO_24 is not yet defined in Mingw64, but will be in the next release. For the time being, define the structure here with another name which won't collide with the upcoming correct definition @@ -1597,8 +1607,9 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) if ((id_val = cldap->get_primary_gid ()) != ILLEGAL_GID) gid = posix_offset + id_val; if ((val = cldap->get_gecos ())) - gecos = wcscpy ((PWCHAR) alloca ((wcslen (val) + 1) - * sizeof (WCHAR)), val); + gecos = colon_to_semicolon ( + wcscpy ((PWCHAR) alloca ((wcslen (val) + 1) + * sizeof (WCHAR)), val)); if ((val = cldap->get_home ())) home = wcscpy ((PWCHAR) alloca ((wcslen (val) + 1) * sizeof (WCHAR)), val);