* cygheap.h (enum cygheap_pwdgrp::cache_t): Remove.
(cygheap_pwdgrp::caching): Convert to bool. (cygheap_pwdgrp::pwd_cache): Add cygserver member. (cygheap_pwdgrp::grp_cache): Ditto. (cygheap_pwdgrp::nss_db_caching): Drop. (cygheap_pwdgrp::nss_db_full_caching): Drop. (cygheap_pwdgrp::nss_cygserver_caching): New method. (cygheap_pwdgrp::nss_disable_cygserver_caching): New method. * cygserver.h (client_request::request_code_t): Add CYGSERVER_REQUEST_PWDGRP. * cygserver_pwdgrp.h: New file. * cygtls.h (struct _local_storage): Remove pwbuf and grbuf members. * grp.cc (pwdgrp::prep_tls_grbuf): Drop. (internal_getgrsid): Handle cygserver caching and rearrange to check the caches first. (internal_getgrnam): Ditto. (internal_getgrgid): Ditto. (gr_ent::enumerate_caches): Handle cygserver cache. * passwd.cc (pwdgrp::prep_tls_pwbuf): Drop. (internal_getpwsid): Handle cygserver caching and rearrange to check the caches first. (internal_getpwnam): Ditto. (internal_getpwuid): Ditto. (pw_ent::enumerate_caches): Handle cygserver cache. * pwdgrp.h (pwdgrp::add_account_from_cygserver): New method declaration. (pwdgrp::fetch_account_from_cygserver): New method declaration. (pwdgrp::prep_tls_pwbuf): Drop declaration. (pwdgrp::prep_tls_grbuf): Drop declaration. (pwdgrp::add_user_from_cygserver): New inline methods. (pwdgrp::add_group_from_cygserver): New inline methods. * tlsoffsets.h: Regenerate. * tlsoffsets64.h: Regenerate. * uinfo.cc (internal_getlogin): Call internal_getgroups if cygserver caching is not available. (cygheap_pwdgrp::init): Initialize pwd_cache.cygserver and grp_cache.cygserver. Set caching to true. (cygheap_pwdgrp::nss_init_line): Drop db_cache handling entirely. (pwdgrp::add_account_from_windows): Drop no caching handling. (client_request_pwdgrp::client_request_pwdgrp): New method. (pwdgrp::fetch_account_from_cygserver): New method. (pwdgrp::add_account_from_cygserver): New method. * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix formatting. * include/sys/cygwin.h: Ditto.
This commit is contained in:
@@ -51,27 +51,6 @@ pwdgrp::init_pwd ()
|
||||
parse = &pwdgrp::parse_passwd;
|
||||
}
|
||||
|
||||
pwdgrp *
|
||||
pwdgrp::prep_tls_pwbuf ()
|
||||
{
|
||||
if (!_my_tls.locals.pwbuf)
|
||||
{
|
||||
_my_tls.locals.pwbuf = ccalloc_abort (HEAP_BUF, 1,
|
||||
sizeof (pwdgrp) + sizeof (pg_pwd));
|
||||
pwdgrp *pw = (pwdgrp *) _my_tls.locals.pwbuf;
|
||||
pw->init_pwd ();
|
||||
pw->pwdgrp_buf = (void *) (pw + 1);
|
||||
pw->max_lines = 1;
|
||||
}
|
||||
pwdgrp *pw = (pwdgrp *) _my_tls.locals.pwbuf;
|
||||
if (pw->curr_lines)
|
||||
{
|
||||
cfree (pw->passwd ()[0].p.pw_name);
|
||||
pw->curr_lines = 0;
|
||||
}
|
||||
return pw;
|
||||
}
|
||||
|
||||
struct passwd *
|
||||
pwdgrp::find_user (cygpsid &sid)
|
||||
{
|
||||
@@ -106,20 +85,28 @@ internal_getpwsid (cygpsid &sid, cyg_ldap *pldap)
|
||||
struct passwd *ret;
|
||||
|
||||
cygheap->pg.nss_init ();
|
||||
/* Check caches first. */
|
||||
if (cygheap->pg.nss_cygserver_caching ()
|
||||
&& (ret = cygheap->pg.pwd_cache.cygserver.find_user (sid)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_files ()
|
||||
&& (ret = cygheap->pg.pwd_cache.file.find_user (sid)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_db ()
|
||||
&& (ret = cygheap->pg.pwd_cache.win.find_user (sid)))
|
||||
return ret;
|
||||
/* Ask sources afterwards. */
|
||||
if (cygheap->pg.nss_cygserver_caching ()
|
||||
&& (ret = cygheap->pg.pwd_cache.cygserver.add_user_from_cygserver (sid)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_files ())
|
||||
{
|
||||
cygheap->pg.pwd_cache.file.check_file ();
|
||||
if ((ret = cygheap->pg.pwd_cache.file.find_user (sid)))
|
||||
return ret;
|
||||
if ((ret = cygheap->pg.pwd_cache.file.add_user_from_file (sid)))
|
||||
return ret;
|
||||
}
|
||||
if (cygheap->pg.nss_pwd_db ())
|
||||
{
|
||||
if ((ret = cygheap->pg.pwd_cache.win.find_user (sid)))
|
||||
return ret;
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (sid, pldap);
|
||||
}
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (sid, pldap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -137,20 +124,28 @@ internal_getpwnam (const char *name, cyg_ldap *pldap)
|
||||
struct passwd *ret;
|
||||
|
||||
cygheap->pg.nss_init ();
|
||||
/* Check caches first. */
|
||||
if (cygheap->pg.nss_cygserver_caching ()
|
||||
&& (ret = cygheap->pg.pwd_cache.cygserver.find_user (name)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_files ()
|
||||
&& (ret = cygheap->pg.pwd_cache.file.find_user (name)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_db ()
|
||||
&& (ret = cygheap->pg.pwd_cache.win.find_user (name)))
|
||||
return ret;
|
||||
/* Ask sources afterwards. */
|
||||
if (cygheap->pg.nss_cygserver_caching ()
|
||||
&& (ret = cygheap->pg.pwd_cache.cygserver.add_user_from_cygserver (name)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_files ())
|
||||
{
|
||||
cygheap->pg.pwd_cache.file.check_file ();
|
||||
if ((ret = cygheap->pg.pwd_cache.file.find_user (name)))
|
||||
return ret;
|
||||
if ((ret = cygheap->pg.pwd_cache.file.add_user_from_file (name)))
|
||||
return ret;
|
||||
}
|
||||
if (cygheap->pg.nss_pwd_db ())
|
||||
{
|
||||
if ((ret = cygheap->pg.pwd_cache.win.find_user (name)))
|
||||
return ret;
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (name, pldap);
|
||||
}
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (name, pldap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -160,22 +155,28 @@ internal_getpwuid (uid_t uid, cyg_ldap *pldap)
|
||||
struct passwd *ret;
|
||||
|
||||
cygheap->pg.nss_init ();
|
||||
/* Check caches first. */
|
||||
if (cygheap->pg.nss_cygserver_caching ()
|
||||
&& (ret = cygheap->pg.pwd_cache.cygserver.find_user (uid)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_files ()
|
||||
&& (ret = cygheap->pg.pwd_cache.file.find_user (uid)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_db ()
|
||||
&& (ret = cygheap->pg.pwd_cache.win.find_user (uid)))
|
||||
return ret;
|
||||
/* Ask sources afterwards. */
|
||||
if (cygheap->pg.nss_cygserver_caching ()
|
||||
&& (ret = cygheap->pg.pwd_cache.cygserver.add_user_from_cygserver (uid)))
|
||||
return ret;
|
||||
if (cygheap->pg.nss_pwd_files ())
|
||||
{
|
||||
cygheap->pg.pwd_cache.file.check_file ();
|
||||
if ((ret = cygheap->pg.pwd_cache.file.find_user (uid)))
|
||||
return ret;
|
||||
if ((ret = cygheap->pg.pwd_cache.file.add_user_from_file (uid)))
|
||||
return ret;
|
||||
}
|
||||
if (cygheap->pg.nss_pwd_db ())
|
||||
{
|
||||
if ((ret = cygheap->pg.pwd_cache.win.find_user (uid)))
|
||||
return ret;
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (uid, pldap);
|
||||
}
|
||||
else if (uid == ILLEGAL_UID)
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (uid);
|
||||
if (cygheap->pg.nss_pwd_db () || uid == ILLEGAL_UID)
|
||||
return cygheap->pg.pwd_cache.win.add_user_from_windows (uid, pldap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -596,20 +597,37 @@ pg_ent::enumerate_ad ()
|
||||
void *
|
||||
pw_ent::enumerate_caches ()
|
||||
{
|
||||
if (!max && from_files)
|
||||
switch (max)
|
||||
{
|
||||
pwdgrp &prf = cygheap->pg.pwd_cache.file;
|
||||
prf.check_file ();
|
||||
if (cnt < prf.cached_users ())
|
||||
return &prf.passwd ()[cnt++].p;
|
||||
case 0:
|
||||
if (cygheap->pg.nss_cygserver_caching ())
|
||||
{
|
||||
pwdgrp &prc = cygheap->pg.pwd_cache.cygserver;
|
||||
if (cnt < prc.cached_users ())
|
||||
return &prc.passwd ()[cnt++].p;
|
||||
}
|
||||
cnt = 0;
|
||||
max = 1;
|
||||
}
|
||||
if (from_db && cygheap->pg.nss_db_caching ())
|
||||
{
|
||||
pwdgrp &prw = cygheap->pg.pwd_cache.win;
|
||||
if (cnt < prw.cached_users ())
|
||||
return &prw.passwd ()[cnt++].p;
|
||||
/*FALLTHRU*/
|
||||
case 1:
|
||||
if (from_files)
|
||||
{
|
||||
pwdgrp &prf = cygheap->pg.pwd_cache.file;
|
||||
prf.check_file ();
|
||||
if (cnt < prf.cached_users ())
|
||||
return &prf.passwd ()[cnt++].p;
|
||||
}
|
||||
cnt = 0;
|
||||
max = 2;
|
||||
/*FALLTHRU*/
|
||||
default:
|
||||
if (from_db)
|
||||
{
|
||||
pwdgrp &prw = cygheap->pg.pwd_cache.win;
|
||||
if (cnt < prw.cached_users ())
|
||||
return &prw.passwd ()[cnt++].p;
|
||||
}
|
||||
break;
|
||||
}
|
||||
cnt = max = 0;
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user