* 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>
* 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;
arg.type = SID_arg;
arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, true);
char *line = pg.fetch_account_from_windows (arg, true, false);
if (line)
return pg.add_account_post_fetch (line, false);
}

View file

@ -487,7 +487,7 @@ pg_ent::enumerate_builtin ()
fetch_user_arg_t arg;
arg.type = SID_arg;
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);
}
@ -534,7 +534,7 @@ pg_ent::enumerate_sam ()
fetch_user_arg_t arg;
arg.type = SID_arg;
arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, group);
char *line = pg.fetch_account_from_windows (arg, group, false);
if (line)
return pg.add_account_post_fetch (line, false);
}
@ -583,7 +583,7 @@ pg_ent::enumerate_ad ()
fetch_user_arg_t arg;
arg.type = SID_arg;
arg.sid = &sid;
char *line = pg.fetch_account_from_windows (arg, group);
char *line = pg.fetch_account_from_windows (arg, group, false);
if (line)
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);
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 group);
char *fetch_account_from_windows (fetch_user_arg_t &arg, bool group,
bool ugid_caching = true);
pwdgrp *prep_tls_pwbuf ();
pwdgrp *prep_tls_grbuf ();

View file

@ -1162,7 +1162,8 @@ fetch_posix_offset (PDS_DOMAIN_TRUSTSW td, bool &ldap_open, cyg_ldap &cldap)
}
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. */
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);
/* Check and, if necessary, add unix<->windows
id mapping on the fly. */
id_val = cldap.get_unix_uid ();
if (id_val != ILLEGAL_UID
&& cygheap->ugid_cache.get_uid (id_val)
== ILLEGAL_UID)
cygheap->ugid_cache.add_uid (id_val, uid);
if (ugid_caching)
{
id_val = cldap.get_unix_uid ();
if (id_val != ILLEGAL_UID
&& cygheap->ugid_cache.get_uid (id_val)
== ILLEGAL_UID)
cygheap->ugid_cache.add_uid (id_val, uid);
}
}
else /* SidTypeGroup */
{
@ -1514,11 +1518,16 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group)
&& wcscmp (name, val))
user = wcscpy ((PWCHAR) alloca ((wcslen (val) + 1)
* sizeof (WCHAR)), val);
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);
/* Check and, if necessary, add unix<->windows
id mapping on the fly. */
if (ugid_caching)
{
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)))
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)
{