diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-02-17 19:36:33 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-02-17 19:36:33 +0400 |
commit | a8cf6887a2ea00524ebf330eb50a05cf8e67bc5c (patch) | |
tree | 63b01096a3b6deb0afe5fdfddc43ec5ddd1487c6 /winsup/cygwin/pwdgrp.h | |
parent | 1e705e29329a0bca000bfb1f199042ffedfe477b (diff) |
* autoload.cc (ldap_abandon): Import.
(ldap_result): Import.
(ldap_searchW): Import.
(NetGroupEnum): Import.
(NetLocalGroupEnum): Import.
(NetUserEnum): Import.
* cygheap.h (class cygheap_pwdgrp): Add members enums and enum_tdoms.
(cygheap_pwdgrp::nss_db_enums): New inline method.
(cygheap_pwdgrp::nss_db_enum_tdoms): Ditto.
* cygtls.h (struct _local_storage): Drop unused members pw_pos and
grp_pos.
* grp.cc (grent): New static variable of class gr_ent.
(gr_ent::enumerate_caches): New method.
(gr_ent::enumerate_local): New method.
(gr_ent::getgrent): New method.
(setgrent): Call gr_ent method.
(getgrent32): Ditto.
(endgrent): Ditto.
* ldap.cc (sid_attr): Rename from nfs_attr.
(cyg_ldap::close): Abandon still running asynchronous search.
(cyg_ldap::fetch_ad_account): Reduce filter buffer size.
(cyg_ldap::enumerate_ad_accounts): New method.
(cyg_ldap::next_account): New method.
(cyg_ldap::fetch_posix_offset_for_domain): Reduce filter buffer size.
(cyg_ldap::fetch_unix_sid_from_ad): Ditto. Fix return value in case
no value has been read.
(cyg_ldap::fetch_unix_name_from_rfc2307): Reduce filter buffer size.
* ldap.h (class cyg_ldap): Add msg_id member.
(cyg_ldap::enumerate_ad_accounts): Declare.
(cyg_ldap::next_account): Declare:
* passwd.cc (pwent): New static variable of class pw_ent.
(pg_ent::clear_cache): New method.
(pg_ent::setent): New method.
(pg_ent::getent): New method.
(pg_ent::endent): New method.
(pg_ent::enumerate_file): New method.
(pg_ent::enumerate_builtin): New method.
(pg_ent::enumerate_sam): New method.
(pg_ent::enumerate_ad): New method.
(pw_ent::enumerate_caches): New method.
(pw_ent::enumerate_local): New method.
(pw_ent::getpwent): New method.
(setpwent): Call pw_ent method.
(getpwent): Ditto.
(endpwent): Ditto.
* pwdgrp.h (class pwdgrp): Define pg_ent, pw_ent and gr_ent as friend
classes.
(pwdgrp::add_account_post_fetch): Declare with extra bool parameter.
(pwdgrp::file_attr): New inline method.
(enum nss_enum_t): Define.
(class pg_ent): Define.
(class pw_ent): Define.
(class gr_ent): Define.
* tlsoffsets.h: Regenerate.
* tlsoffsets64.h: Ditto.
* uinfo.cc (cygheap_pwdgrp::init): Initialize enums and enum_tdoms.
(cygheap_pwdgrp::nss_init_line): Fix typo in preceeding comment.
Handle new "db_enum" keyword.
(pwdgrp::add_account_post_fetch): Take additional `bool lock' parameter
and acquire pglock before adding element to array if lock is true.
(pwdgrp::add_account_from_file): Call add_account_post_fetch with lock
set to true.
(pwdgrp::add_account_from_windows): Ditto in case of caching.
(pwdgrp::fetch_account_from_windows): Handle builtin aliases only
known to the domain controller. Only call NetLocalGroupGetInfo for
aliases.
Diffstat (limited to 'winsup/cygwin/pwdgrp.h')
-rw-r--r-- | winsup/cygwin/pwdgrp.h | 102 |
1 files changed, 101 insertions, 1 deletions
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h index 4ed245104..e59b2173b 100644 --- a/winsup/cygwin/pwdgrp.h +++ b/winsup/cygwin/pwdgrp.h @@ -23,6 +23,8 @@ extern struct group *internal_getgrnam (const char *); int internal_getgroups (int, gid_t *, cygpsid * = NULL); #include "sync.h" +#include "ldap.h" +#include "miscfuncs.h" enum fetch_user_arg_type_t { SID_arg, @@ -56,6 +58,10 @@ struct pg_grp class pwdgrp { + friend class pg_ent; + friend class pw_ent; + friend class gr_ent; + unsigned pwdgrp_buf_elem_size; void *pwdgrp_buf; bool (pwdgrp::*parse) (); @@ -87,7 +93,7 @@ class pwdgrp i = (int) x; return res; } - void *add_account_post_fetch (char *line); + void *add_account_post_fetch (char *line, bool lock); void *add_account_from_file (cygpsid &sid); void *add_account_from_file (const char *name); void *add_account_from_file (uint32_t id); @@ -103,6 +109,7 @@ class pwdgrp public: ULONG cached_users () const { return curr_lines; } ULONG cached_groups () const { return curr_lines; } + POBJECT_ATTRIBUTES file_attr () { return &attr; } bool check_file (bool group); void init_pwd (); @@ -141,3 +148,96 @@ public: struct group *find_group (const char *name); struct group *find_group (gid_t gid); }; + +enum nss_enum_t +{ + ENUM_NONE = 0x00, + ENUM_CACHE = 0x01, + ENUM_FILES = 0x02, + ENUM_BUILTIN = 0x04, + ENUM_LOCAL = 0x08, + ENUM_PRIMARY = 0x10, + ENUM_TDOMS = 0x20, + ENUM_TDOMS_ALL = 0x40, + ENUM_ALL = 0x7f +}; + +class pg_ent +{ +protected: + pwdgrp pg; + bool group; + pg_pwd pwd; + pg_grp grp; + NT_readline rl; + cyg_ldap cldap; + PCHAR buf; + ULONG cnt; + ULONG max; + ULONG_PTR resume; + int enums; + PCWSTR enum_tdoms; + bool from_files; + bool from_db; + enum { + rewound = 0, + from_cache, + from_file, + from_builtin, + from_local, + from_sam, + from_ad, + finished + } state; + + void clear_cache (); + inline bool nss_db_enum_caches () const { return !!(enums & ENUM_CACHE); } + inline bool nss_db_enum_files () const { return !!(enums & ENUM_FILES); } + inline bool nss_db_enum_builtin () const { return !!(enums & ENUM_BUILTIN); } + inline bool nss_db_enum_local () const { return !!(enums & ENUM_LOCAL); } + inline bool nss_db_enum_primary () const { return !!(enums & ENUM_PRIMARY); } + inline bool nss_db_enum_tdom (PWCHAR domain) + { + if (enums & ENUM_TDOMS_ALL) + return true; + if (!(enums & ENUM_TDOMS) || !enum_tdoms || !domain) + return false; + for (PCWSTR td = enum_tdoms; td && *td; td = wcschr (td, L'\0')) + if (!wcscasecmp (td, domain)) + return true; + return false; + } + virtual void *enumerate_caches () = 0; + virtual void *enumerate_file (); + virtual void *enumerate_builtin (); + virtual void *enumerate_local () = 0; + virtual void *enumerate_sam (); + virtual void *enumerate_ad (); + +public: + void setent (bool _group, int _enums = 0, PCWSTR _enum_tdoms = NULL); + void *getent (); + void endent (bool _group); +}; + +class pw_ent : public pg_ent +{ + void *enumerate_caches (); + void *enumerate_local (); +public: + inline void setpwent (int _enums = 0, PCWSTR _enum_tdoms = NULL) + { setent (false, _enums, _enum_tdoms); } + struct passwd *getpwent (); + inline void endpwent () { endent (false); } +}; + +class gr_ent : public pg_ent +{ + void *enumerate_caches (); + void *enumerate_local (); +public: + inline void setgrent (int _enums = 0, PCWSTR _enum_tdoms = NULL) + { setent (true, _enums, _enum_tdoms); } + struct group *getgrent (); + inline void endgrent () { endent (true); } +}; |