2000-09-08 10:56:55 +08:00
|
|
|
/* security.h: security declarations
|
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
2014-01-24 01:02:30 +08:00
|
|
|
2011, 2012, 2013, 2014 Red Hat, Inc.
|
2000-09-08 10:56:55 +08:00
|
|
|
|
|
|
|
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. */
|
|
|
|
|
2012-07-22 06:58:20 +08:00
|
|
|
#pragma once
|
2003-09-10 10:12:26 +08:00
|
|
|
|
2002-07-02 09:36:15 +08:00
|
|
|
#include <accctrl.h>
|
2014-02-10 03:44:56 +08:00
|
|
|
#include <dsgetdc.h>
|
2001-04-20 21:02:32 +08:00
|
|
|
|
2009-10-31 03:58:53 +08:00
|
|
|
/* Special file attribute set, for instance, in open() and mkdir() to
|
|
|
|
flag that a file has just been created. Used in alloc_sd, see there. */
|
|
|
|
#define S_JUSTCREATED 0x80000000
|
|
|
|
|
2014-02-10 03:44:56 +08:00
|
|
|
/* UID/GID */
|
|
|
|
void uinfo_init ();
|
|
|
|
|
|
|
|
#define ILLEGAL_UID ((uid_t)-1)
|
|
|
|
#define ILLEGAL_GID ((gid_t)-1)
|
|
|
|
|
|
|
|
/* For UNIX accounts not mapped to Windows accounts via winbind, Samba returns
|
|
|
|
SIDs of the form S-1-22-x-y, with x == 1 for users and x == 2 for groups,
|
|
|
|
and y == UNIX uid/gid. NFS returns no SIDs at all, but the plain UNIX
|
|
|
|
uid/gid values.
|
|
|
|
|
|
|
|
UNIX uid/gid values are mapped to Cygwin uid/gid values 0xff000000 +
|
|
|
|
unix uid/gid. This *might* collide with a posix_offset of some trusted
|
|
|
|
domain, but it's *very* unlikely. Define the mapping as macro. */
|
|
|
|
#define UNIX_POSIX_OFFSET (0xff000000)
|
|
|
|
#define UNIX_POSIX_MASK (0x00ffffff)
|
|
|
|
#define MAP_UNIX_TO_CYGWIN_ID(id) (UNIX_POSIX_OFFSET \
|
|
|
|
| ((id) & UNIX_POSIX_MASK))
|
|
|
|
|
|
|
|
#ifndef __x86_64__
|
|
|
|
#define ILLEGAL_UID16 ((__uid16_t)-1)
|
|
|
|
#define ILLEGAL_GID16 ((__gid16_t)-1)
|
|
|
|
#define uid16touid32(u16) ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(uid_t)(u16))
|
|
|
|
#define gid16togid32(g16) ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(gid_t)(g16))
|
|
|
|
#endif
|
|
|
|
|
2001-05-01 02:21:48 +08:00
|
|
|
|
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
2001-05-16 03:23:31 +08:00
|
|
|
#define MAX_SID_LEN 40
|
2002-05-13 20:10:49 +08:00
|
|
|
#define MAX_DACL_LEN(n) (sizeof (ACL) \
|
|
|
|
+ (n) * (sizeof (ACCESS_ALLOWED_ACE) - sizeof (DWORD) + MAX_SID_LEN))
|
2008-04-19 04:13:37 +08:00
|
|
|
#define SD_MIN_SIZE (sizeof (SECURITY_DESCRIPTOR) + MAX_DACL_LEN (1))
|
2010-09-10 22:53:44 +08:00
|
|
|
#define ACL_MAXIMUM_SIZE 65532 /* Yeah, right. 64K - sizeof (DWORD). */
|
|
|
|
#define SD_MAXIMUM_SIZE 65536
|
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
2001-05-16 03:23:31 +08:00
|
|
|
#define NO_SID ((PSID)NULL)
|
|
|
|
|
2007-07-19 16:33:22 +08:00
|
|
|
#ifndef SE_CREATE_TOKEN_PRIVILEGE
|
2013-04-24 18:16:13 +08:00
|
|
|
#define SE_CREATE_TOKEN_PRIVILEGE 2U
|
|
|
|
#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3U
|
|
|
|
#define SE_LOCK_MEMORY_PRIVILEGE 4U
|
|
|
|
#define SE_INCREASE_QUOTA_PRIVILEGE 5U
|
|
|
|
#define SE_MACHINE_ACCOUNT_PRIVILEGE 6U
|
|
|
|
#define SE_TCB_PRIVILEGE 7U
|
|
|
|
#define SE_SECURITY_PRIVILEGE 8U
|
|
|
|
#define SE_TAKE_OWNERSHIP_PRIVILEGE 9U
|
|
|
|
#define SE_LOAD_DRIVER_PRIVILEGE 10U
|
|
|
|
#define SE_SYSTEM_PROFILE_PRIVILEGE 11U
|
|
|
|
#define SE_SYSTEMTIME_PRIVILEGE 12U
|
|
|
|
#define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13U
|
|
|
|
#define SE_INC_BASE_PRIORITY_PRIVILEGE 14U
|
|
|
|
#define SE_CREATE_PAGEFILE_PRIVILEGE 15U
|
|
|
|
#define SE_CREATE_PERMANENT_PRIVILEGE 16U
|
|
|
|
#define SE_BACKUP_PRIVILEGE 17U
|
|
|
|
#define SE_RESTORE_PRIVILEGE 18U
|
|
|
|
#define SE_SHUTDOWN_PRIVILEGE 19U
|
|
|
|
#define SE_DEBUG_PRIVILEGE 20U
|
|
|
|
#define SE_AUDIT_PRIVILEGE 21U
|
|
|
|
#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22U
|
|
|
|
#define SE_CHANGE_NOTIFY_PRIVILEGE 23U
|
|
|
|
#define SE_REMOTE_SHUTDOWN_PRIVILEGE 24U
|
|
|
|
#define SE_UNDOCK_PRIVILEGE 25U
|
|
|
|
#define SE_SYNC_AGENT_PRIVILEGE 26U
|
|
|
|
#define SE_ENABLE_DELEGATION_PRIVILEGE 27U
|
|
|
|
#define SE_MANAGE_VOLUME_PRIVILEGE 28U
|
|
|
|
#define SE_IMPERSONATE_PRIVILEGE 29U
|
|
|
|
#define SE_CREATE_GLOBAL_PRIVILEGE 30U
|
2007-07-19 16:33:22 +08:00
|
|
|
/* Starting with Vista */
|
2013-04-24 18:16:13 +08:00
|
|
|
#define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31U
|
|
|
|
#define SE_RELABEL_PRIVILEGE 32U
|
|
|
|
#define SE_INCREASE_WORKING_SET_PRIVILEGE 33U
|
|
|
|
#define SE_TIME_ZONE_PRIVILEGE 34U
|
|
|
|
#define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35U
|
2007-07-19 16:33:22 +08:00
|
|
|
|
|
|
|
#define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE
|
|
|
|
|
|
|
|
#endif /* ! SE_CREATE_TOKEN_PRIVILEGE */
|
|
|
|
|
2006-11-24 00:44:55 +08:00
|
|
|
/* Added for debugging purposes. */
|
|
|
|
typedef struct {
|
|
|
|
BYTE Revision;
|
|
|
|
BYTE SubAuthorityCount;
|
|
|
|
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
|
|
|
|
DWORD SubAuthority[8];
|
|
|
|
} DBGSID, *PDBGSID;
|
|
|
|
|
2004-02-06 01:23:19 +08:00
|
|
|
/* Macro to define variable length SID structures */
|
2006-11-24 00:44:55 +08:00
|
|
|
#define MKSID(name, comment, authority, count, rid...) \
|
2004-02-06 01:23:19 +08:00
|
|
|
static NO_COPY struct { \
|
|
|
|
BYTE Revision; \
|
|
|
|
BYTE SubAuthorityCount; \
|
|
|
|
SID_IDENTIFIER_AUTHORITY IdentifierAuthority; \
|
|
|
|
DWORD SubAuthority[count]; \
|
|
|
|
} name##_struct = { SID_REVISION, count, {authority}, {rid}}; \
|
|
|
|
cygpsid NO_COPY name = (PSID) &name##_struct;
|
|
|
|
|
2003-11-26 18:52:21 +08:00
|
|
|
#define FILE_READ_BITS (FILE_READ_DATA | GENERIC_READ | GENERIC_ALL)
|
|
|
|
#define FILE_WRITE_BITS (FILE_WRITE_DATA | GENERIC_WRITE | GENERIC_ALL)
|
|
|
|
#define FILE_EXEC_BITS (FILE_EXECUTE | GENERIC_EXECUTE | GENERIC_ALL)
|
|
|
|
|
2014-02-10 03:44:56 +08:00
|
|
|
/* Convenience macros. The Windows SID access functions are crude. */
|
|
|
|
#define sid_id_auth(s) \
|
|
|
|
(RtlIdentifierAuthoritySid (s)->Value[5])
|
|
|
|
#define sid_sub_auth_count(s) \
|
|
|
|
(*RtlSubAuthorityCountSid ((s)))
|
|
|
|
#define sid_sub_auth(s,i) \
|
|
|
|
(*RtlSubAuthoritySid ((s),(i)))
|
|
|
|
#define sid_sub_auth_rid(s) \
|
|
|
|
(*RtlSubAuthoritySid ((s), (*RtlSubAuthorityCountSid ((s)) - 1)))
|
|
|
|
|
2011-04-29 18:38:12 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
/* We need these declarations, otherwise g++ complains that the below
|
|
|
|
inline methods use an undefined function, if ntdll.h isn't included. */
|
|
|
|
BOOLEAN NTAPI RtlEqualSid (PSID, PSID);
|
|
|
|
NTSTATUS NTAPI RtlCopySid (ULONG, PSID, PSID);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-27 20:57:27 +08:00
|
|
|
class cyg_ldap;
|
|
|
|
|
2003-02-04 22:58:04 +08:00
|
|
|
class cygpsid {
|
|
|
|
protected:
|
2001-04-25 17:43:25 +08:00
|
|
|
PSID psid;
|
2003-02-04 22:58:04 +08:00
|
|
|
public:
|
|
|
|
cygpsid () {}
|
|
|
|
cygpsid (PSID nsid) { psid = nsid; }
|
2006-10-22 22:57:43 +08:00
|
|
|
operator PSID () const { return psid; }
|
2003-02-04 22:58:04 +08:00
|
|
|
const PSID operator= (PSID nsid) { return psid = nsid;}
|
2014-02-27 20:57:27 +08:00
|
|
|
uid_t get_id (BOOL search_grp, int *type, cyg_ldap *pldap);
|
|
|
|
int get_uid (cyg_ldap *pldap) { return get_id (FALSE, NULL, pldap); }
|
|
|
|
int get_gid (cyg_ldap *pldap) { return get_id (TRUE, NULL, pldap); }
|
2003-02-04 22:58:04 +08:00
|
|
|
|
2014-02-10 03:44:56 +08:00
|
|
|
PWCHAR pstring (PWCHAR nsidstr) const;
|
2008-02-15 00:47:11 +08:00
|
|
|
PWCHAR string (PWCHAR nsidstr) const;
|
2014-02-10 03:44:56 +08:00
|
|
|
char *pstring (char *nsidstr) const;
|
2003-02-04 22:58:04 +08:00
|
|
|
char *string (char *nsidstr) const;
|
|
|
|
|
|
|
|
bool operator== (const PSID nsid) const
|
|
|
|
{
|
|
|
|
if (!psid || !nsid)
|
|
|
|
return nsid == psid;
|
2011-04-29 18:38:12 +08:00
|
|
|
return RtlEqualSid (psid, nsid);
|
2003-02-04 22:58:04 +08:00
|
|
|
}
|
|
|
|
bool operator!= (const PSID nsid) const
|
|
|
|
{ return !(*this == nsid); }
|
|
|
|
bool operator== (const char *nsidstr) const;
|
|
|
|
bool operator!= (const char *nsidstr) const
|
|
|
|
{ return !(*this == nsidstr); }
|
|
|
|
|
|
|
|
void debug_print (const char *prefix = NULL) const
|
|
|
|
{
|
2003-10-26 18:58:11 +08:00
|
|
|
char buf[256] __attribute__ ((unused));
|
2003-02-04 22:58:04 +08:00
|
|
|
debug_printf ("%s %s", prefix ?: "", string (buf) ?: "NULL");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class cygsid : public cygpsid {
|
2001-04-25 17:43:25 +08:00
|
|
|
char sbuf[MAX_SID_LEN];
|
2006-11-27 20:59:59 +08:00
|
|
|
bool well_known_sid;
|
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
2001-05-16 03:23:31 +08:00
|
|
|
|
2014-02-10 03:44:56 +08:00
|
|
|
const PSID getfromstr (PCWSTR nsidstr, bool well_known);
|
2006-11-27 20:59:59 +08:00
|
|
|
const PSID getfromstr (const char *nsidstr, bool well_known);
|
|
|
|
PSID get_sid (DWORD s, DWORD cnt, DWORD *r, bool well_known);
|
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
2001-05-16 03:23:31 +08:00
|
|
|
|
2006-11-27 20:59:59 +08:00
|
|
|
inline const PSID assign (const PSID nsid, bool well_known)
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
{
|
|
|
|
if (!nsid)
|
2001-09-08 05:32:07 +08:00
|
|
|
psid = NO_SID;
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
else
|
2001-09-08 05:32:07 +08:00
|
|
|
{
|
|
|
|
psid = (PSID) sbuf;
|
2011-04-29 18:38:12 +08:00
|
|
|
RtlCopySid (MAX_SID_LEN, psid, nsid);
|
2006-11-27 20:59:59 +08:00
|
|
|
well_known_sid = well_known;
|
2001-09-08 05:32:07 +08:00
|
|
|
}
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
return psid;
|
|
|
|
}
|
|
|
|
|
2001-04-25 17:43:25 +08:00
|
|
|
public:
|
2001-11-03 11:32:27 +08:00
|
|
|
inline operator const PSID () { return psid; }
|
2006-11-27 20:59:59 +08:00
|
|
|
inline bool is_well_known_sid () { return well_known_sid; }
|
2001-11-03 11:32:27 +08:00
|
|
|
|
2006-11-27 20:59:59 +08:00
|
|
|
/* Both, = and *= are assignment operators. = creates a "normal" SID,
|
|
|
|
*= marks the SID as being a well-known SID. This difference is
|
|
|
|
important when creating a SID list for LSA authentication. */
|
2001-11-03 11:32:27 +08:00
|
|
|
inline const PSID operator= (cygsid &nsid)
|
2006-11-27 20:59:59 +08:00
|
|
|
{ return assign (nsid, nsid.well_known_sid); }
|
2001-11-03 11:32:27 +08:00
|
|
|
inline const PSID operator= (const PSID nsid)
|
2006-11-27 20:59:59 +08:00
|
|
|
{ return assign (nsid, false); }
|
2014-02-10 03:44:56 +08:00
|
|
|
inline const PSID operator= (PCWSTR nsidstr)
|
|
|
|
{ return getfromstr (nsidstr, false); }
|
2001-11-03 11:32:27 +08:00
|
|
|
inline const PSID operator= (const char *nsidstr)
|
2006-11-27 20:59:59 +08:00
|
|
|
{ return getfromstr (nsidstr, false); }
|
|
|
|
inline const PSID operator*= (cygsid &nsid)
|
|
|
|
{ return assign (nsid, true); }
|
|
|
|
inline const PSID operator*= (const PSID nsid)
|
|
|
|
{ return assign (nsid, true); }
|
2014-02-10 03:44:56 +08:00
|
|
|
inline const PSID operator*= (PCWSTR nsidstr)
|
|
|
|
{ return getfromstr (nsidstr, true); }
|
2006-11-27 20:59:59 +08:00
|
|
|
inline const PSID operator*= (const char *nsidstr)
|
|
|
|
{ return getfromstr (nsidstr, true); }
|
|
|
|
|
|
|
|
inline cygsid () : cygpsid ((PSID) sbuf), well_known_sid (false) {}
|
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
2001-05-16 03:23:31 +08:00
|
|
|
inline cygsid (const PSID nsid) { *this = nsid; }
|
|
|
|
inline cygsid (const char *nstrsid) { *this = nstrsid; }
|
2014-02-17 00:02:18 +08:00
|
|
|
inline cygsid (cygsid &nsid) { *this = nsid; }
|
2001-04-25 17:43:25 +08:00
|
|
|
|
|
|
|
inline PSID set () { return psid = (PSID) sbuf; }
|
|
|
|
|
2001-05-30 04:43:40 +08:00
|
|
|
BOOL getfrompw (const struct passwd *pw);
|
2013-04-23 17:44:36 +08:00
|
|
|
BOOL getfromgr (const struct group *gr);
|
2006-11-27 20:59:59 +08:00
|
|
|
|
|
|
|
void debug_print (const char *prefix = NULL) const
|
|
|
|
{
|
|
|
|
char buf[256] __attribute__ ((unused));
|
|
|
|
debug_printf ("%s %s%s", prefix ?: "", string (buf) ?: "NULL", well_known_sid ? " (*)" : " (+)");
|
|
|
|
}
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
};
|
|
|
|
|
2002-09-11 18:37:11 +08:00
|
|
|
typedef enum { cygsidlist_empty, cygsidlist_alloc, cygsidlist_auto } cygsidlist_type;
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
class cygsidlist {
|
2006-11-27 20:59:59 +08:00
|
|
|
int maxcnt;
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
BOOL add (const PSID nsi, bool well_known); /* Only with auto for now */
|
|
|
|
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
public:
|
|
|
|
cygsid *sids;
|
2002-07-29 20:51:52 +08:00
|
|
|
cygsidlist_type type;
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
|
2002-07-29 20:51:52 +08:00
|
|
|
cygsidlist (cygsidlist_type t, int m)
|
2006-11-27 20:59:59 +08:00
|
|
|
: maxcnt (m), cnt (0), type (t)
|
2002-07-29 20:51:52 +08:00
|
|
|
{
|
|
|
|
if (t == cygsidlist_alloc)
|
|
|
|
sids = alloc_sids (m);
|
|
|
|
else
|
|
|
|
sids = new cygsid [m];
|
|
|
|
}
|
|
|
|
~cygsidlist () { if (type == cygsidlist_auto) delete [] sids; }
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
BOOL addfromgr (struct group *gr) /* Only with alloc */
|
2006-11-27 20:59:59 +08:00
|
|
|
{ return sids[cnt].getfromgr (gr) && ++cnt; }
|
|
|
|
|
|
|
|
/* += adds a "normal" SID, *= adds a well-known SID. See comment in class
|
|
|
|
cygsid above. */
|
2012-05-29 21:01:50 +08:00
|
|
|
BOOL operator+= (cygsid &si) { return add ((PSID) si,
|
|
|
|
si.is_well_known_sid ()); }
|
2006-11-27 20:59:59 +08:00
|
|
|
BOOL operator+= (const char *sidstr) { cygsid nsi (sidstr);
|
2012-05-29 21:01:50 +08:00
|
|
|
return add ((PSID) nsi,
|
|
|
|
nsi.is_well_known_sid ());
|
|
|
|
}
|
2006-11-27 20:59:59 +08:00
|
|
|
BOOL operator+= (const PSID psid) { return add (psid, false); }
|
|
|
|
BOOL operator*= (cygsid &si) { return add ((PSID) si, true); }
|
|
|
|
BOOL operator*= (const char *sidstr) { cygsid nsi (sidstr);
|
2008-02-16 01:53:11 +08:00
|
|
|
return add ((PSID) nsi, true); }
|
2006-11-27 20:59:59 +08:00
|
|
|
BOOL operator*= (const PSID psid) { return add (psid, true); }
|
|
|
|
|
|
|
|
void count (int ncnt)
|
|
|
|
{ cnt = ncnt; }
|
|
|
|
int count () const { return cnt; }
|
|
|
|
int non_well_known_count () const
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
{
|
2006-11-27 20:59:59 +08:00
|
|
|
int wcnt = 0;
|
|
|
|
for (int i = 0; i < cnt; ++i)
|
2008-02-16 01:53:11 +08:00
|
|
|
if (!sids[i].is_well_known_sid ())
|
2006-11-27 20:59:59 +08:00
|
|
|
++wcnt;
|
|
|
|
return wcnt;
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
}
|
|
|
|
|
2002-07-29 20:51:52 +08:00
|
|
|
int position (const PSID sid) const
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
{
|
2006-11-27 20:59:59 +08:00
|
|
|
for (int i = 0; i < cnt; ++i)
|
2001-09-08 05:32:07 +08:00
|
|
|
if (sids[i] == sid)
|
2002-07-29 20:51:52 +08:00
|
|
|
return i;
|
|
|
|
return -1;
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
}
|
2002-07-29 20:51:52 +08:00
|
|
|
|
2006-11-27 20:59:59 +08:00
|
|
|
int next_non_well_known_sid (int idx)
|
|
|
|
{
|
|
|
|
while (++idx < cnt)
|
2008-02-16 01:53:11 +08:00
|
|
|
if (!sids[idx].is_well_known_sid ())
|
2006-11-27 20:59:59 +08:00
|
|
|
return idx;
|
|
|
|
return -1;
|
|
|
|
}
|
2002-07-29 20:51:52 +08:00
|
|
|
BOOL contains (const PSID sid) const { return position (sid) >= 0; }
|
|
|
|
cygsid *alloc_sids (int n);
|
|
|
|
void free_sids ();
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
void debug_print (const char *prefix = NULL) const
|
|
|
|
{
|
|
|
|
debug_printf ("-- begin sidlist ---");
|
2006-11-27 20:59:59 +08:00
|
|
|
if (!cnt)
|
2001-09-08 05:32:07 +08:00
|
|
|
debug_printf ("No elements");
|
2006-11-27 20:59:59 +08:00
|
|
|
for (int i = 0; i < cnt; ++i)
|
2001-09-08 05:32:07 +08:00
|
|
|
sids[i].debug_print (prefix);
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
debug_printf ("-- ende sidlist ---");
|
|
|
|
}
|
2001-04-25 17:43:25 +08:00
|
|
|
};
|
|
|
|
|
2003-11-26 21:23:27 +08:00
|
|
|
/* Wrapper class to allow simple deleting of buffer space allocated
|
|
|
|
by read_sd() */
|
|
|
|
class security_descriptor {
|
|
|
|
protected:
|
|
|
|
PSECURITY_DESCRIPTOR psd;
|
|
|
|
DWORD sd_size;
|
|
|
|
public:
|
2006-12-21 01:14:23 +08:00
|
|
|
security_descriptor () : psd (NULL), sd_size (0) {}
|
2003-11-26 21:23:27 +08:00
|
|
|
~security_descriptor () { free (); }
|
|
|
|
|
|
|
|
PSECURITY_DESCRIPTOR malloc (size_t nsize);
|
|
|
|
PSECURITY_DESCRIPTOR realloc (size_t nsize);
|
2005-07-05 11:16:46 +08:00
|
|
|
void free ();
|
2003-11-26 21:23:27 +08:00
|
|
|
|
2006-12-21 01:14:23 +08:00
|
|
|
inline DWORD size () const { return sd_size; }
|
|
|
|
inline DWORD copy (void *buf, DWORD buf_size) const {
|
2006-10-22 22:57:43 +08:00
|
|
|
if (buf_size < size ())
|
|
|
|
return sd_size;
|
|
|
|
memcpy (buf, psd, sd_size);
|
|
|
|
return 0;
|
|
|
|
}
|
2003-11-26 21:23:27 +08:00
|
|
|
inline operator const PSECURITY_DESCRIPTOR () { return psd; }
|
2006-10-22 22:57:43 +08:00
|
|
|
inline operator PSECURITY_DESCRIPTOR *() { return &psd; }
|
2009-10-31 03:58:53 +08:00
|
|
|
inline void operator =(PSECURITY_DESCRIPTOR nsd) { psd = nsd; }
|
2003-11-26 21:23:27 +08:00
|
|
|
};
|
|
|
|
|
2002-07-29 20:51:52 +08:00
|
|
|
class user_groups {
|
|
|
|
public:
|
|
|
|
cygsid pgsid;
|
|
|
|
cygsidlist sgsids;
|
|
|
|
BOOL ischanged;
|
|
|
|
|
|
|
|
BOOL issetgroups () const { return (sgsids.type == cygsidlist_alloc); }
|
|
|
|
void update_supp (const cygsidlist &newsids)
|
|
|
|
{
|
|
|
|
sgsids.free_sids ();
|
|
|
|
sgsids = newsids;
|
|
|
|
ischanged = TRUE;
|
|
|
|
}
|
2002-09-11 18:37:11 +08:00
|
|
|
void clear_supp ()
|
|
|
|
{
|
2003-02-04 22:58:04 +08:00
|
|
|
if (issetgroups ())
|
2003-03-10 04:31:07 +08:00
|
|
|
{
|
2003-02-04 22:58:04 +08:00
|
|
|
sgsids.free_sids ();
|
|
|
|
ischanged = TRUE;
|
|
|
|
}
|
2002-09-11 18:37:11 +08:00
|
|
|
}
|
2002-07-29 20:51:52 +08:00
|
|
|
void update_pgrp (const PSID sid)
|
|
|
|
{
|
|
|
|
pgsid = sid;
|
|
|
|
ischanged = TRUE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2004-02-06 01:23:19 +08:00
|
|
|
extern cygpsid well_known_null_sid;
|
|
|
|
extern cygpsid well_known_world_sid;
|
|
|
|
extern cygpsid well_known_local_sid;
|
2011-10-16 00:31:57 +08:00
|
|
|
extern cygpsid well_known_console_logon_sid;
|
2004-02-06 01:23:19 +08:00
|
|
|
extern cygpsid well_known_creator_owner_sid;
|
|
|
|
extern cygpsid well_known_creator_group_sid;
|
|
|
|
extern cygpsid well_known_dialup_sid;
|
|
|
|
extern cygpsid well_known_network_sid;
|
|
|
|
extern cygpsid well_known_batch_sid;
|
|
|
|
extern cygpsid well_known_interactive_sid;
|
|
|
|
extern cygpsid well_known_service_sid;
|
|
|
|
extern cygpsid well_known_authenticated_users_sid;
|
2006-11-08 19:38:05 +08:00
|
|
|
extern cygpsid well_known_this_org_sid;
|
2004-02-06 01:23:19 +08:00
|
|
|
extern cygpsid well_known_system_sid;
|
2010-02-13 01:40:42 +08:00
|
|
|
extern cygpsid well_known_builtin_sid;
|
2004-02-06 01:23:19 +08:00
|
|
|
extern cygpsid well_known_admins_sid;
|
2010-01-08 23:55:27 +08:00
|
|
|
extern cygpsid well_known_users_sid;
|
2008-04-22 18:45:34 +08:00
|
|
|
extern cygpsid mandatory_medium_integrity_sid;
|
|
|
|
extern cygpsid mandatory_high_integrity_sid;
|
|
|
|
extern cygpsid mandatory_system_integrity_sid;
|
2009-04-09 17:19:03 +08:00
|
|
|
extern cygpsid well_known_samba_unix_user_fake_sid;
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
|
2011-10-16 00:31:57 +08:00
|
|
|
bool privilege_luid (const PWCHAR pname, LUID &luid, bool &high_integrity);
|
2005-04-03 21:06:43 +08:00
|
|
|
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline BOOL
|
2011-04-04 17:00:02 +08:00
|
|
|
well_known_sid_type (SID_NAME_USE type)
|
|
|
|
{
|
|
|
|
return type == SidTypeAlias || type == SidTypeWellKnownGroup;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline BOOL
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
legal_sid_type (SID_NAME_USE type)
|
|
|
|
{
|
|
|
|
return type == SidTypeUser || type == SidTypeGroup
|
|
|
|
|| type == SidTypeAlias || type == SidTypeWellKnownGroup;
|
|
|
|
}
|
* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions
moved to methods into class cygsid.
(class cygsid): Declare new methods `getfromstr', `get_sid',
`getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
and new constructors and operators =, == and !=.
Declare new global cygsids `well_known_XXX_sid' substituting the
corresponding `get_XXX_sid' functions. Remove declarations of
these functions.
* sec_helper.cc (well_known_admin_sid): New global variable.
(well_known_system_sid): Ditto
(well_known_creator_owner_sid): Ditto
(well_known_world_sid): Ditto
(cygsid::string): New method, substituting `convert_sid_to_string_sid'.
(cygsid::get_sid): New method, substituting `get_sid'.
(cygsid::getfromstr): New method, substituting
`convert_string_sid_to_sid'.
(cygsid::getfrompw): New method, substituting `get_pw_sid'.
(cygsid::getfromgr): New method, substituting `get_gr_sid'.
(cygsid::get_id): New method, substituting `get_id_from_sid'.
(get_admin_sid): Eliminated.
(get_system_sid): Ditto.
(get_creator_owner_sid): Ditto.
(get_world_sid): Ditto.
* grp.cc: Use new cygsid methods and well known sids throughout.
* registry.cc: Ditto.
* sec_acl.cc: Ditto.
* security.cc: Ditto.
* shared.cc: Ditto.
* syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
* uinfo.cc (internal_getlogin): Ditto.
* spawn.cc (spawn_guts) Revert previous patch.
2001-05-16 03:23:31 +08:00
|
|
|
|
2009-01-03 13:12:22 +08:00
|
|
|
class path_conv;
|
2000-09-08 10:56:55 +08:00
|
|
|
/* File manipulation */
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg3 get_file_attribute (HANDLE, path_conv &, mode_t *,
|
2013-04-23 17:44:36 +08:00
|
|
|
uid_t *, gid_t *);
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg3 set_file_attribute (HANDLE, path_conv &,
|
2013-04-23 17:44:36 +08:00
|
|
|
uid_t, gid_t, mode_t);
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg2 get_object_sd (HANDLE, security_descriptor &);
|
2013-04-23 17:44:36 +08:00
|
|
|
int __reg3 get_object_attribute (HANDLE, uid_t *, gid_t *, mode_t *);
|
|
|
|
int __reg3 set_object_attribute (HANDLE, uid_t, gid_t, mode_t);
|
|
|
|
int __reg3 create_object_sd_from_attribute (HANDLE, uid_t, gid_t,
|
2013-01-21 12:34:52 +08:00
|
|
|
mode_t, security_descriptor &);
|
|
|
|
int __reg3 set_object_sd (HANDLE, security_descriptor &, bool);
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
int __reg3 get_reg_attribute (HKEY hkey, mode_t *, uid_t *, gid_t *);
|
2013-01-21 12:34:52 +08:00
|
|
|
LONG __reg3 get_file_sd (HANDLE fh, path_conv &, security_descriptor &, bool);
|
|
|
|
LONG __reg3 set_file_sd (HANDLE fh, path_conv &, security_descriptor &, bool);
|
|
|
|
bool __reg3 add_access_allowed_ace (PACL, int, DWORD, PSID, size_t &, DWORD);
|
|
|
|
bool __reg3 add_access_denied_ace (PACL, int, DWORD, PSID, size_t &, DWORD);
|
|
|
|
int __reg3 check_file_access (path_conv &, int, bool);
|
|
|
|
int __reg3 check_registry_access (HANDLE, int, bool);
|
2001-04-20 21:02:32 +08:00
|
|
|
|
2008-08-14 22:05:04 +08:00
|
|
|
void set_security_attribute (path_conv &pc, int attribute,
|
|
|
|
PSECURITY_ATTRIBUTES psa,
|
2003-11-26 21:23:27 +08:00
|
|
|
security_descriptor &sd_buf);
|
2001-08-07 23:09:54 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
bool get_sids_info (cygpsid, cygpsid, uid_t * , gid_t *);
|
2003-02-04 22:58:04 +08:00
|
|
|
|
2004-04-15 00:36:26 +08:00
|
|
|
/* sec_acl.cc */
|
2013-04-23 17:44:36 +08:00
|
|
|
struct acl;
|
|
|
|
extern "C" int aclsort32 (int, int, struct acl *);
|
|
|
|
extern "C" int acl32 (const char *, int, int, struct acl *);
|
|
|
|
int getacl (HANDLE, path_conv &, int, struct acl *);
|
|
|
|
int setacl (HANDLE, path_conv &, int, struct acl *, bool &);
|
2004-04-15 00:36:26 +08:00
|
|
|
|
2009-10-13 18:23:31 +08:00
|
|
|
/* Set impersonation or restricted token. */
|
|
|
|
void set_imp_token (HANDLE token, int type);
|
2006-11-27 20:59:59 +08:00
|
|
|
/* Function creating a token by calling NtCreateToken. */
|
2006-12-13 03:18:56 +08:00
|
|
|
HANDLE create_token (cygsid &usersid, user_groups &groups, struct passwd * pw);
|
2006-11-27 20:59:59 +08:00
|
|
|
/* LSA authentication function. */
|
|
|
|
HANDLE lsaauth (cygsid &, user_groups &, struct passwd *);
|
2008-11-26 18:18:10 +08:00
|
|
|
/* LSA private key storage authentication, same as when using service logons. */
|
|
|
|
HANDLE lsaprivkeyauth (struct passwd *pw);
|
2002-05-16 17:30:48 +08:00
|
|
|
/* Verify an existing token */
|
2003-12-08 06:37:12 +08:00
|
|
|
bool verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern = NULL);
|
2005-04-16 23:21:47 +08:00
|
|
|
/* Get groups of a user */
|
|
|
|
bool get_server_groups (cygsidlist &grp_list, PSID usersid, struct passwd *pw);
|
* autoload.cc: Add load statements for `LookupAccountNameW',
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
2001-05-20 16:10:47 +08:00
|
|
|
|
|
|
|
/* Extract U-domain\user field from passwd entry. */
|
2008-07-30 20:10:20 +08:00
|
|
|
void extract_nt_dom_user (const struct passwd *pw, PWCHAR domain, PWCHAR user);
|
2002-06-04 01:04:03 +08:00
|
|
|
/* Get default logonserver for a domain. */
|
2014-02-10 03:44:56 +08:00
|
|
|
bool get_logon_server (PWCHAR domain, PWCHAR wserver, ULONG flags);
|
2001-04-20 21:02:32 +08:00
|
|
|
|
2014-01-24 01:02:30 +08:00
|
|
|
HANDLE lsa_open_policy (PWCHAR server, ACCESS_MASK access);
|
|
|
|
void lsa_close_policy (HANDLE lsa);
|
2008-11-26 18:18:10 +08:00
|
|
|
|
2001-04-20 21:02:32 +08:00
|
|
|
/* sec_helper.cc: Security helper functions. */
|
2007-07-19 16:33:22 +08:00
|
|
|
int set_privilege (HANDLE token, DWORD privilege, bool enable);
|
2005-04-03 21:06:43 +08:00
|
|
|
void set_cygwin_privileges (HANDLE token);
|
|
|
|
|
|
|
|
#define _push_thread_privilege(_priv, _val, _check) { \
|
2007-02-23 23:15:50 +08:00
|
|
|
HANDLE _dup_token = NULL; \
|
|
|
|
HANDLE _token = (cygheap->user.issetuid () && (_check)) \
|
2007-07-17 04:01:15 +08:00
|
|
|
? cygheap->user.primary_token () : hProcToken; \
|
2007-02-23 23:15:50 +08:00
|
|
|
if (!DuplicateTokenEx (_token, MAXIMUM_ALLOWED, NULL, \
|
|
|
|
SecurityImpersonation, TokenImpersonation, \
|
|
|
|
&_dup_token)) \
|
|
|
|
debug_printf ("DuplicateTokenEx: %E"); \
|
|
|
|
else if (!ImpersonateLoggedOnUser (_dup_token)) \
|
|
|
|
debug_printf ("ImpersonateLoggedOnUser: %E"); \
|
|
|
|
else \
|
2007-07-19 16:33:22 +08:00
|
|
|
set_privilege (_dup_token, (_priv), (_val));
|
2007-02-23 23:15:50 +08:00
|
|
|
|
2005-04-03 21:06:43 +08:00
|
|
|
#define push_thread_privilege(_priv, _val) _push_thread_privilege(_priv,_val,1)
|
|
|
|
#define push_self_privilege(_priv, _val) _push_thread_privilege(_priv,_val,0)
|
|
|
|
|
|
|
|
#define pop_thread_privilege() \
|
|
|
|
if (_dup_token) \
|
|
|
|
{ \
|
2007-01-24 20:14:54 +08:00
|
|
|
if (!cygheap->user.issetuid ()) \
|
2006-12-13 00:27:32 +08:00
|
|
|
RevertToSelf (); \
|
|
|
|
else \
|
2007-01-24 20:14:54 +08:00
|
|
|
cygheap->user.reimpersonate (); \
|
2005-04-03 21:06:43 +08:00
|
|
|
CloseHandle (_dup_token); \
|
|
|
|
} \
|
|
|
|
}
|
2007-02-23 23:15:50 +08:00
|
|
|
|
2005-04-03 21:06:43 +08:00
|
|
|
#define pop_self_privilege() pop_thread_privilege()
|
2000-09-08 10:56:55 +08:00
|
|
|
|
2001-04-20 21:02:32 +08:00
|
|
|
/* shared.cc: */
|
|
|
|
|
2000-09-08 10:56:55 +08:00
|
|
|
/* Various types of security attributes for use in Create* functions. */
|
|
|
|
extern SECURITY_ATTRIBUTES sec_none, sec_none_nih, sec_all, sec_all_nih;
|
2013-01-21 12:34:52 +08:00
|
|
|
extern SECURITY_ATTRIBUTES *__reg3 __sec_user (PVOID, PSID, PSID,
|
|
|
|
DWORD, BOOL);
|
2012-06-04 00:46:53 +08:00
|
|
|
|
|
|
|
extern PSECURITY_DESCRIPTOR _recycler_sd (void *buf, bool users, bool dir);
|
|
|
|
#define recycler_sd(users,dir) \
|
|
|
|
(_recycler_sd (alloca (sizeof (SECURITY_DESCRIPTOR) + MAX_DACL_LEN (3)), \
|
|
|
|
(users), \
|
|
|
|
(dir)))
|
|
|
|
|
2008-04-19 04:13:37 +08:00
|
|
|
extern PSECURITY_DESCRIPTOR _everyone_sd (void *buf, ACCESS_MASK access);
|
|
|
|
#define everyone_sd(access) (_everyone_sd (alloca (SD_MIN_SIZE), (access)))
|
|
|
|
|
2010-01-15 02:46:02 +08:00
|
|
|
#define sec_none_cloexec(f) (((f) & O_CLOEXEC ? &sec_none_nih : &sec_none))
|
|
|
|
|
2005-02-14 02:17:29 +08:00
|
|
|
extern bool sec_acl (PACL acl, bool original, bool admins, PSID sid1 = NO_SID,
|
2003-09-16 08:45:50 +08:00
|
|
|
PSID sid2 = NO_SID, DWORD access2 = 0);
|
2000-09-08 10:56:55 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
ssize_t __reg3 read_ea (HANDLE, path_conv &, const char *,
|
|
|
|
char *, size_t);
|
|
|
|
int __reg3 write_ea (HANDLE, path_conv &, const char *, const char *,
|
|
|
|
size_t, int);
|
2002-02-19 13:58:44 +08:00
|
|
|
|
2006-03-31 00:08:50 +08:00
|
|
|
/* Note: sid1 is usually (read: currently always) the current user's
|
|
|
|
effective sid (cygheap->user.sid ()). */
|
2002-02-19 13:58:44 +08:00
|
|
|
extern inline SECURITY_ATTRIBUTES *
|
2006-03-31 00:08:50 +08:00
|
|
|
sec_user_nih (SECURITY_ATTRIBUTES *sa_buf, PSID sid1, PSID sid2 = NULL,
|
2005-06-08 03:31:42 +08:00
|
|
|
DWORD access2 = 0)
|
2002-02-19 13:58:44 +08:00
|
|
|
{
|
2003-09-16 08:45:50 +08:00
|
|
|
return __sec_user (sa_buf, sid1, sid2, access2, FALSE);
|
2002-02-19 13:58:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
extern inline SECURITY_ATTRIBUTES *
|
2006-03-31 00:08:50 +08:00
|
|
|
sec_user (SECURITY_ATTRIBUTES *sa_buf, PSID sid1, PSID sid2 = NULL,
|
2005-06-08 03:31:42 +08:00
|
|
|
DWORD access2 = 0)
|
2002-02-19 13:58:44 +08:00
|
|
|
{
|
2003-09-16 08:45:50 +08:00
|
|
|
return __sec_user (sa_buf, sid1, sid2, access2, TRUE);
|
2002-02-19 13:58:44 +08:00
|
|
|
}
|