* external.cc (cygwin_internal): Add cases for CW_GETNSSSEP,
CW_GETPWSID and CW_GETGRSID. * grp.cc (internal_getgrsid_from_db): New function. * passwd.cc (internal_getpwsid_from_db): New function. (pg_ent::setent): Add special case for call from mkpasswd/mkgroup. * pwdgrp.h (internal_getpwsid_from_db): Declare. (internal_getgrsid_from_db): Declare. (enum nss_enum_t): Move to include/sys/cygwin.h. (class pg_ent): Add comment. * uinfo.cc (pwdgrp::fetch_account_from_windows): Fix typo in comment. Change "UNIX" to "Unix" in domain name. * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GETNSSSEP, CW_GETPWSID and CW_GETGRSID. (enum nss_enum_t): Define here.
This commit is contained in:
parent
98cc373860
commit
b211f4c17e
@ -1,3 +1,20 @@
|
|||||||
|
2014-02-22 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* external.cc (cygwin_internal): Add cases for CW_GETNSSSEP,
|
||||||
|
CW_GETPWSID and CW_GETGRSID.
|
||||||
|
* grp.cc (internal_getgrsid_from_db): New function.
|
||||||
|
* passwd.cc (internal_getpwsid_from_db): New function.
|
||||||
|
(pg_ent::setent): Add special case for call from mkpasswd/mkgroup.
|
||||||
|
* pwdgrp.h (internal_getpwsid_from_db): Declare.
|
||||||
|
(internal_getgrsid_from_db): Declare.
|
||||||
|
(enum nss_enum_t): Move to include/sys/cygwin.h.
|
||||||
|
(class pg_ent): Add comment.
|
||||||
|
* uinfo.cc (pwdgrp::fetch_account_from_windows): Fix typo in comment.
|
||||||
|
Change "UNIX" to "Unix" in domain name.
|
||||||
|
* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GETNSSSEP,
|
||||||
|
CW_GETPWSID and CW_GETGRSID.
|
||||||
|
(enum nss_enum_t): Define here.
|
||||||
|
|
||||||
2014-02-21 Corinna Vinschen <corinna@vinschen.de>
|
2014-02-21 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* pwdgrp.h (pwdgrp::fetch_account_from_windows): Add bool parameter
|
* pwdgrp.h (pwdgrp::fetch_account_from_windows): Add bool parameter
|
||||||
|
@ -595,6 +595,30 @@ cygwin_internal (cygwin_getinfo_types t, ...)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CW_GETNSSSEP:
|
||||||
|
res = (uintptr_t) cygheap->pg.nss_separator ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CW_GETPWSID:
|
||||||
|
{
|
||||||
|
int db_only = va_arg (arg, int);
|
||||||
|
PSID psid = va_arg (arg, PSID);
|
||||||
|
cygpsid sid (psid);
|
||||||
|
res = (uintptr_t) (db_only ? internal_getpwsid_from_db (sid)
|
||||||
|
: internal_getpwsid (sid));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CW_GETGRSID:
|
||||||
|
{
|
||||||
|
int db_only = va_arg (arg, int);
|
||||||
|
PSID psid = va_arg (arg, PSID);
|
||||||
|
cygpsid sid (psid);
|
||||||
|
res = (uintptr_t) (db_only ? internal_getgrsid_from_db (sid)
|
||||||
|
: internal_getgrsid (sid));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
set_errno (ENOSYS);
|
set_errno (ENOSYS);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,14 @@ internal_getgrsid (cygpsid &sid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function gets only called from mkgroup via cygwin_internal. */
|
||||||
|
struct group *
|
||||||
|
internal_getgrsid_from_db (cygpsid &sid)
|
||||||
|
{
|
||||||
|
cygheap->pg.nss_init ();
|
||||||
|
return cygheap->pg.grp_cache.win.add_group_from_windows (sid);
|
||||||
|
}
|
||||||
|
|
||||||
struct group *
|
struct group *
|
||||||
internal_getgrnam (const char *name)
|
internal_getgrnam (const char *name)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,10 @@ typedef enum
|
|||||||
CW_FREE_DRIVE_MAP,
|
CW_FREE_DRIVE_MAP,
|
||||||
CW_SETENT,
|
CW_SETENT,
|
||||||
CW_GETENT,
|
CW_GETENT,
|
||||||
CW_ENDENT
|
CW_ENDENT,
|
||||||
|
CW_GETNSSSEP,
|
||||||
|
CW_GETPWSID,
|
||||||
|
CW_GETGRSID
|
||||||
} cygwin_getinfo_types;
|
} cygwin_getinfo_types;
|
||||||
|
|
||||||
#define CW_LOCK_PINFO CW_LOCK_PINFO
|
#define CW_LOCK_PINFO CW_LOCK_PINFO
|
||||||
@ -200,6 +203,9 @@ typedef enum
|
|||||||
#define CW_SETENT CW_SETENT
|
#define CW_SETENT CW_SETENT
|
||||||
#define CW_GETENT CW_GETENT
|
#define CW_GETENT CW_GETENT
|
||||||
#define CW_ENDENT CW_ENDENT
|
#define CW_ENDENT CW_ENDENT
|
||||||
|
#define CW_GETNSSSEP CW_GETNSSSEP
|
||||||
|
#define CW_GETPWSID CW_GETPWSID
|
||||||
|
#define CW_GETGRSID CW_GETGRSID
|
||||||
|
|
||||||
/* Token type for CW_SET_EXTERNAL_TOKEN */
|
/* Token type for CW_SET_EXTERNAL_TOKEN */
|
||||||
enum
|
enum
|
||||||
@ -208,6 +214,20 @@ CW_TOKEN_IMPERSONATION = 0,
|
|||||||
CW_TOKEN_RESTRICTED = 1
|
CW_TOKEN_RESTRICTED = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Enumeration source constants for CW_SETENT called from mkpasswd/mkgroup. */
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
#define CW_NEXTPID 0x80000000 /* or with pid to get next one */
|
#define CW_NEXTPID 0x80000000 /* or with pid to get next one */
|
||||||
uintptr_t cygwin_internal (cygwin_getinfo_types, ...);
|
uintptr_t cygwin_internal (cygwin_getinfo_types, ...);
|
||||||
|
|
||||||
|
@ -123,6 +123,14 @@ internal_getpwsid (cygpsid &sid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function gets only called from mkpasswd via cygwin_internal. */
|
||||||
|
struct passwd *
|
||||||
|
internal_getpwsid_from_db (cygpsid &sid)
|
||||||
|
{
|
||||||
|
cygheap->pg.nss_init ();
|
||||||
|
return cygheap->pg.pwd_cache.win.add_user_from_windows (sid);
|
||||||
|
}
|
||||||
|
|
||||||
struct passwd *
|
struct passwd *
|
||||||
internal_getpwnam (const char *name)
|
internal_getpwnam (const char *name)
|
||||||
{
|
{
|
||||||
@ -300,23 +308,28 @@ pg_ent::setent (bool _group, int _enums, PCWSTR _enum_tdoms)
|
|||||||
endent (_group);
|
endent (_group);
|
||||||
if (!_enums && !_enum_tdoms)
|
if (!_enums && !_enum_tdoms)
|
||||||
{
|
{
|
||||||
|
/* This is the default, when called from the usual setpwent/setgrent
|
||||||
|
functions. */
|
||||||
enums = cygheap->pg.nss_db_enums ();
|
enums = cygheap->pg.nss_db_enums ();
|
||||||
enum_tdoms = cygheap->pg.nss_db_enum_tdoms ();
|
enum_tdoms = cygheap->pg.nss_db_enum_tdoms ();
|
||||||
|
if (_group)
|
||||||
|
{
|
||||||
|
from_files = cygheap->pg.nss_grp_files ();
|
||||||
|
from_db = cygheap->pg.nss_grp_db ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
from_files = cygheap->pg.nss_pwd_files ();
|
||||||
|
from_db = cygheap->pg.nss_pwd_db ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* This case is when called from mkpasswd/mkgroup via cygwin_internal. */
|
||||||
enums = _enums;
|
enums = _enums;
|
||||||
enum_tdoms = _enum_tdoms;
|
enum_tdoms = _enum_tdoms;
|
||||||
}
|
from_files = false;
|
||||||
if (_group)
|
from_db = true;
|
||||||
{
|
|
||||||
from_files = cygheap->pg.nss_grp_files ();
|
|
||||||
from_db = cygheap->pg.nss_grp_db ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
from_files = cygheap->pg.nss_pwd_files ();
|
|
||||||
from_db = cygheap->pg.nss_pwd_db ();
|
|
||||||
}
|
}
|
||||||
state = from_cache;
|
state = from_cache;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,11 @@ details. */
|
|||||||
/* These functions are needed to allow searching and walking through
|
/* These functions are needed to allow searching and walking through
|
||||||
the passwd and group lists */
|
the passwd and group lists */
|
||||||
extern struct passwd *internal_getpwsid (cygpsid &);
|
extern struct passwd *internal_getpwsid (cygpsid &);
|
||||||
|
extern struct passwd *internal_getpwsid_from_db (cygpsid &sid);
|
||||||
extern struct passwd *internal_getpwnam (const char *);
|
extern struct passwd *internal_getpwnam (const char *);
|
||||||
extern struct passwd *internal_getpwuid (uid_t);
|
extern struct passwd *internal_getpwuid (uid_t);
|
||||||
extern struct group *internal_getgrsid (cygpsid &);
|
extern struct group *internal_getgrsid (cygpsid &);
|
||||||
|
extern struct group *internal_getgrsid_from_db (cygpsid &sid);
|
||||||
extern struct group *internal_getgrgid (gid_t);
|
extern struct group *internal_getgrgid (gid_t);
|
||||||
extern struct group *internal_getgrnam (const char *);
|
extern struct group *internal_getgrnam (const char *);
|
||||||
int internal_getgroups (int, gid_t *, cygpsid * = NULL);
|
int internal_getgroups (int, gid_t *, cygpsid * = NULL);
|
||||||
@ -158,19 +160,6 @@ public:
|
|||||||
struct group *find_group (gid_t gid);
|
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
|
class pg_ent
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -184,7 +173,7 @@ protected:
|
|||||||
ULONG cnt;
|
ULONG cnt;
|
||||||
ULONG max;
|
ULONG max;
|
||||||
ULONG_PTR resume;
|
ULONG_PTR resume;
|
||||||
int enums;
|
int enums; /* ENUM_xxx values defined in sys/cygwin.h. */
|
||||||
PCWSTR enum_tdoms;
|
PCWSTR enum_tdoms;
|
||||||
bool from_files;
|
bool from_files;
|
||||||
bool from_db;
|
bool from_db;
|
||||||
|
@ -1720,12 +1720,12 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, bool group,
|
|||||||
{
|
{
|
||||||
/* Samba UNIX Users/Groups
|
/* Samba UNIX Users/Groups
|
||||||
|
|
||||||
This *might* colide with a posix_offset of some trusted domain.
|
This *might* collide with a posix_offset of some trusted domain.
|
||||||
It's just very unlikely. */
|
It's just very unlikely. */
|
||||||
uid = MAP_UNIX_TO_CYGWIN_ID (sid_sub_auth_rid (sid));
|
uid = MAP_UNIX_TO_CYGWIN_ID (sid_sub_auth_rid (sid));
|
||||||
/* Unfortunately we have no access to the file server from here,
|
/* Unfortunately we have no access to the file server from here,
|
||||||
so we can't generate correct user names. */
|
so we can't generate correct user names. */
|
||||||
p = wcpcpy (dom, L"UNIX_");
|
p = wcpcpy (dom, L"Unix_");
|
||||||
wcpcpy (p, sid_sub_auth (sid, 0) == 1 ? L"User" : L"Group");
|
wcpcpy (p, sid_sub_auth (sid, 0) == 1 ? L"User" : L"Group");
|
||||||
__small_swprintf (name = namebuf, L"%d", uid & UNIX_POSIX_MASK);
|
__small_swprintf (name = namebuf, L"%d", uid & UNIX_POSIX_MASK);
|
||||||
name_style = fully_qualified;
|
name_style = fully_qualified;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user