* pwdgrp.h (pwdgrp::fetch_account_from_windows): Add bool parameter

to declaration, set to true by default.
	* uinfo.cc (pwdgrp::fetch_account_from_windows): Add bool parameter
	"ugid_caching".  Only add account to ugid_cache if set to true.
	* grp.cc (gr_ent::enumerate_local): Call fetch_account_from_windows
	with ugid_caching parameter set to false.
	* passwd.cc (pg_ent::enumerate_builtin): Ditto.
	(pg_ent::enumerate_sam): Ditto.
	(pg_ent::enumerate_ad): Ditto.
This commit is contained in:
Corinna Vinschen 2014-02-21 10:01:00 +00:00
parent 6480b2ae76
commit 98cc373860
5 changed files with 40 additions and 17 deletions

View File

@ -1,3 +1,15 @@
2014-02-21 Corinna Vinschen <corinna@vinschen.de>
* pwdgrp.h (pwdgrp::fetch_account_from_windows): Add bool parameter
to declaration, set to true by default.
* uinfo.cc (pwdgrp::fetch_account_from_windows): Add bool parameter
"ugid_caching". Only add account to ugid_cache if set to true.
* grp.cc (gr_ent::enumerate_local): Call fetch_account_from_windows
with ugid_caching parameter set to false.
* passwd.cc (pg_ent::enumerate_builtin): Ditto.
(pg_ent::enumerate_sam): Ditto.
(pg_ent::enumerate_ad): Ditto.
2014-02-20 Corinna Vinschen <corinna@vinschen.de> 2014-02-20 Corinna Vinschen <corinna@vinschen.de>
* grp.cc (getgrouplist): Fix previous fix so ret is only set to ngroups * grp.cc (getgrouplist): Fix previous fix so ret is only set to ngroups

View File

@ -381,7 +381,7 @@ gr_ent::enumerate_local ()
fetch_user_arg_t arg; fetch_user_arg_t arg;
arg.type = SID_arg; arg.type = SID_arg;
arg.sid = &sid; arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, true); char *line = pg.fetch_account_from_windows (arg, true, false);
if (line) if (line)
return pg.add_account_post_fetch (line, false); return pg.add_account_post_fetch (line, false);
} }

View File

@ -487,7 +487,7 @@ pg_ent::enumerate_builtin ()
fetch_user_arg_t arg; fetch_user_arg_t arg;
arg.type = SID_arg; arg.type = SID_arg;
arg.sid = &sid; arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, group); char *line = pg.fetch_account_from_windows (arg, group, false);
return pg.add_account_post_fetch (line, false); return pg.add_account_post_fetch (line, false);
} }
@ -534,7 +534,7 @@ pg_ent::enumerate_sam ()
fetch_user_arg_t arg; fetch_user_arg_t arg;
arg.type = SID_arg; arg.type = SID_arg;
arg.sid = &sid; arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, group); char *line = pg.fetch_account_from_windows (arg, group, false);
if (line) if (line)
return pg.add_account_post_fetch (line, false); return pg.add_account_post_fetch (line, false);
} }
@ -583,7 +583,7 @@ pg_ent::enumerate_ad ()
fetch_user_arg_t arg; fetch_user_arg_t arg;
arg.type = SID_arg; arg.type = SID_arg;
arg.sid = &sid; arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, group); char *line = pg.fetch_account_from_windows (arg, group, false);
if (line) if (line)
return pg.add_account_post_fetch (line, false); return pg.add_account_post_fetch (line, false);
} }

View File

@ -110,7 +110,8 @@ class pwdgrp
void *add_account_from_windows (uint32_t id, bool group); void *add_account_from_windows (uint32_t id, bool group);
char *fetch_account_from_line (fetch_user_arg_t &arg, const char *line); 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_file (fetch_user_arg_t &arg);
char *fetch_account_from_windows (fetch_user_arg_t &arg, bool group); char *fetch_account_from_windows (fetch_user_arg_t &arg, bool group,
bool ugid_caching = true);
pwdgrp *prep_tls_pwbuf (); pwdgrp *prep_tls_pwbuf ();
pwdgrp *prep_tls_grbuf (); pwdgrp *prep_tls_grbuf ();

View File

@ -1162,7 +1162,8 @@ fetch_posix_offset (PDS_DOMAIN_TRUSTSW td, bool &ldap_open, cyg_ldap &cldap)
} }
char * char *
pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group) pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group,
bool ugid_caching)
{ {
/* Used in LookupAccount calls. */ /* Used in LookupAccount calls. */
WCHAR namebuf[UNLEN + 1], *name = namebuf; WCHAR namebuf[UNLEN + 1], *name = namebuf;
@ -1502,11 +1503,14 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
* sizeof (WCHAR)), val); * sizeof (WCHAR)), val);
/* Check and, if necessary, add unix<->windows /* Check and, if necessary, add unix<->windows
id mapping on the fly. */ id mapping on the fly. */
id_val = cldap.get_unix_uid (); if (ugid_caching)
if (id_val != ILLEGAL_UID {
&& cygheap->ugid_cache.get_uid (id_val) id_val = cldap.get_unix_uid ();
== ILLEGAL_UID) if (id_val != ILLEGAL_UID
cygheap->ugid_cache.add_uid (id_val, uid); && cygheap->ugid_cache.get_uid (id_val)
== ILLEGAL_UID)
cygheap->ugid_cache.add_uid (id_val, uid);
}
} }
else /* SidTypeGroup */ else /* SidTypeGroup */
{ {
@ -1514,11 +1518,16 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
&& wcscmp (name, val)) && wcscmp (name, val))
user = wcscpy ((PWCHAR) alloca ((wcslen (val) + 1) user = wcscpy ((PWCHAR) alloca ((wcslen (val) + 1)
* sizeof (WCHAR)), val); * sizeof (WCHAR)), val);
id_val = cldap.get_unix_gid (); /* Check and, if necessary, add unix<->windows
if (id_val != ILLEGAL_GID id mapping on the fly. */
&& cygheap->ugid_cache.get_gid (id_val) if (ugid_caching)
== ILLEGAL_GID) {
cygheap->ugid_cache.add_gid (id_val, uid); id_val = cldap.get_unix_gid ();
if (id_val != ILLEGAL_GID
&& cygheap->ugid_cache.get_gid (id_val)
== ILLEGAL_GID)
cygheap->ugid_cache.add_gid (id_val, uid);
}
} }
} }
} }
@ -1624,7 +1633,8 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
|| (gr = internal_getgrnam (gname + 1))) || (gr = internal_getgrnam (gname + 1)))
gid = gr->gr_gid; gid = gr->gr_gid;
} }
if (uxid && ((id_val = wcstoul (uxid, &e, 10)), !*e)) if (ugid_caching && uxid
&& ((id_val = wcstoul (uxid, &e, 10)), !*e))
{ {
if (acc_type == SidTypeUser) if (acc_type == SidTypeUser)
{ {