2001-09-10 00:52:37 +08:00
|
|
|
/* pwdgrp.h
|
|
|
|
|
|
|
|
Stuff common to pwd and grp handling.
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2014-02-10 03:44:56 +08:00
|
|
|
#pragma once
|
|
|
|
|
2014-02-27 20:57:27 +08:00
|
|
|
#include "sync.h"
|
|
|
|
#include "ldap.h"
|
|
|
|
#include "miscfuncs.h"
|
2015-02-24 04:51:12 +08:00
|
|
|
#include "userinfo.h"
|
2014-02-27 20:57:27 +08:00
|
|
|
|
2002-12-10 Pierre Humblet <pierre.humblet@ieee.org>
* pwdgrp.h (pwdgrp_check::pwdgrp_state): Replace by
pwdgrp_check::isinitializing ().
(pwdgrp_check::isinitializing): Create.
* passwd.cc (grab_int): Change type to unsigned, use strtoul and
set the pointer content to 0 if the field is invalid.
(parse_pwd): Move validity test after getting pw_gid.
(read_etc_passwd): Replace "passwd_state <= " by
passwd_state::isinitializing ().
(internal_getpwuid): Ditto.
(internal_getpwnam): Ditto.
(getpwent): Ditto.
(getpass): Ditto.
* grp.cc (parse_grp): Use strtoul for gr_gid and verify the validity.
(read_etc_group): Replace "group_state <= " by
group_state::isinitializing ().
(internal_getgrgid): Ditto.
(getgrent32): Ditto.
(internal_getgrent): Ditto.
2002-12-10 Pierre Humblet <pierre.humblet@ieee.org>
* security.h: Move declarations of internal_getgrent,
internal_getpwsid and internal_getgrsid to pwdgrp.h.
* pwdgrp.h: Declare internal_getpwsid, internal_getpwnam,
internal_getpwuid, internal_getgrsid, internal_getgrgid,
internal_getgrnam, internal_getgrent and internal_getgroups.
Delete "emulated" from enum pwdgrp_state.
(pwdgrp_check::isuninitialized): Create.
(pwdgrp_check::pwdgrp_state): Change state to initializing
rather than to uninitialized.
(pwdgrp_read::gets): Remove trailing CRs.
* passwd.cc (grab_string): Don't look for NLs.
(grab_int): Ditto.
(parse_pwd): Don't look for CRs. Return 0 if entry is too short.
(search_for): Delete.
(read_etc_passwd): Simplify tests to actually read the file.
Set state to loaded before making internal_getpwXX calls.
Replace search_for calls by equivalent internal_pwgetXX calls.
(internal_getpwsid): Use passwd_state.isuninitialized to decide
to call read_etc_passwd.
(internal_getpwuid): Create.
(internal_getpwnam): Create.
(getpwuid32): Simply call internal_getpwuid.
(getpwuid_r32): Call internal_getpwuid.
(getpwnam): Simply call internal_getpwnam.
(getpwnam_r): Call internal_getpwnam.
* grp.cc (parse_grp): Don't look for CRs. Adjust blank space.
(add_grp_line): Adjust blank space.
(class group_lock): Ditto.
(read_etc_group): Simplify tests to actually read the file.
Set state to loaded before making internal_getgrXX calls.
Replace getgrXX calls by equivalent internal calls.
(internal_getgrsid): Use group_state.isuninitialized to decide
to call read_etc_group.
(internal_getgrgid): Create.
(internal_getgrnam): Create.
(getgroups32): Simply call internal_getgrgid.
(getgrnam32): Simply call internal_getgrnam.
(internal_getgrent): Call group_state.isuninitialized.
(internal_getgroups): Create from the former getgroups32, using
two of the four arguments. Set gid to myself->gid and username
to cygheap->user.name ().
(getgroups32): Simply call internal_getgroup.
(getgroups): Call internal_getgroup instead of getgroups32.
(setgroups32): Call internal versions of get{pw,gr}XX.
* sec_helper.cc: Include pwdgrp.h.
(is_grp_member): Call internal versions of get{pw,gr}XX.
* security.cc: Include pwdgrp.h.
(alloc_sd): Call internal versions of get{pw,gr}XX.
* syscalls.cc: Include pwdgrp.h.
(seteuid32): Call internal versions of get{pw,gr}XX.
(setegid32): Ditto.
* uinfo.cc: Include pwdgrp.h.
(internal_getlogin): Call internal versions of get{pw,gr}XX.
(cygheap_user::ontherange): Ditto.
* sec_acl.cc: Include pwdgrp.h.
(setacl): Call internal versions of get{pw,gr}XX.
(acl_access): Ditto and simplify logic.
(aclfromtext): Ditto.
2002-12-10 20:43:49 +08:00
|
|
|
/* These functions are needed to allow searching and walking through
|
|
|
|
the passwd and group lists */
|
2014-02-27 20:57:27 +08:00
|
|
|
extern struct passwd *internal_getpwsid (cygpsid &, cyg_ldap * = NULL);
|
2014-02-23 03:38:12 +08:00
|
|
|
extern struct passwd *internal_getpwsid_from_db (cygpsid &sid);
|
2014-02-27 20:57:27 +08:00
|
|
|
extern struct passwd *internal_getpwnam (const char *, cyg_ldap * = NULL);
|
|
|
|
extern struct passwd *internal_getpwuid (uid_t, cyg_ldap * = NULL);
|
|
|
|
extern struct group *internal_getgrsid (cygpsid &, cyg_ldap * = NULL);
|
2014-02-23 03:38:12 +08:00
|
|
|
extern struct group *internal_getgrsid_from_db (cygpsid &sid);
|
2014-02-27 20:57:27 +08:00
|
|
|
extern struct group *internal_getgrgid (gid_t, cyg_ldap * = NULL);
|
|
|
|
extern struct group *internal_getgrnam (const char *, cyg_ldap * = NULL);
|
2002-12-10 Pierre Humblet <pierre.humblet@ieee.org>
* pwdgrp.h (pwdgrp_check::pwdgrp_state): Replace by
pwdgrp_check::isinitializing ().
(pwdgrp_check::isinitializing): Create.
* passwd.cc (grab_int): Change type to unsigned, use strtoul and
set the pointer content to 0 if the field is invalid.
(parse_pwd): Move validity test after getting pw_gid.
(read_etc_passwd): Replace "passwd_state <= " by
passwd_state::isinitializing ().
(internal_getpwuid): Ditto.
(internal_getpwnam): Ditto.
(getpwent): Ditto.
(getpass): Ditto.
* grp.cc (parse_grp): Use strtoul for gr_gid and verify the validity.
(read_etc_group): Replace "group_state <= " by
group_state::isinitializing ().
(internal_getgrgid): Ditto.
(getgrent32): Ditto.
(internal_getgrent): Ditto.
2002-12-10 Pierre Humblet <pierre.humblet@ieee.org>
* security.h: Move declarations of internal_getgrent,
internal_getpwsid and internal_getgrsid to pwdgrp.h.
* pwdgrp.h: Declare internal_getpwsid, internal_getpwnam,
internal_getpwuid, internal_getgrsid, internal_getgrgid,
internal_getgrnam, internal_getgrent and internal_getgroups.
Delete "emulated" from enum pwdgrp_state.
(pwdgrp_check::isuninitialized): Create.
(pwdgrp_check::pwdgrp_state): Change state to initializing
rather than to uninitialized.
(pwdgrp_read::gets): Remove trailing CRs.
* passwd.cc (grab_string): Don't look for NLs.
(grab_int): Ditto.
(parse_pwd): Don't look for CRs. Return 0 if entry is too short.
(search_for): Delete.
(read_etc_passwd): Simplify tests to actually read the file.
Set state to loaded before making internal_getpwXX calls.
Replace search_for calls by equivalent internal_pwgetXX calls.
(internal_getpwsid): Use passwd_state.isuninitialized to decide
to call read_etc_passwd.
(internal_getpwuid): Create.
(internal_getpwnam): Create.
(getpwuid32): Simply call internal_getpwuid.
(getpwuid_r32): Call internal_getpwuid.
(getpwnam): Simply call internal_getpwnam.
(getpwnam_r): Call internal_getpwnam.
* grp.cc (parse_grp): Don't look for CRs. Adjust blank space.
(add_grp_line): Adjust blank space.
(class group_lock): Ditto.
(read_etc_group): Simplify tests to actually read the file.
Set state to loaded before making internal_getgrXX calls.
Replace getgrXX calls by equivalent internal calls.
(internal_getgrsid): Use group_state.isuninitialized to decide
to call read_etc_group.
(internal_getgrgid): Create.
(internal_getgrnam): Create.
(getgroups32): Simply call internal_getgrgid.
(getgrnam32): Simply call internal_getgrnam.
(internal_getgrent): Call group_state.isuninitialized.
(internal_getgroups): Create from the former getgroups32, using
two of the four arguments. Set gid to myself->gid and username
to cygheap->user.name ().
(getgroups32): Simply call internal_getgroup.
(getgroups): Call internal_getgroup instead of getgroups32.
(setgroups32): Call internal versions of get{pw,gr}XX.
* sec_helper.cc: Include pwdgrp.h.
(is_grp_member): Call internal versions of get{pw,gr}XX.
* security.cc: Include pwdgrp.h.
(alloc_sd): Call internal versions of get{pw,gr}XX.
* syscalls.cc: Include pwdgrp.h.
(seteuid32): Call internal versions of get{pw,gr}XX.
(setegid32): Ditto.
* uinfo.cc: Include pwdgrp.h.
(internal_getlogin): Call internal versions of get{pw,gr}XX.
(cygheap_user::ontherange): Ditto.
* sec_acl.cc: Include pwdgrp.h.
(setacl): Call internal versions of get{pw,gr}XX.
(acl_access): Ditto and simplify logic.
(aclfromtext): Ditto.
2002-12-10 20:43:49 +08:00
|
|
|
|
2015-03-17 22:42:59 +08:00
|
|
|
extern int internal_getgroups (int, gid_t *, cyg_ldap *);
|
2014-02-28 19:37:02 +08:00
|
|
|
|
2014-02-19 03:39:48 +08:00
|
|
|
/* These functions are called from mkpasswd/mkgroup via cygwin_internal. */
|
|
|
|
void *setpwent_filtered (int enums, PCWSTR enum_tdoms);
|
|
|
|
void *getpwent_filtered (void *gr);
|
|
|
|
void endpwent_filtered (void *gr);
|
|
|
|
void *setgrent_filtered (int enums, PCWSTR enum_tdoms);
|
|
|
|
void *getgrent_filtered (void *gr);
|
|
|
|
void endgrent_filtered (void *gr);
|
|
|
|
|
2015-04-17 17:56:15 +08:00
|
|
|
/* NOTE: The below sid members were cygsid's originally. Don't do that.
|
|
|
|
cygsid's are pointer based. When adding new entries to the passwd or
|
|
|
|
group caches, a crealloc call potenitally moves the entries and then
|
|
|
|
the cygsid pointers point into neverneverland. */
|
2014-02-10 03:44:56 +08:00
|
|
|
struct pg_pwd
|
|
|
|
{
|
|
|
|
struct passwd p;
|
2015-04-17 17:56:15 +08:00
|
|
|
BYTE sid[SECURITY_MAX_SID_SIZE];
|
2014-05-07 19:00:00 +08:00
|
|
|
size_t len;
|
2014-02-10 03:44:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pg_grp
|
|
|
|
{
|
|
|
|
struct group g;
|
2015-04-17 17:56:15 +08:00
|
|
|
BYTE sid[SECURITY_MAX_SID_SIZE];
|
2014-05-07 19:00:00 +08:00
|
|
|
size_t len;
|
2014-02-10 03:44:56 +08:00
|
|
|
};
|
|
|
|
|
2003-01-17 13:18:30 +08:00
|
|
|
class pwdgrp
|
|
|
|
{
|
2014-02-17 23:36:33 +08:00
|
|
|
friend class pg_ent;
|
|
|
|
friend class pw_ent;
|
|
|
|
friend class gr_ent;
|
|
|
|
|
2003-01-21 14:58:11 +08:00
|
|
|
unsigned pwdgrp_buf_elem_size;
|
2014-02-10 03:44:56 +08:00
|
|
|
void *pwdgrp_buf;
|
2003-01-24 11:53:46 +08:00
|
|
|
bool (pwdgrp::*parse) ();
|
2014-02-10 03:44:56 +08:00
|
|
|
UNICODE_STRING path;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
LARGE_INTEGER last_modified;
|
|
|
|
char *lptr;
|
|
|
|
ULONG curr_lines;
|
|
|
|
ULONG max_lines;
|
2005-04-05 14:04:57 +08:00
|
|
|
static muto pglock;
|
2003-01-20 10:57:54 +08:00
|
|
|
|
2003-01-24 11:53:46 +08:00
|
|
|
bool parse_passwd ();
|
|
|
|
bool parse_group ();
|
|
|
|
char *add_line (char *);
|
2003-01-26 13:38:38 +08:00
|
|
|
char *raw_ptr () const {return lptr;}
|
2003-01-27 08:16:01 +08:00
|
|
|
char *next_str (char);
|
2003-01-26 13:38:38 +08:00
|
|
|
bool next_num (unsigned long&);
|
|
|
|
bool next_num (unsigned int& i)
|
|
|
|
{
|
|
|
|
unsigned long x;
|
|
|
|
bool res = next_num (x);
|
|
|
|
i = (unsigned int) x;
|
|
|
|
return res;
|
|
|
|
}
|
2003-04-10 13:27:34 +08:00
|
|
|
inline bool next_num (int& i)
|
2003-01-26 13:38:38 +08:00
|
|
|
{
|
|
|
|
unsigned long x;
|
|
|
|
bool res = next_num (x);
|
|
|
|
i = (int) x;
|
|
|
|
return res;
|
|
|
|
}
|
2014-02-17 23:36:33 +08:00
|
|
|
void *add_account_post_fetch (char *line, bool lock);
|
2014-02-10 03:44:56 +08:00
|
|
|
void *add_account_from_file (cygpsid &sid);
|
|
|
|
void *add_account_from_file (const char *name);
|
|
|
|
void *add_account_from_file (uint32_t id);
|
2014-03-08 04:38:48 +08:00
|
|
|
void *add_account_from_windows (cygpsid &sid, cyg_ldap *pldap = NULL);
|
|
|
|
void *add_account_from_windows (const char *name, cyg_ldap *pldap = NULL);
|
|
|
|
void *add_account_from_windows (uint32_t id, cyg_ldap *pldap = NULL);
|
2014-03-13 01:36:56 +08:00
|
|
|
void *add_account_from_cygserver (cygpsid &sid);
|
|
|
|
void *add_account_from_cygserver (const char *name);
|
|
|
|
void *add_account_from_cygserver (uint32_t id);
|
2014-02-10 03:44:56 +08:00
|
|
|
char *fetch_account_from_line (fetch_user_arg_t &arg, const char *line);
|
|
|
|
char *fetch_account_from_file (fetch_user_arg_t &arg);
|
2014-03-08 04:38:48 +08:00
|
|
|
char *fetch_account_from_windows (fetch_user_arg_t &arg,
|
2014-02-27 20:57:27 +08:00
|
|
|
cyg_ldap *pldap = NULL);
|
2014-03-13 01:36:56 +08:00
|
|
|
char *fetch_account_from_cygserver (fetch_user_arg_t &arg);
|
2001-09-10 00:52:37 +08:00
|
|
|
|
|
|
|
public:
|
2014-02-10 03:44:56 +08:00
|
|
|
ULONG cached_users () const { return curr_lines; }
|
|
|
|
ULONG cached_groups () const { return curr_lines; }
|
2014-02-17 23:36:33 +08:00
|
|
|
POBJECT_ATTRIBUTES file_attr () { return &attr; }
|
2014-03-08 04:38:48 +08:00
|
|
|
bool check_file ();
|
2003-01-20 10:57:54 +08:00
|
|
|
|
2014-02-10 03:44:56 +08:00
|
|
|
void init_pwd ();
|
2014-03-08 04:38:48 +08:00
|
|
|
bool is_passwd () const { return pwdgrp_buf_elem_size == sizeof (pg_pwd); }
|
2014-02-10 03:44:56 +08:00
|
|
|
pg_pwd *passwd () const { return (pg_pwd *) pwdgrp_buf; };
|
2014-03-13 01:36:56 +08:00
|
|
|
struct passwd *add_user_from_cygserver (cygpsid &sid)
|
|
|
|
{ return (struct passwd *) add_account_from_cygserver (sid); }
|
|
|
|
struct passwd *add_user_from_cygserver (const char *name)
|
|
|
|
{ return (struct passwd *) add_account_from_cygserver (name); }
|
|
|
|
struct passwd *add_user_from_cygserver (uint32_t id)
|
|
|
|
{ return (struct passwd *) add_account_from_cygserver (id); }
|
|
|
|
struct passwd *add_user_from_file (cygpsid &sid)
|
2014-02-10 03:44:56 +08:00
|
|
|
{ return (struct passwd *) add_account_from_file (sid); }
|
|
|
|
struct passwd *add_user_from_file (const char *name)
|
|
|
|
{ return (struct passwd *) add_account_from_file (name); }
|
|
|
|
struct passwd *add_user_from_file (uint32_t id)
|
|
|
|
{ return (struct passwd *) add_account_from_file (id); }
|
2014-02-27 20:57:27 +08:00
|
|
|
struct passwd *add_user_from_windows (cygpsid &sid, cyg_ldap *pldap = NULL)
|
2014-03-08 04:38:48 +08:00
|
|
|
{ return (struct passwd *) add_account_from_windows (sid, pldap); }
|
2014-02-27 20:57:27 +08:00
|
|
|
struct passwd *add_user_from_windows (const char *name,
|
|
|
|
cyg_ldap* pldap = NULL)
|
2014-03-08 04:38:48 +08:00
|
|
|
{ return (struct passwd *) add_account_from_windows (name, pldap); }
|
2014-02-27 20:57:27 +08:00
|
|
|
struct passwd *add_user_from_windows (uint32_t id, cyg_ldap *pldap = NULL)
|
2014-03-08 04:38:48 +08:00
|
|
|
{ return (struct passwd *) add_account_from_windows (id, pldap); }
|
2014-02-10 03:44:56 +08:00
|
|
|
struct passwd *find_user (cygpsid &sid);
|
|
|
|
struct passwd *find_user (const char *name);
|
|
|
|
struct passwd *find_user (uid_t uid);
|
|
|
|
|
|
|
|
void init_grp ();
|
2014-03-08 04:38:48 +08:00
|
|
|
bool is_group () const { return pwdgrp_buf_elem_size == sizeof (pg_grp); }
|
2014-02-10 03:44:56 +08:00
|
|
|
pg_grp *group () const { return (pg_grp *) pwdgrp_buf; };
|
2014-03-13 01:36:56 +08:00
|
|
|
struct group *add_group_from_cygserver (cygpsid &sid)
|
|
|
|
{ return (struct group *) add_account_from_cygserver (sid); }
|
|
|
|
struct group *add_group_from_cygserver (const char *name)
|
|
|
|
{ return (struct group *) add_account_from_cygserver (name); }
|
|
|
|
struct group *add_group_from_cygserver (uint32_t id)
|
|
|
|
{ return (struct group *) add_account_from_cygserver (id); }
|
2014-02-10 03:44:56 +08:00
|
|
|
struct group *add_group_from_file (cygpsid &sid)
|
|
|
|
{ return (struct group *) add_account_from_file (sid); }
|
|
|
|
struct group *add_group_from_file (const char *name)
|
|
|
|
{ return (struct group *) add_account_from_file (name); }
|
|
|
|
struct group *add_group_from_file (uint32_t id)
|
|
|
|
{ return (struct group *) add_account_from_file (id); }
|
2014-02-27 20:57:27 +08:00
|
|
|
struct group *add_group_from_windows (cygpsid &sid, cyg_ldap *pldap = NULL)
|
2014-03-08 04:38:48 +08:00
|
|
|
{ return (struct group *) add_account_from_windows (sid, pldap); }
|
2014-02-27 20:57:27 +08:00
|
|
|
struct group *add_group_from_windows (const char *name,
|
|
|
|
cyg_ldap *pldap = NULL)
|
2014-03-08 04:38:48 +08:00
|
|
|
{ return (struct group *) add_account_from_windows (name, pldap); }
|
2014-02-27 20:57:27 +08:00
|
|
|
struct group *add_group_from_windows (uint32_t id, cyg_ldap *pldap = NULL)
|
2014-03-08 04:38:48 +08:00
|
|
|
{ return (struct group *) add_account_from_windows (id, pldap); }
|
2015-02-25 04:52:57 +08:00
|
|
|
struct group *add_group_from_windows (fetch_acc_t &full_acc,
|
2015-02-24 04:51:12 +08:00
|
|
|
cyg_ldap *pldap = NULL);
|
2014-02-10 03:44:56 +08:00
|
|
|
struct group *find_group (cygpsid &sid);
|
|
|
|
struct group *find_group (const char *name);
|
|
|
|
struct group *find_group (gid_t gid);
|
|
|
|
};
|
2014-02-17 23:36:33 +08:00
|
|
|
|
|
|
|
class pg_ent
|
|
|
|
{
|
|
|
|
protected:
|
2015-02-25 04:52:57 +08:00
|
|
|
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; /* ENUM_xxx values defined in sys/cygwin.h. */
|
|
|
|
PCWSTR enum_tdoms;
|
|
|
|
bool from_files;
|
|
|
|
bool from_db;
|
|
|
|
UNICODE_STRING dom;
|
2014-02-17 23:36:33 +08:00
|
|
|
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); }
|
|
|
|
};
|
2015-03-19 00:15:27 +08:00
|
|
|
|
|
|
|
/* These inline methods have to be defined here so that pg_pwd and pg_grp
|
|
|
|
are defined. */
|
|
|
|
inline BOOL cygsid::getfrompw (const struct passwd *pw)
|
|
|
|
{ return (*this = pw ? (PSID) ((pg_pwd *) pw)->sid : NO_SID) != NO_SID; }
|
|
|
|
|
|
|
|
inline BOOL cygsid::getfromgr (const struct group *gr)
|
|
|
|
{ return (*this = gr ? (PSID) ((pg_grp *) gr)->sid : NO_SID) != NO_SID; }
|
2015-04-08 17:00:08 +08:00
|
|
|
|
|
|
|
/* Use these functions if you just need the PSID. */
|
|
|
|
inline PSID sidfromuid (uid_t uid, cyg_ldap *pldap)
|
|
|
|
{
|
|
|
|
struct passwd *pw = internal_getpwuid (uid, pldap);
|
|
|
|
if (pw)
|
|
|
|
return (PSID) ((pg_pwd *) pw)->sid;
|
|
|
|
return NO_SID;
|
|
|
|
}
|
|
|
|
inline PSID sidfromgid (gid_t gid, cyg_ldap *pldap)
|
|
|
|
{
|
|
|
|
struct group *gr = internal_getgrgid (gid, pldap);
|
|
|
|
if (gr)
|
|
|
|
return (PSID) ((pg_grp *) gr)->sid;
|
|
|
|
return NO_SID;
|
|
|
|
}
|