1999-01-28 14:46:25 +01:00
|
|
|
/*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 1999, 2000 Juergen Schmied <juergen.schmied@debitel.net>
|
2003-11-11 23:03:24 +01:00
|
|
|
* Copyright 2003 CodeWeavers Inc. (Ulrich Czekalla)
|
2006-08-12 14:00:34 +02:00
|
|
|
* Copyright 2006 Robert Reif
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
1999-01-28 14:46:25 +01:00
|
|
|
*/
|
2002-03-10 00:29:33 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-02-19 16:42:11 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
1997-11-30 18:45:40 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2009-01-15 07:30:11 +01:00
|
|
|
#include "winsafer.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2005-06-24 13:54:15 +02:00
|
|
|
#include "winioctl.h"
|
2002-12-19 05:15:23 +01:00
|
|
|
#include "accctrl.h"
|
2003-11-11 23:03:24 +01:00
|
|
|
#include "sddl.h"
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
#include "winsvc.h"
|
2004-08-06 19:31:17 +02:00
|
|
|
#include "aclapi.h"
|
2007-09-23 06:26:05 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "iads.h"
|
2006-07-29 14:12:58 +02:00
|
|
|
#include "advapi32_misc.h"
|
2008-10-18 22:53:24 +02:00
|
|
|
#include "lmcons.h"
|
2004-08-06 19:31:17 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-10-23 22:20:59 +02:00
|
|
|
#include "wine/unicode.h"
|
1997-02-15 15:29:56 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes);
|
|
|
|
static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
|
|
|
|
PACL pAcl, LPDWORD cBytes);
|
|
|
|
static BYTE ParseAceStringFlags(LPCWSTR* StringAcl);
|
|
|
|
static BYTE ParseAceStringType(LPCWSTR* StringAcl);
|
|
|
|
static DWORD ParseAceStringRights(LPCWSTR* StringAcl);
|
|
|
|
static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
|
|
|
|
LPCWSTR StringSecurityDescriptor,
|
2009-06-16 13:28:00 +02:00
|
|
|
SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
|
2003-11-11 23:03:24 +01:00
|
|
|
LPDWORD cBytes);
|
|
|
|
static DWORD ParseAclStringFlags(LPCWSTR* StringAcl);
|
|
|
|
|
|
|
|
typedef struct _ACEFLAG
|
|
|
|
{
|
|
|
|
LPCWSTR wstr;
|
|
|
|
DWORD value;
|
|
|
|
} ACEFLAG, *LPACEFLAG;
|
|
|
|
|
2006-07-29 02:21:49 +02:00
|
|
|
typedef struct _MAX_SID
|
2006-06-12 17:37:07 +02:00
|
|
|
{
|
2006-07-16 13:21:00 +02:00
|
|
|
/* same fields as struct _SID */
|
|
|
|
BYTE Revision;
|
|
|
|
BYTE SubAuthorityCount;
|
|
|
|
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
|
|
|
|
DWORD SubAuthority[SID_MAX_SUB_AUTHORITIES];
|
2006-07-29 02:21:49 +02:00
|
|
|
} MAX_SID;
|
|
|
|
|
|
|
|
typedef struct WELLKNOWNSID
|
|
|
|
{
|
|
|
|
WCHAR wstr[2];
|
|
|
|
WELL_KNOWN_SID_TYPE Type;
|
|
|
|
MAX_SID Sid;
|
2006-06-12 17:37:07 +02:00
|
|
|
} WELLKNOWNSID;
|
|
|
|
|
2006-07-16 13:21:00 +02:00
|
|
|
static const WELLKNOWNSID WellKnownSids[] =
|
|
|
|
{
|
2006-07-29 02:21:49 +02:00
|
|
|
{ {0,0}, WinNullSid, { SID_REVISION, 1, { SECURITY_NULL_SID_AUTHORITY }, { SECURITY_NULL_RID } } },
|
|
|
|
{ {'W','D'}, WinWorldSid, { SID_REVISION, 1, { SECURITY_WORLD_SID_AUTHORITY }, { SECURITY_WORLD_RID } } },
|
|
|
|
{ {0,0}, WinLocalSid, { SID_REVISION, 1, { SECURITY_LOCAL_SID_AUTHORITY }, { SECURITY_LOCAL_RID } } },
|
|
|
|
{ {'C','O'}, WinCreatorOwnerSid, { SID_REVISION, 1, { SECURITY_CREATOR_SID_AUTHORITY }, { SECURITY_CREATOR_OWNER_RID } } },
|
|
|
|
{ {'C','G'}, WinCreatorGroupSid, { SID_REVISION, 1, { SECURITY_CREATOR_SID_AUTHORITY }, { SECURITY_CREATOR_GROUP_RID } } },
|
|
|
|
{ {0,0}, WinCreatorOwnerServerSid, { SID_REVISION, 1, { SECURITY_CREATOR_SID_AUTHORITY }, { SECURITY_CREATOR_OWNER_SERVER_RID } } },
|
|
|
|
{ {0,0}, WinCreatorGroupServerSid, { SID_REVISION, 1, { SECURITY_CREATOR_SID_AUTHORITY }, { SECURITY_CREATOR_GROUP_SERVER_RID } } },
|
2007-03-12 13:06:31 +01:00
|
|
|
{ {0,0}, WinNtAuthoritySid, { SID_REVISION, 0, { SECURITY_NT_AUTHORITY }, { SECURITY_NULL_RID } } },
|
2006-07-29 02:21:49 +02:00
|
|
|
{ {0,0}, WinDialupSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_DIALUP_RID } } },
|
|
|
|
{ {'N','U'}, WinNetworkSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_NETWORK_RID } } },
|
|
|
|
{ {0,0}, WinBatchSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_BATCH_RID } } },
|
|
|
|
{ {'I','U'}, WinInteractiveSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_INTERACTIVE_RID } } },
|
|
|
|
{ {'S','U'}, WinServiceSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_SERVICE_RID } } },
|
|
|
|
{ {'A','N'}, WinAnonymousSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_ANONYMOUS_LOGON_RID } } },
|
|
|
|
{ {0,0}, WinProxySid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_PROXY_RID } } },
|
|
|
|
{ {'E','D'}, WinEnterpriseControllersSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_ENTERPRISE_CONTROLLERS_RID } } },
|
|
|
|
{ {'P','S'}, WinSelfSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_PRINCIPAL_SELF_RID } } },
|
|
|
|
{ {'A','U'}, WinAuthenticatedUserSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_AUTHENTICATED_USER_RID } } },
|
|
|
|
{ {'R','C'}, WinRestrictedCodeSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_RESTRICTED_CODE_RID } } },
|
|
|
|
{ {0,0}, WinTerminalServerSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_TERMINAL_SERVER_RID } } },
|
|
|
|
{ {0,0}, WinRemoteLogonIdSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_REMOTE_LOGON_RID } } },
|
|
|
|
{ {'S','Y'}, WinLocalSystemSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_LOCAL_SYSTEM_RID } } },
|
|
|
|
{ {'L','S'}, WinLocalServiceSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_LOCAL_SERVICE_RID } } },
|
|
|
|
{ {'N','S'}, WinNetworkServiceSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_NETWORK_SERVICE_RID } } },
|
|
|
|
{ {0,0}, WinBuiltinDomainSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID } } },
|
|
|
|
{ {'B','A'}, WinBuiltinAdministratorsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS } } },
|
|
|
|
{ {'B','U'}, WinBuiltinUsersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_USERS } } },
|
|
|
|
{ {'B','G'}, WinBuiltinGuestsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_GUESTS } } },
|
|
|
|
{ {'P','U'}, WinBuiltinPowerUsersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS } } },
|
|
|
|
{ {'A','O'}, WinBuiltinAccountOperatorsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ACCOUNT_OPS } } },
|
|
|
|
{ {'S','O'}, WinBuiltinSystemOperatorsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_SYSTEM_OPS } } },
|
|
|
|
{ {'P','O'}, WinBuiltinPrintOperatorsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_PRINT_OPS } } },
|
|
|
|
{ {'B','O'}, WinBuiltinBackupOperatorsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_BACKUP_OPS } } },
|
|
|
|
{ {'R','E'}, WinBuiltinReplicatorSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_REPLICATOR } } },
|
|
|
|
{ {'R','U'}, WinBuiltinPreWindows2000CompatibleAccessSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_PREW2KCOMPACCESS } } },
|
|
|
|
{ {'R','D'}, WinBuiltinRemoteDesktopUsersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS } } },
|
|
|
|
{ {'N','O'}, WinBuiltinNetworkConfigurationOperatorsSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS } } },
|
2006-08-12 05:51:21 +02:00
|
|
|
{ {0,0}, WinNTLMAuthenticationSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_PACKAGE_BASE_RID, SECURITY_PACKAGE_NTLM_RID } } },
|
|
|
|
{ {0,0}, WinDigestAuthenticationSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_PACKAGE_BASE_RID, SECURITY_PACKAGE_DIGEST_RID } } },
|
|
|
|
{ {0,0}, WinSChannelAuthenticationSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_PACKAGE_BASE_RID, SECURITY_PACKAGE_SCHANNEL_RID } } },
|
|
|
|
{ {0,0}, WinThisOrganizationSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_THIS_ORGANIZATION_RID } } },
|
|
|
|
{ {0,0}, WinOtherOrganizationSid, { SID_REVISION, 1, { SECURITY_NT_AUTHORITY }, { SECURITY_OTHER_ORGANIZATION_RID } } },
|
2007-10-21 11:01:56 +02:00
|
|
|
{ {0,0}, WinBuiltinIncomingForestTrustBuildersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS } } },
|
2006-08-12 05:51:21 +02:00
|
|
|
{ {0,0}, WinBuiltinPerfMonitoringUsersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_MONITORING_USERS } } },
|
|
|
|
{ {0,0}, WinBuiltinPerfLoggingUsersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_LOGGING_USERS } } },
|
2007-10-21 09:41:54 +02:00
|
|
|
{ {0,0}, WinBuiltinAuthorizationAccessSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_AUTHORIZATIONACCESS } } },
|
|
|
|
{ {0,0}, WinBuiltinTerminalServerLicenseServersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_TS_LICENSE_SERVERS } } },
|
2007-10-25 20:53:46 +02:00
|
|
|
{ {0,0}, WinBuiltinDCOMUsersSid, { SID_REVISION, 2, { SECURITY_NT_AUTHORITY }, { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_DCOM_USERS } } },
|
2009-02-03 19:55:14 +01:00
|
|
|
{ {'L','W'}, WinLowLabelSid, { SID_REVISION, 1, { SECURITY_MANDATORY_LABEL_AUTHORITY}, { SECURITY_MANDATORY_LOW_RID} } },
|
|
|
|
{ {'M','E'}, WinMediumLabelSid, { SID_REVISION, 1, { SECURITY_MANDATORY_LABEL_AUTHORITY}, { SECURITY_MANDATORY_MEDIUM_RID } } },
|
|
|
|
{ {'H','I'}, WinHighLabelSid, { SID_REVISION, 1, { SECURITY_MANDATORY_LABEL_AUTHORITY}, { SECURITY_MANDATORY_HIGH_RID } } },
|
|
|
|
{ {'S','I'}, WinSystemLabelSid, { SID_REVISION, 1, { SECURITY_MANDATORY_LABEL_AUTHORITY}, { SECURITY_MANDATORY_SYSTEM_RID } } },
|
2015-08-26 08:44:45 +02:00
|
|
|
{ {0,0}, WinBuiltinAnyPackageSid, { SID_REVISION, 2, { SECURITY_APP_PACKAGE_AUTHORITY }, { SECURITY_APP_PACKAGE_BASE_RID, SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE } } },
|
2006-07-16 13:21:00 +02:00
|
|
|
};
|
|
|
|
|
2007-11-09 12:37:53 +01:00
|
|
|
/* these SIDs must be constructed as relative to some domain - only the RID is well-known */
|
|
|
|
typedef struct WELLKNOWNRID
|
2007-10-21 11:01:56 +02:00
|
|
|
{
|
2012-11-13 05:31:24 +01:00
|
|
|
WCHAR wstr[2];
|
2007-10-21 11:01:56 +02:00
|
|
|
WELL_KNOWN_SID_TYPE Type;
|
|
|
|
DWORD Rid;
|
|
|
|
} WELLKNOWNRID;
|
|
|
|
|
2007-11-06 14:38:54 +01:00
|
|
|
static const WELLKNOWNRID WellKnownRids[] = {
|
2012-11-13 05:31:24 +01:00
|
|
|
{ {'L','A'}, WinAccountAdministratorSid, DOMAIN_USER_RID_ADMIN },
|
|
|
|
{ {'L','G'}, WinAccountGuestSid, DOMAIN_USER_RID_GUEST },
|
|
|
|
{ {0,0}, WinAccountKrbtgtSid, DOMAIN_USER_RID_KRBTGT },
|
2015-08-18 22:32:00 +02:00
|
|
|
{ {'D','A'}, WinAccountDomainAdminsSid, DOMAIN_GROUP_RID_ADMINS },
|
|
|
|
{ {'D','U'}, WinAccountDomainUsersSid, DOMAIN_GROUP_RID_USERS },
|
|
|
|
{ {'D','G'}, WinAccountDomainGuestsSid, DOMAIN_GROUP_RID_GUESTS },
|
|
|
|
{ {'D','C'}, WinAccountComputersSid, DOMAIN_GROUP_RID_COMPUTERS },
|
|
|
|
{ {'D','D'}, WinAccountControllersSid, DOMAIN_GROUP_RID_CONTROLLERS },
|
|
|
|
{ {'C','A'}, WinAccountCertAdminsSid, DOMAIN_GROUP_RID_CERT_ADMINS },
|
|
|
|
{ {'S','A'}, WinAccountSchemaAdminsSid, DOMAIN_GROUP_RID_SCHEMA_ADMINS },
|
|
|
|
{ {'E','A'}, WinAccountEnterpriseAdminsSid, DOMAIN_GROUP_RID_ENTERPRISE_ADMINS },
|
|
|
|
{ {'P','A'}, WinAccountPolicyAdminsSid, DOMAIN_GROUP_RID_POLICY_ADMINS },
|
|
|
|
{ {'R','S'}, WinAccountRasAndIasServersSid, DOMAIN_ALIAS_RID_RAS_SERVERS },
|
2007-10-21 11:01:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-03-05 11:46:34 +01:00
|
|
|
static SID const sidWorld = { SID_REVISION, 1, { SECURITY_WORLD_SID_AUTHORITY} , { SECURITY_WORLD_RID } };
|
|
|
|
|
2006-07-20 13:05:46 +02:00
|
|
|
typedef struct _AccountSid {
|
|
|
|
WELL_KNOWN_SID_TYPE type;
|
|
|
|
LPCWSTR account;
|
|
|
|
LPCWSTR domain;
|
|
|
|
SID_NAME_USE name_use;
|
2009-03-27 15:47:43 +01:00
|
|
|
LPCWSTR alias;
|
2006-07-20 13:05:46 +02:00
|
|
|
} AccountSid;
|
|
|
|
|
|
|
|
static const WCHAR Account_Operators[] = { 'A','c','c','o','u','n','t',' ','O','p','e','r','a','t','o','r','s',0 };
|
|
|
|
static const WCHAR Administrator[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0 };
|
|
|
|
static const WCHAR Administrators[] = { 'A','d','m','i','n','i','s','t','r','a','t','o','r','s',0 };
|
2015-08-26 08:44:45 +02:00
|
|
|
static const WCHAR ALL_APPLICATION_PACKAGES[] = { 'A','L','L',' ','A','P','P','L','I','C','A','T','I','O','N',' ','P','A','C','K','A','G','E','S',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR ANONYMOUS_LOGON[] = { 'A','N','O','N','Y','M','O','U','S',' ','L','O','G','O','N',0 };
|
2015-08-26 08:44:45 +02:00
|
|
|
static const WCHAR APPLICATION_PACKAGE_AUTHORITY[] = { 'A','P','P','L','I','C','A','T','I','O','N',' ','P','A','C','K','A','G','E',' ','A','U','T','H','O','R','I','T','Y',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR Authenticated_Users[] = { 'A','u','t','h','e','n','t','i','c','a','t','e','d',' ','U','s','e','r','s',0 };
|
|
|
|
static const WCHAR Backup_Operators[] = { 'B','a','c','k','u','p',' ','O','p','e','r','a','t','o','r','s',0 };
|
|
|
|
static const WCHAR BATCH[] = { 'B','A','T','C','H',0 };
|
|
|
|
static const WCHAR Blank[] = { 0 };
|
|
|
|
static const WCHAR BUILTIN[] = { 'B','U','I','L','T','I','N',0 };
|
2006-08-12 14:00:34 +02:00
|
|
|
static const WCHAR Cert_Publishers[] = { 'C','e','r','t',' ','P','u','b','l','i','s','h','e','r','s',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR CREATOR_GROUP[] = { 'C','R','E','A','T','O','R',' ','G','R','O','U','P',0 };
|
|
|
|
static const WCHAR CREATOR_GROUP_SERVER[] = { 'C','R','E','A','T','O','R',' ','G','R','O','U','P',' ','S','E','R','V','E','R',0 };
|
|
|
|
static const WCHAR CREATOR_OWNER[] = { 'C','R','E','A','T','O','R',' ','O','W','N','E','R',0 };
|
|
|
|
static const WCHAR CREATOR_OWNER_SERVER[] = { 'C','R','E','A','T','O','R',' ','O','W','N','E','R',' ','S','E','R','V','E','R',0 };
|
2009-08-16 12:36:56 +02:00
|
|
|
static const WCHAR CURRENT_USER[] = { 'C','U','R','R','E','N','T','_','U','S','E','R',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR DIALUP[] = { 'D','I','A','L','U','P',0 };
|
2006-08-12 05:51:21 +02:00
|
|
|
static const WCHAR Digest_Authentication[] = { 'D','i','g','e','s','t',' ','A','u','t','h','e','n','t','i','c','a','t','i','o','n',0 };
|
2006-08-12 14:00:34 +02:00
|
|
|
static const WCHAR Domain_Admins[] = { 'D','o','m','a','i','n',' ','A','d','m','i','n','s',0 };
|
|
|
|
static const WCHAR Domain_Computers[] = { 'D','o','m','a','i','n',' ','C','o','m','p','u','t','e','r','s',0 };
|
|
|
|
static const WCHAR Domain_Controllers[] = { 'D','o','m','a','i','n',' ','C','o','n','t','r','o','l','l','e','r','s',0 };
|
|
|
|
static const WCHAR Domain_Guests[] = { 'D','o','m','a','i','n',' ','G','u','e','s','t','s',0 };
|
|
|
|
static const WCHAR Domain_Users[] = { 'D','o','m','a','i','n',' ','U','s','e','r','s',0 };
|
|
|
|
static const WCHAR Enterprise_Admins[] = { 'E','n','t','e','r','p','r','i','s','e',' ','A','d','m','i','n','s',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR ENTERPRISE_DOMAIN_CONTROLLERS[] = { 'E','N','T','E','R','P','R','I','S','E',' ','D','O','M','A','I','N',' ','C','O','N','T','R','O','L','L','E','R','S',0 };
|
|
|
|
static const WCHAR Everyone[] = { 'E','v','e','r','y','o','n','e',0 };
|
2006-08-12 14:00:34 +02:00
|
|
|
static const WCHAR Group_Policy_Creator_Owners[] = { 'G','r','o','u','p',' ','P','o','l','i','c','y',' ','C','r','e','a','t','o','r',' ','O','w','n','e','r','s',0 };
|
2006-07-31 13:09:21 +02:00
|
|
|
static const WCHAR Guest[] = { 'G','u','e','s','t',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR Guests[] = { 'G','u','e','s','t','s',0 };
|
|
|
|
static const WCHAR INTERACTIVE[] = { 'I','N','T','E','R','A','C','T','I','V','E',0 };
|
|
|
|
static const WCHAR LOCAL[] = { 'L','O','C','A','L',0 };
|
|
|
|
static const WCHAR LOCAL_SERVICE[] = { 'L','O','C','A','L',' ','S','E','R','V','I','C','E',0 };
|
2009-03-27 15:47:43 +01:00
|
|
|
static const WCHAR LOCAL_SERVICE2[] = { 'L','O','C','A','L','S','E','R','V','I','C','E',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR NETWORK[] = { 'N','E','T','W','O','R','K',0 };
|
|
|
|
static const WCHAR Network_Configuration_Operators[] = { 'N','e','t','w','o','r','k',' ','C','o','n','f','i','g','u','r','a','t','i','o','n',' ','O','p','e','r','a','t','o','r','s',0 };
|
|
|
|
static const WCHAR NETWORK_SERVICE[] = { 'N','E','T','W','O','R','K',' ','S','E','R','V','I','C','E',0 };
|
2009-03-27 15:47:43 +01:00
|
|
|
static const WCHAR NETWORK_SERVICE2[] = { 'N','E','T','W','O','R','K','S','E','R','V','I','C','E',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR NT_AUTHORITY[] = { 'N','T',' ','A','U','T','H','O','R','I','T','Y',0 };
|
|
|
|
static const WCHAR NT_Pseudo_Domain[] = { 'N','T',' ','P','s','e','u','d','o',' ','D','o','m','a','i','n',0 };
|
2006-08-12 05:51:21 +02:00
|
|
|
static const WCHAR NTML_Authentication[] = { 'N','T','M','L',' ','A','u','t','h','e','n','t','i','c','a','t','i','o','n',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR NULL_SID[] = { 'N','U','L','L',' ','S','I','D',0 };
|
2006-08-12 05:51:21 +02:00
|
|
|
static const WCHAR Other_Organization[] = { 'O','t','h','e','r',' ','O','r','g','a','n','i','z','a','t','i','o','n',0 };
|
|
|
|
static const WCHAR Performance_Log_Users[] = { 'P','e','r','f','o','r','m','a','n','c','e',' ','L','o','g',' ','U','s','e','r','s',0 };
|
|
|
|
static const WCHAR Performance_Monitor_Users[] = { 'P','e','r','f','o','r','m','a','n','c','e',' ','M','o','n','i','t','o','r',' ','U','s','e','r','s',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR Power_Users[] = { 'P','o','w','e','r',' ','U','s','e','r','s',0 };
|
2006-08-12 05:51:21 +02:00
|
|
|
static const WCHAR Pre_Windows_2000_Compatible_Access[] = { 'P','r','e','-','W','i','n','d','o','w','s',' ','2','0','0','0',' ','C','o','m','p','a','t','i','b','l','e',' ','A','c','c','e','s','s',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR Print_Operators[] = { 'P','r','i','n','t',' ','O','p','e','r','a','t','o','r','s',0 };
|
|
|
|
static const WCHAR PROXY[] = { 'P','R','O','X','Y',0 };
|
2006-08-12 14:00:34 +02:00
|
|
|
static const WCHAR RAS_and_IAS_Servers[] = { 'R','A','S',' ','a','n','d',' ','I','A','S',' ','S','e','r','v','e','r','s',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR Remote_Desktop_Users[] = { 'R','e','m','o','t','e',' ','D','e','s','k','t','o','p',' ','U','s','e','r','s',0 };
|
|
|
|
static const WCHAR REMOTE_INTERACTIVE_LOGON[] = { 'R','E','M','O','T','E',' ','I','N','T','E','R','A','C','T','I','V','E',' ','L','O','G','O','N',0 };
|
|
|
|
static const WCHAR Replicators[] = { 'R','e','p','l','i','c','a','t','o','r','s',0 };
|
|
|
|
static const WCHAR RESTRICTED[] = { 'R','E','S','T','R','I','C','T','E','D',0 };
|
2006-08-12 05:51:21 +02:00
|
|
|
static const WCHAR SChannel_Authentication[] = { 'S','C','h','a','n','n','e','l',' ','A','u','t','h','e','n','t','i','c','a','t','i','o','n',0 };
|
2006-08-12 14:00:34 +02:00
|
|
|
static const WCHAR Schema_Admins[] = { 'S','c','h','e','m','a',' ','A','d','m','i','n','s',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR SELF[] = { 'S','E','L','F',0 };
|
|
|
|
static const WCHAR Server_Operators[] = { 'S','e','r','v','e','r',' ','O','p','e','r','a','t','o','r','s',0 };
|
|
|
|
static const WCHAR SERVICE[] = { 'S','E','R','V','I','C','E',0 };
|
|
|
|
static const WCHAR SYSTEM[] = { 'S','Y','S','T','E','M',0 };
|
|
|
|
static const WCHAR TERMINAL_SERVER_USER[] = { 'T','E','R','M','I','N','A','L',' ','S','E','R','V','E','R',' ','U','S','E','R',0 };
|
2006-08-12 05:51:21 +02:00
|
|
|
static const WCHAR This_Organization[] = { 'T','h','i','s',' ','O','r','g','a','n','i','z','a','t','i','o','n',0 };
|
2006-07-20 13:05:46 +02:00
|
|
|
static const WCHAR Users[] = { 'U','s','e','r','s',0 };
|
|
|
|
|
|
|
|
static const AccountSid ACCOUNT_SIDS[] = {
|
|
|
|
{ WinNullSid, NULL_SID, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinWorldSid, Everyone, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinLocalSid, LOCAL, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinCreatorOwnerSid, CREATOR_OWNER, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinCreatorGroupSid, CREATOR_GROUP, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinCreatorOwnerServerSid, CREATOR_OWNER_SERVER, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinCreatorGroupServerSid, CREATOR_GROUP_SERVER, Blank, SidTypeWellKnownGroup },
|
|
|
|
{ WinNtAuthoritySid, NT_Pseudo_Domain, NT_Pseudo_Domain, SidTypeDomain },
|
|
|
|
{ WinDialupSid, DIALUP, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinNetworkSid, NETWORK, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinBatchSid, BATCH, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinInteractiveSid, INTERACTIVE, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinServiceSid, SERVICE, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinAnonymousSid, ANONYMOUS_LOGON, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinProxySid, PROXY, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinEnterpriseControllersSid, ENTERPRISE_DOMAIN_CONTROLLERS, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinSelfSid, SELF, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinAuthenticatedUserSid, Authenticated_Users, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinRestrictedCodeSid, RESTRICTED, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinTerminalServerSid, TERMINAL_SERVER_USER, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinRemoteLogonIdSid, REMOTE_INTERACTIVE_LOGON, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinLocalSystemSid, SYSTEM, NT_AUTHORITY, SidTypeWellKnownGroup },
|
2009-03-27 15:47:43 +01:00
|
|
|
{ WinLocalServiceSid, LOCAL_SERVICE, NT_AUTHORITY, SidTypeWellKnownGroup, LOCAL_SERVICE2 },
|
|
|
|
{ WinNetworkServiceSid, NETWORK_SERVICE, NT_AUTHORITY, SidTypeWellKnownGroup , NETWORK_SERVICE2},
|
2006-07-20 13:05:46 +02:00
|
|
|
{ WinBuiltinDomainSid, BUILTIN, BUILTIN, SidTypeDomain },
|
|
|
|
{ WinBuiltinAdministratorsSid, Administrators, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinUsersSid, Users, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinGuestsSid, Guests, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinPowerUsersSid, Power_Users, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinAccountOperatorsSid, Account_Operators, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinSystemOperatorsSid, Server_Operators, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinPrintOperatorsSid, Print_Operators, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinBackupOperatorsSid, Backup_Operators, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinReplicatorSid, Replicators, BUILTIN, SidTypeAlias },
|
2006-08-12 14:00:34 +02:00
|
|
|
{ WinBuiltinPreWindows2000CompatibleAccessSid, Pre_Windows_2000_Compatible_Access, BUILTIN, SidTypeAlias },
|
2006-07-20 13:05:46 +02:00
|
|
|
{ WinBuiltinRemoteDesktopUsersSid, Remote_Desktop_Users, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinNetworkConfigurationOperatorsSid, Network_Configuration_Operators, BUILTIN, SidTypeAlias },
|
2006-08-12 05:51:21 +02:00
|
|
|
{ WinNTLMAuthenticationSid, NTML_Authentication, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinDigestAuthenticationSid, Digest_Authentication, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinSChannelAuthenticationSid, SChannel_Authentication, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinThisOrganizationSid, This_Organization, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinOtherOrganizationSid, Other_Organization, NT_AUTHORITY, SidTypeWellKnownGroup },
|
|
|
|
{ WinBuiltinPerfMonitoringUsersSid, Performance_Monitor_Users, BUILTIN, SidTypeAlias },
|
|
|
|
{ WinBuiltinPerfLoggingUsersSid, Performance_Log_Users, BUILTIN, SidTypeAlias },
|
2015-08-26 08:44:45 +02:00
|
|
|
{ WinBuiltinAnyPackageSid, ALL_APPLICATION_PACKAGES, APPLICATION_PACKAGE_AUTHORITY, SidTypeWellKnownGroup },
|
2006-07-20 13:05:46 +02:00
|
|
|
};
|
2003-11-11 23:03:24 +01:00
|
|
|
/*
|
|
|
|
* ACE access rights
|
|
|
|
*/
|
|
|
|
static const WCHAR SDDL_READ_CONTROL[] = {'R','C',0};
|
|
|
|
static const WCHAR SDDL_WRITE_DAC[] = {'W','D',0};
|
|
|
|
static const WCHAR SDDL_WRITE_OWNER[] = {'W','O',0};
|
|
|
|
static const WCHAR SDDL_STANDARD_DELETE[] = {'S','D',0};
|
2007-09-23 06:26:05 +02:00
|
|
|
|
|
|
|
static const WCHAR SDDL_READ_PROPERTY[] = {'R','P',0};
|
|
|
|
static const WCHAR SDDL_WRITE_PROPERTY[] = {'W','P',0};
|
|
|
|
static const WCHAR SDDL_CREATE_CHILD[] = {'C','C',0};
|
|
|
|
static const WCHAR SDDL_DELETE_CHILD[] = {'D','C',0};
|
|
|
|
static const WCHAR SDDL_LIST_CHILDREN[] = {'L','C',0};
|
|
|
|
static const WCHAR SDDL_SELF_WRITE[] = {'S','W',0};
|
|
|
|
static const WCHAR SDDL_LIST_OBJECT[] = {'L','O',0};
|
|
|
|
static const WCHAR SDDL_DELETE_TREE[] = {'D','T',0};
|
|
|
|
static const WCHAR SDDL_CONTROL_ACCESS[] = {'C','R',0};
|
|
|
|
|
|
|
|
static const WCHAR SDDL_FILE_ALL[] = {'F','A',0};
|
|
|
|
static const WCHAR SDDL_FILE_READ[] = {'F','R',0};
|
|
|
|
static const WCHAR SDDL_FILE_WRITE[] = {'F','W',0};
|
|
|
|
static const WCHAR SDDL_FILE_EXECUTE[] = {'F','X',0};
|
|
|
|
|
|
|
|
static const WCHAR SDDL_KEY_ALL[] = {'K','A',0};
|
|
|
|
static const WCHAR SDDL_KEY_READ[] = {'K','R',0};
|
|
|
|
static const WCHAR SDDL_KEY_WRITE[] = {'K','W',0};
|
|
|
|
static const WCHAR SDDL_KEY_EXECUTE[] = {'K','X',0};
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
static const WCHAR SDDL_GENERIC_ALL[] = {'G','A',0};
|
|
|
|
static const WCHAR SDDL_GENERIC_READ[] = {'G','R',0};
|
|
|
|
static const WCHAR SDDL_GENERIC_WRITE[] = {'G','W',0};
|
|
|
|
static const WCHAR SDDL_GENERIC_EXECUTE[] = {'G','X',0};
|
|
|
|
|
2015-04-16 17:02:29 +02:00
|
|
|
static const WCHAR SDDL_NO_READ_UP[] = {'N','R',0};
|
|
|
|
static const WCHAR SDDL_NO_WRITE_UP[] = {'N','W',0};
|
|
|
|
static const WCHAR SDDL_NO_EXECUTE_UP[] = {'N','X',0};
|
|
|
|
|
2007-09-25 22:12:50 +02:00
|
|
|
/*
|
|
|
|
* ACL flags
|
|
|
|
*/
|
|
|
|
static const WCHAR SDDL_PROTECTED[] = {'P',0};
|
|
|
|
static const WCHAR SDDL_AUTO_INHERIT_REQ[] = {'A','R',0};
|
|
|
|
static const WCHAR SDDL_AUTO_INHERITED[] = {'A','I',0};
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
/*
|
|
|
|
* ACE types
|
|
|
|
*/
|
|
|
|
static const WCHAR SDDL_ACCESS_ALLOWED[] = {'A',0};
|
|
|
|
static const WCHAR SDDL_ACCESS_DENIED[] = {'D',0};
|
|
|
|
static const WCHAR SDDL_AUDIT[] = {'A','U',0};
|
|
|
|
static const WCHAR SDDL_ALARM[] = {'A','L',0};
|
2015-04-16 17:02:29 +02:00
|
|
|
static const WCHAR SDDL_MANDATORY_LABEL[] = {'M','L',0};
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ACE flags
|
|
|
|
*/
|
|
|
|
static const WCHAR SDDL_CONTAINER_INHERIT[] = {'C','I',0};
|
|
|
|
static const WCHAR SDDL_OBJECT_INHERIT[] = {'O','I',0};
|
|
|
|
static const WCHAR SDDL_NO_PROPAGATE[] = {'N','P',0};
|
|
|
|
static const WCHAR SDDL_INHERIT_ONLY[] = {'I','O',0};
|
|
|
|
static const WCHAR SDDL_INHERITED[] = {'I','D',0};
|
|
|
|
static const WCHAR SDDL_AUDIT_SUCCESS[] = {'S','A',0};
|
|
|
|
static const WCHAR SDDL_AUDIT_FAILURE[] = {'F','A',0};
|
|
|
|
|
2006-07-29 14:12:58 +02:00
|
|
|
const char * debugstr_sid(PSID sid)
|
2006-07-20 13:05:46 +02:00
|
|
|
{
|
|
|
|
int auth = 0;
|
2009-02-16 09:53:37 +01:00
|
|
|
SID * psid = sid;
|
2006-07-20 13:05:46 +02:00
|
|
|
|
|
|
|
if (psid == NULL)
|
|
|
|
return "(null)";
|
|
|
|
|
|
|
|
auth = psid->IdentifierAuthority.Value[5] +
|
|
|
|
(psid->IdentifierAuthority.Value[4] << 8) +
|
|
|
|
(psid->IdentifierAuthority.Value[3] << 16) +
|
|
|
|
(psid->IdentifierAuthority.Value[2] << 24);
|
|
|
|
|
|
|
|
switch (psid->SubAuthorityCount) {
|
|
|
|
case 0:
|
|
|
|
return wine_dbg_sprintf("S-%d-%d", psid->Revision, auth);
|
|
|
|
case 1:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0]);
|
|
|
|
case 2:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0], psid->SubAuthority[1]);
|
|
|
|
case 3:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0], psid->SubAuthority[1], psid->SubAuthority[2]);
|
|
|
|
case 4:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0], psid->SubAuthority[1], psid->SubAuthority[2],
|
|
|
|
psid->SubAuthority[3]);
|
|
|
|
case 5:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u-%u-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0], psid->SubAuthority[1], psid->SubAuthority[2],
|
|
|
|
psid->SubAuthority[3], psid->SubAuthority[4]);
|
|
|
|
case 6:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u-%u-%u-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[3], psid->SubAuthority[1], psid->SubAuthority[2],
|
|
|
|
psid->SubAuthority[0], psid->SubAuthority[4], psid->SubAuthority[5]);
|
|
|
|
case 7:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u-%u-%u-%u-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0], psid->SubAuthority[1], psid->SubAuthority[2],
|
|
|
|
psid->SubAuthority[3], psid->SubAuthority[4], psid->SubAuthority[5],
|
|
|
|
psid->SubAuthority[6]);
|
|
|
|
case 8:
|
2006-10-03 15:48:41 +02:00
|
|
|
return wine_dbg_sprintf("S-%d-%d-%u-%u-%u-%u-%u-%u-%u-%u", psid->Revision, auth,
|
2006-07-20 13:05:46 +02:00
|
|
|
psid->SubAuthority[0], psid->SubAuthority[1], psid->SubAuthority[2],
|
|
|
|
psid->SubAuthority[3], psid->SubAuthority[4], psid->SubAuthority[5],
|
|
|
|
psid->SubAuthority[6], psid->SubAuthority[7]);
|
|
|
|
}
|
|
|
|
return "(too-big)";
|
|
|
|
}
|
|
|
|
|
2004-12-22 16:31:16 +01:00
|
|
|
/* set last error code from NT status and get the proper boolean return value */
|
|
|
|
/* used for functions that are a simple wrapper around the corresponding ntdll API */
|
|
|
|
static inline BOOL set_ntstatus( NTSTATUS status )
|
|
|
|
{
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError( status ));
|
|
|
|
return !status;
|
|
|
|
}
|
1999-02-19 17:29:05 +01:00
|
|
|
|
2013-01-18 18:59:01 +01:00
|
|
|
/* helper function for SE_FILE_OBJECT objects in [Get|Set]NamedSecurityInfo */
|
2015-03-27 11:11:31 +01:00
|
|
|
static inline DWORD get_security_file( LPCWSTR full_file_name, DWORD access, HANDLE *file )
|
2013-01-18 18:59:01 +01:00
|
|
|
{
|
|
|
|
UNICODE_STRING file_nameW;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
IO_STATUS_BLOCK io;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
if (!RtlDosPathNameToNtPathName_U( full_file_name, &file_nameW, NULL, NULL ))
|
|
|
|
return ERROR_PATH_NOT_FOUND;
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE;
|
|
|
|
attr.ObjectName = &file_nameW;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
2015-10-30 12:53:59 +01:00
|
|
|
status = NtCreateFile( file, access|SYNCHRONIZE, &attr, &io, NULL, FILE_FLAG_BACKUP_SEMANTICS,
|
2013-01-18 18:59:01 +01:00
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN,
|
|
|
|
FILE_OPEN_FOR_BACKUP_INTENT, NULL, 0 );
|
|
|
|
RtlFreeUnicodeString( &file_nameW );
|
|
|
|
return RtlNtStatusToDosError( status );
|
|
|
|
}
|
|
|
|
|
2013-01-30 20:59:12 +01:00
|
|
|
/* helper function for SE_SERVICE objects in [Get|Set]NamedSecurityInfo */
|
|
|
|
static inline DWORD get_security_service( LPWSTR full_service_name, DWORD access, HANDLE *service )
|
|
|
|
{
|
|
|
|
SC_HANDLE manager = 0;
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
err = SERV_OpenSCManagerW( NULL, NULL, access, (SC_HANDLE *)&manager );
|
|
|
|
if (err == ERROR_SUCCESS)
|
2015-07-16 12:56:05 +02:00
|
|
|
{
|
2013-01-30 20:59:12 +01:00
|
|
|
err = SERV_OpenServiceW( manager, full_service_name, access, (SC_HANDLE *)service );
|
2015-07-16 12:56:05 +02:00
|
|
|
CloseServiceHandle( manager );
|
|
|
|
}
|
2013-01-30 20:59:12 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2013-02-02 16:52:04 +01:00
|
|
|
/* helper function for SE_REGISTRY_KEY objects in [Get|Set]NamedSecurityInfo */
|
|
|
|
static inline DWORD get_security_regkey( LPWSTR full_key_name, DWORD access, HANDLE *key )
|
|
|
|
{
|
|
|
|
WCHAR classes_rootW[] = {'C','L','A','S','S','E','S','_','R','O','O','T',0};
|
|
|
|
WCHAR current_userW[] = {'C','U','R','R','E','N','T','_','U','S','E','R',0};
|
|
|
|
WCHAR machineW[] = {'M','A','C','H','I','N','E',0};
|
|
|
|
WCHAR usersW[] = {'U','S','E','R','S',0};
|
|
|
|
LPWSTR p = strchrW(full_key_name, '\\');
|
|
|
|
int len = p-full_key_name;
|
|
|
|
HKEY hParent;
|
|
|
|
|
|
|
|
if (!p) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (strncmpW( full_key_name, classes_rootW, len ) == 0)
|
|
|
|
hParent = HKEY_CLASSES_ROOT;
|
|
|
|
else if (strncmpW( full_key_name, current_userW, len ) == 0)
|
|
|
|
hParent = HKEY_CURRENT_USER;
|
|
|
|
else if (strncmpW( full_key_name, machineW, len ) == 0)
|
|
|
|
hParent = HKEY_LOCAL_MACHINE;
|
|
|
|
else if (strncmpW( full_key_name, usersW, len ) == 0)
|
|
|
|
hParent = HKEY_USERS;
|
|
|
|
else
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
return RegOpenKeyExW( hParent, p+1, 0, access, (HKEY *)key );
|
|
|
|
}
|
|
|
|
|
2005-03-05 11:46:34 +01:00
|
|
|
#define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD))
|
|
|
|
|
|
|
|
static void GetWorldAccessACL(PACL pACL)
|
|
|
|
{
|
|
|
|
PACCESS_ALLOWED_ACE pACE = (PACCESS_ALLOWED_ACE) (pACL + 1);
|
|
|
|
|
|
|
|
pACL->AclRevision = ACL_REVISION;
|
|
|
|
pACL->Sbz1 = 0;
|
|
|
|
pACL->AclSize = WINE_SIZE_OF_WORLD_ACCESS_ACL;
|
|
|
|
pACL->AceCount = 1;
|
|
|
|
pACL->Sbz2 = 0;
|
|
|
|
|
|
|
|
pACE->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
|
|
|
|
pACE->Header.AceFlags = CONTAINER_INHERIT_ACE;
|
|
|
|
pACE->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD);
|
|
|
|
pACE->Mask = 0xf3ffffff; /* Everything except reserved bits */
|
|
|
|
memcpy(&pACE->SidStart, &sidWorld, sizeof(sidWorld));
|
|
|
|
}
|
|
|
|
|
2002-09-17 20:31:06 +02:00
|
|
|
/************************************************************
|
|
|
|
* ADVAPI_IsLocalComputer
|
|
|
|
*
|
|
|
|
* Checks whether the server name indicates local machine.
|
|
|
|
*/
|
2006-07-29 14:12:58 +02:00
|
|
|
BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
|
2002-09-17 20:31:06 +02:00
|
|
|
{
|
2005-06-09 11:44:44 +02:00
|
|
|
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
|
|
|
|
BOOL Result;
|
|
|
|
LPWSTR buf;
|
|
|
|
|
|
|
|
if (!ServerName || !ServerName[0])
|
2004-11-04 05:52:17 +01:00
|
|
|
return TRUE;
|
2006-08-04 03:47:50 +02:00
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
buf = heap_alloc(dwSize * sizeof(WCHAR));
|
2005-06-09 11:44:44 +02:00
|
|
|
Result = GetComputerNameW(buf, &dwSize);
|
|
|
|
if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
|
|
|
|
ServerName += 2;
|
|
|
|
Result = Result && !lstrcmpW(ServerName, buf);
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(buf);
|
2005-06-09 11:44:44 +02:00
|
|
|
|
|
|
|
return Result;
|
2002-09-17 20:31:06 +02:00
|
|
|
}
|
|
|
|
|
2006-07-31 12:59:43 +02:00
|
|
|
/************************************************************
|
|
|
|
* ADVAPI_GetComputerSid
|
|
|
|
*/
|
|
|
|
BOOL ADVAPI_GetComputerSid(PSID sid)
|
|
|
|
{
|
2011-03-02 10:46:30 +01:00
|
|
|
static const struct /* same fields as struct SID */
|
2006-07-31 12:59:43 +02:00
|
|
|
{
|
2011-03-02 10:46:30 +01:00
|
|
|
BYTE Revision;
|
|
|
|
BYTE SubAuthorityCount;
|
|
|
|
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
|
|
|
|
DWORD SubAuthority[4];
|
|
|
|
} computer_sid =
|
|
|
|
{ SID_REVISION, 4, { SECURITY_NT_AUTHORITY }, { SECURITY_NT_NON_UNIQUE, 0, 0, 0 } };
|
|
|
|
|
|
|
|
memcpy( sid, &computer_sid, sizeof(computer_sid) );
|
|
|
|
return TRUE;
|
2006-07-31 12:59:43 +02:00
|
|
|
}
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/* ##############################
|
|
|
|
###### TOKEN FUNCTIONS ######
|
|
|
|
##############################
|
|
|
|
*/
|
1999-01-28 14:46:25 +01:00
|
|
|
|
1999-01-03 13:48:29 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* OpenProcessToken [ADVAPI32.@]
|
2003-03-18 19:35:48 +01:00
|
|
|
* Opens the access token associated with a process handle.
|
1999-01-03 13:48:29 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-01-28 14:46:25 +01:00
|
|
|
* ProcessHandle [I] Handle to process
|
|
|
|
* DesiredAccess [I] Desired access to process
|
|
|
|
* TokenHandle [O] Pointer to handle of open access token
|
1999-01-03 13:48:29 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. TokenHandle contains the access token.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See NtOpenProcessToken.
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-06-01 01:06:46 +02:00
|
|
|
OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
|
1999-02-26 12:11:13 +01:00
|
|
|
HANDLE *TokenHandle )
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
|
1999-03-09 18:43:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* OpenThreadToken [ADVAPI32.@]
|
1999-03-09 18:43:44 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Opens the access token associated with a thread handle.
|
|
|
|
*
|
1999-03-09 18:43:44 +01:00
|
|
|
* PARAMS
|
2003-03-18 19:35:48 +01:00
|
|
|
* ThreadHandle [I] Handle to process
|
|
|
|
* DesiredAccess [I] Desired access to the thread
|
|
|
|
* OpenAsSelf [I] ???
|
|
|
|
* TokenHandle [O] Destination for the token handle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. TokenHandle contains the access token.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See NtOpenThreadToken.
|
1999-03-09 18:43:44 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2002-06-01 01:06:46 +02:00
|
|
|
OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
|
1999-03-09 18:43:44 +01:00
|
|
|
BOOL OpenAsSelf, HANDLE *TokenHandle)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
|
1999-02-19 17:29:05 +01:00
|
|
|
}
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOL WINAPI
|
|
|
|
AdjustTokenGroups( HANDLE TokenHandle, BOOL ResetToDefault, PTOKEN_GROUPS NewState,
|
|
|
|
DWORD BufferLength, PTOKEN_GROUPS PreviousState, PDWORD ReturnLength )
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( NtAdjustGroupsToken(TokenHandle, ResetToDefault, NewState, BufferLength,
|
|
|
|
PreviousState, ReturnLength));
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* AdjustTokenPrivileges [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Adjust the privileges of an open token handle.
|
|
|
|
*
|
1999-02-19 17:29:05 +01:00
|
|
|
* PARAMS
|
2003-03-18 19:35:48 +01:00
|
|
|
* TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
|
|
|
|
* DisableAllPrivileges [I] TRUE=Remove all privileges, FALSE=Use NewState
|
|
|
|
* NewState [I] Desired new privileges of the token
|
|
|
|
* BufferLength [I] Length of NewState
|
|
|
|
* PreviousState [O] Destination for the previous state
|
|
|
|
* ReturnLength [I/O] Size of PreviousState
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. Privileges are set to NewState and PreviousState is updated.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See NtAdjustPrivilegesToken.
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
|
|
|
AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
|
2007-10-17 09:30:44 +02:00
|
|
|
PTOKEN_PRIVILEGES NewState, DWORD BufferLength,
|
2007-10-23 15:31:27 +02:00
|
|
|
PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength )
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
2005-02-11 12:52:06 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
|
2013-12-02 06:38:09 +01:00
|
|
|
TRACE("(%p %d %p %d %p %p)\n", TokenHandle, DisableAllPrivileges, NewState, BufferLength,
|
|
|
|
PreviousState, ReturnLength);
|
|
|
|
|
2005-02-11 12:52:06 +01:00
|
|
|
status = NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges,
|
2004-12-22 16:31:16 +01:00
|
|
|
NewState, BufferLength, PreviousState,
|
2005-02-11 12:52:06 +01:00
|
|
|
ReturnLength);
|
|
|
|
SetLastError( RtlNtStatusToDosError( status ));
|
|
|
|
if ((status == STATUS_SUCCESS) || (status == STATUS_NOT_ALL_ASSIGNED))
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
2002-01-31 21:44:02 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CheckTokenMembership [ADVAPI32.@]
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Determine if an access token is a member of a SID.
|
|
|
|
*
|
2002-01-31 21:44:02 +01:00
|
|
|
* PARAMS
|
2003-03-18 19:35:48 +01:00
|
|
|
* TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
|
|
|
|
* SidToCheck [I] SID that possibly contains the token
|
|
|
|
* IsMember [O] Destination for result.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise.
|
|
|
|
* Failure: FALSE.
|
2002-01-31 21:44:02 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2009-11-08 11:23:09 +01:00
|
|
|
CheckTokenMembership( HANDLE token, PSID sid_to_check,
|
|
|
|
PBOOL is_member )
|
2002-01-31 21:44:02 +01:00
|
|
|
{
|
2009-11-11 00:03:10 +01:00
|
|
|
PTOKEN_GROUPS token_groups = NULL;
|
|
|
|
HANDLE thread_token = NULL;
|
2009-11-08 11:23:09 +01:00
|
|
|
DWORD size, i;
|
2009-11-11 00:03:10 +01:00
|
|
|
BOOL ret;
|
2002-01-31 21:44:02 +01:00
|
|
|
|
2009-11-08 11:23:09 +01:00
|
|
|
TRACE("(%p %s %p)\n", token, debugstr_sid(sid_to_check), is_member);
|
|
|
|
|
|
|
|
*is_member = FALSE;
|
|
|
|
|
|
|
|
if (!token)
|
|
|
|
{
|
2009-11-11 00:03:10 +01:00
|
|
|
if (!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &thread_token))
|
|
|
|
{
|
|
|
|
HANDLE process_token;
|
|
|
|
ret = OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE, &process_token);
|
|
|
|
if (!ret)
|
|
|
|
goto exit;
|
|
|
|
ret = DuplicateTokenEx(process_token, TOKEN_QUERY,
|
|
|
|
NULL, SecurityImpersonation, TokenImpersonation,
|
|
|
|
&thread_token);
|
|
|
|
CloseHandle(process_token);
|
|
|
|
if (!ret)
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
token = thread_token;
|
2009-11-08 11:23:09 +01:00
|
|
|
}
|
2011-08-02 00:12:51 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
TOKEN_TYPE type;
|
|
|
|
|
|
|
|
ret = GetTokenInformation(token, TokenType, &type, sizeof(TOKEN_TYPE), &size);
|
|
|
|
if (!ret) goto exit;
|
|
|
|
|
|
|
|
if (type == TokenPrimary)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NO_IMPERSONATION_TOKEN);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2009-11-08 11:23:09 +01:00
|
|
|
|
2009-11-11 00:03:10 +01:00
|
|
|
ret = GetTokenInformation(token, TokenGroups, NULL, 0, &size);
|
|
|
|
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
goto exit;
|
2009-11-08 11:23:09 +01:00
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
token_groups = heap_alloc(size);
|
2009-11-08 11:23:09 +01:00
|
|
|
if (!token_groups)
|
|
|
|
{
|
2009-11-11 00:03:10 +01:00
|
|
|
ret = FALSE;
|
|
|
|
goto exit;
|
2009-11-08 11:23:09 +01:00
|
|
|
}
|
|
|
|
|
2009-11-11 00:03:10 +01:00
|
|
|
ret = GetTokenInformation(token, TokenGroups, token_groups, size, &size);
|
|
|
|
if (!ret)
|
|
|
|
goto exit;
|
|
|
|
|
2009-11-08 11:23:09 +01:00
|
|
|
for (i = 0; i < token_groups->GroupCount; i++)
|
|
|
|
{
|
|
|
|
TRACE("Groups[%d]: {0x%x, %s}\n", i,
|
|
|
|
token_groups->Groups[i].Attributes,
|
|
|
|
debugstr_sid(token_groups->Groups[i].Sid));
|
|
|
|
if ((token_groups->Groups[i].Attributes & SE_GROUP_ENABLED) &&
|
|
|
|
EqualSid(sid_to_check, token_groups->Groups[i].Sid))
|
|
|
|
{
|
|
|
|
*is_member = TRUE;
|
|
|
|
TRACE("sid enabled and found in token\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-11 00:03:10 +01:00
|
|
|
exit:
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(token_groups);
|
2009-11-11 00:03:10 +01:00
|
|
|
if (thread_token != NULL) CloseHandle(thread_token);
|
2009-11-08 11:23:09 +01:00
|
|
|
|
2009-11-11 00:03:10 +01:00
|
|
|
return ret;
|
2002-01-31 21:44:02 +01:00
|
|
|
}
|
|
|
|
|
1999-01-03 13:48:29 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetTokenInformation [ADVAPI32.@]
|
1999-01-03 13:48:29 +01:00
|
|
|
*
|
2005-11-12 20:12:03 +01:00
|
|
|
* Get a type of information about an access token.
|
|
|
|
*
|
1999-01-03 13:48:29 +01:00
|
|
|
* PARAMS
|
2003-03-18 19:35:48 +01:00
|
|
|
* token [I] Handle from OpenProcessToken() or OpenThreadToken()
|
|
|
|
* tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
|
|
|
|
* tokeninfo [O] Destination for token information
|
|
|
|
* tokeninfolength [I] Length of tokeninfo
|
|
|
|
* retlen [O] Destination for returned token information length
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. tokeninfo contains retlen bytes of token information
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See NtQueryInformationToken.
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-04-03 21:53:31 +02:00
|
|
|
GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
|
1999-03-09 18:43:44 +01:00
|
|
|
LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("(%p, %s, %p, %d, %p):\n",
|
2002-08-26 23:39:17 +02:00
|
|
|
token,
|
|
|
|
(tokeninfoclass == TokenUser) ? "TokenUser" :
|
|
|
|
(tokeninfoclass == TokenGroups) ? "TokenGroups" :
|
|
|
|
(tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
|
|
|
|
(tokeninfoclass == TokenOwner) ? "TokenOwner" :
|
|
|
|
(tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
|
|
|
|
(tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
|
|
|
|
(tokeninfoclass == TokenSource) ? "TokenSource" :
|
|
|
|
(tokeninfoclass == TokenType) ? "TokenType" :
|
|
|
|
(tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
|
|
|
|
(tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
|
|
|
|
(tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
|
|
|
|
(tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
|
|
|
|
(tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
|
|
|
|
(tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
|
|
|
|
(tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
|
|
|
|
"Unknown",
|
|
|
|
tokeninfo, tokeninfolength, retlen);
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( NtQueryInformationToken( token, tokeninfoclass, tokeninfo,
|
|
|
|
tokeninfolength, retlen));
|
2002-08-26 23:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetTokenInformation [ADVAPI32.@]
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Set information for an access token.
|
|
|
|
*
|
2002-08-26 23:39:17 +02:00
|
|
|
* PARAMS
|
2003-03-18 19:35:48 +01:00
|
|
|
* token [I] Handle from OpenProcessToken() or OpenThreadToken()
|
|
|
|
* tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
|
|
|
|
* tokeninfo [I] Token information to set
|
|
|
|
* tokeninfolength [I] Length of tokeninfo
|
2002-08-26 23:39:17 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. The information for the token is set to tokeninfo.
|
|
|
|
* Failure: FALSE.
|
2002-08-26 23:39:17 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
SetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
|
|
|
|
LPVOID tokeninfo, DWORD tokeninfolength )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("(%p, %s, %p, %d): stub\n",
|
2002-08-26 23:39:17 +02:00
|
|
|
token,
|
|
|
|
(tokeninfoclass == TokenUser) ? "TokenUser" :
|
|
|
|
(tokeninfoclass == TokenGroups) ? "TokenGroups" :
|
|
|
|
(tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
|
|
|
|
(tokeninfoclass == TokenOwner) ? "TokenOwner" :
|
|
|
|
(tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
|
|
|
|
(tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
|
|
|
|
(tokeninfoclass == TokenSource) ? "TokenSource" :
|
|
|
|
(tokeninfoclass == TokenType) ? "TokenType" :
|
|
|
|
(tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
|
|
|
|
(tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
|
|
|
|
(tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
|
|
|
|
(tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
|
|
|
|
(tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
|
|
|
|
(tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
|
|
|
|
(tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
|
|
|
|
"Unknown",
|
|
|
|
tokeninfo, tokeninfolength);
|
|
|
|
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( NtSetInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength ));
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/*************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetThreadToken [ADVAPI32.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Assigns an 'impersonation token' to a thread so it can assume the
|
2004-04-28 02:24:44 +02:00
|
|
|
* security privileges of another thread or process. Can also remove
|
2003-03-18 19:35:48 +01:00
|
|
|
* a previously assigned token.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* thread [O] Handle to thread to set the token for
|
|
|
|
* token [I] Token to set
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. The threads access token is set to token
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Only supported on NT or higher. On Win9X this function does nothing.
|
|
|
|
* See SetTokenInformation.
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( NtSetInformationThread( thread ? *thread : GetCurrentThread(),
|
|
|
|
ThreadImpersonationToken, &token, sizeof token ));
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
2008-03-21 23:37:36 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* CreateRestrictedToken [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Create a new more restricted token from an existing token.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* baseToken [I] Token to base the new restricted token on
|
|
|
|
* flags [I] Options
|
|
|
|
* nDisableSids [I] Length of disableSids array
|
|
|
|
* disableSids [I] Array of SIDs to disable in the new token
|
|
|
|
* nDeletePrivs [I] Length of deletePrivs array
|
|
|
|
* deletePrivs [I] Array of privileges to delete in the new token
|
|
|
|
* nRestrictSids [I] Length of restrictSids array
|
|
|
|
* restrictSids [I] Array of SIDs to restrict in the new token
|
|
|
|
* newToken [O] Address where the new token is stored
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CreateRestrictedToken(
|
|
|
|
HANDLE baseToken,
|
|
|
|
DWORD flags,
|
|
|
|
DWORD nDisableSids,
|
|
|
|
PSID_AND_ATTRIBUTES disableSids,
|
|
|
|
DWORD nDeletePrivs,
|
|
|
|
PLUID_AND_ATTRIBUTES deletePrivs,
|
|
|
|
DWORD nRestrictSids,
|
|
|
|
PSID_AND_ATTRIBUTES restrictSids,
|
|
|
|
PHANDLE newToken)
|
|
|
|
{
|
2013-01-16 10:56:47 +01:00
|
|
|
TOKEN_TYPE type;
|
|
|
|
SECURITY_IMPERSONATION_LEVEL level = TokenImpersonationLevel;
|
|
|
|
DWORD size;
|
|
|
|
|
2008-03-21 23:37:36 +01:00
|
|
|
FIXME("(%p, 0x%x, %u, %p, %u, %p, %u, %p, %p): stub\n",
|
|
|
|
baseToken, flags, nDisableSids, disableSids,
|
|
|
|
nDeletePrivs, deletePrivs,
|
|
|
|
nRestrictSids, restrictSids,
|
|
|
|
newToken);
|
2013-01-16 10:56:47 +01:00
|
|
|
|
|
|
|
size = sizeof(type);
|
|
|
|
if (!GetTokenInformation( baseToken, TokenType, &type, size, &size )) return FALSE;
|
|
|
|
if (type == TokenImpersonation)
|
|
|
|
{
|
|
|
|
size = sizeof(level);
|
|
|
|
if (!GetTokenInformation( baseToken, TokenImpersonationLevel, &level, size, &size ))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return DuplicateTokenEx( baseToken, MAXIMUM_ALLOWED, NULL, level, type, newToken );
|
2008-03-21 23:37:36 +01:00
|
|
|
}
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/* ##############################
|
|
|
|
###### SID FUNCTIONS ######
|
|
|
|
##############################
|
|
|
|
*/
|
|
|
|
|
1999-01-03 13:48:29 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* AllocateAndInitializeSid [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-02-19 17:29:05 +01:00
|
|
|
* pIdentifierAuthority []
|
|
|
|
* nSubAuthorityCount []
|
|
|
|
* nSubAuthority0 []
|
|
|
|
* nSubAuthority1 []
|
|
|
|
* nSubAuthority2 []
|
|
|
|
* nSubAuthority3 []
|
|
|
|
* nSubAuthority4 []
|
|
|
|
* nSubAuthority5 []
|
|
|
|
* nSubAuthority6 []
|
|
|
|
* nSubAuthority7 []
|
|
|
|
* pSid []
|
1999-01-28 14:46:25 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-02-19 17:29:05 +01:00
|
|
|
AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
|
|
|
BYTE nSubAuthorityCount,
|
|
|
|
DWORD nSubAuthority0, DWORD nSubAuthority1,
|
|
|
|
DWORD nSubAuthority2, DWORD nSubAuthority3,
|
|
|
|
DWORD nSubAuthority4, DWORD nSubAuthority5,
|
|
|
|
DWORD nSubAuthority6, DWORD nSubAuthority7,
|
|
|
|
PSID *pSid )
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlAllocateAndInitializeSid(
|
|
|
|
pIdentifierAuthority, nSubAuthorityCount,
|
|
|
|
nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
|
|
|
|
nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
|
|
|
|
pSid ));
|
1999-02-19 17:29:05 +01:00
|
|
|
}
|
1999-01-03 13:48:29 +01:00
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* FreeSid [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-02-19 17:29:05 +01:00
|
|
|
* pSid []
|
1999-01-28 14:46:25 +01:00
|
|
|
*/
|
1999-07-04 13:01:21 +02:00
|
|
|
PVOID WINAPI
|
1999-02-19 17:29:05 +01:00
|
|
|
FreeSid( PSID pSid )
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
RtlFreeSid(pSid);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return NULL; /* is documented like this */
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* CopySid [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* nDestinationSidLength []
|
|
|
|
* pDestinationSid []
|
|
|
|
* pSourceSid []
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-02-12 18:47:07 +01:00
|
|
|
CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
2006-07-16 13:21:00 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CreateWellKnownSid [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
CreateWellKnownSid( WELL_KNOWN_SID_TYPE WellKnownSidType,
|
|
|
|
PSID DomainSid,
|
|
|
|
PSID pSid,
|
|
|
|
DWORD* cbSid)
|
|
|
|
{
|
2007-09-21 22:17:23 +02:00
|
|
|
unsigned int i;
|
2006-07-20 13:05:46 +02:00
|
|
|
TRACE("(%d, %s, %p, %p)\n", WellKnownSidType, debugstr_sid(DomainSid), pSid, cbSid);
|
2006-07-16 13:21:00 +02:00
|
|
|
|
2009-04-15 14:59:10 +02:00
|
|
|
if (cbSid == NULL || (DomainSid && !IsValidSid(DomainSid)))
|
|
|
|
{
|
2006-07-16 13:21:00 +02:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++) {
|
|
|
|
if (WellKnownSids[i].Type == WellKnownSidType) {
|
2006-07-29 02:21:49 +02:00
|
|
|
DWORD length = GetSidLengthRequired(WellKnownSids[i].Sid.SubAuthorityCount);
|
2006-07-16 13:21:00 +02:00
|
|
|
|
2009-04-15 14:59:10 +02:00
|
|
|
if (*cbSid < length)
|
|
|
|
{
|
|
|
|
*cbSid = length;
|
2006-07-16 13:21:00 +02:00
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-04-15 14:59:10 +02:00
|
|
|
if (!pSid)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-07-29 02:21:49 +02:00
|
|
|
CopyMemory(pSid, &WellKnownSids[i].Sid.Revision, length);
|
2006-07-16 13:21:00 +02:00
|
|
|
*cbSid = length;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-21 11:01:56 +02:00
|
|
|
if (DomainSid == NULL || *GetSidSubAuthorityCount(DomainSid) == SID_MAX_SUB_AUTHORITIES)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
|
|
|
|
if (WellKnownRids[i].Type == WellKnownSidType) {
|
|
|
|
UCHAR domain_subauth = *GetSidSubAuthorityCount(DomainSid);
|
|
|
|
DWORD domain_sid_length = GetSidLengthRequired(domain_subauth);
|
|
|
|
DWORD output_sid_length = GetSidLengthRequired(domain_subauth + 1);
|
|
|
|
|
2009-04-15 14:59:10 +02:00
|
|
|
if (*cbSid < output_sid_length)
|
|
|
|
{
|
|
|
|
*cbSid = output_sid_length;
|
2007-10-21 11:01:56 +02:00
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-04-15 14:59:10 +02:00
|
|
|
if (!pSid)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-10-21 11:01:56 +02:00
|
|
|
CopyMemory(pSid, DomainSid, domain_sid_length);
|
|
|
|
(*GetSidSubAuthorityCount(pSid))++;
|
|
|
|
(*GetSidSubAuthority(pSid, domain_subauth)) = WellKnownRids[i].Rid;
|
|
|
|
*cbSid = output_sid_length;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-07-16 13:21:00 +02:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* IsWellKnownSid [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
IsWellKnownSid( PSID pSid, WELL_KNOWN_SID_TYPE WellKnownSidType )
|
|
|
|
{
|
2007-09-21 22:17:23 +02:00
|
|
|
unsigned int i;
|
2006-07-20 13:05:46 +02:00
|
|
|
TRACE("(%s, %d)\n", debugstr_sid(pSid), WellKnownSidType);
|
2006-07-16 13:21:00 +02:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
|
|
|
|
if (WellKnownSids[i].Type == WellKnownSidType)
|
2006-07-29 02:21:49 +02:00
|
|
|
if (EqualSid(pSid, (PSID)&(WellKnownSids[i].Sid.Revision)))
|
2006-07-16 13:21:00 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI
|
|
|
|
IsTokenRestricted( HANDLE TokenHandle )
|
|
|
|
{
|
2005-06-21 22:49:54 +02:00
|
|
|
TOKEN_GROUPS *groups;
|
|
|
|
DWORD size;
|
|
|
|
NTSTATUS status;
|
|
|
|
BOOL restricted;
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
|
2005-06-21 22:49:54 +02:00
|
|
|
TRACE("(%p)\n", TokenHandle);
|
|
|
|
|
|
|
|
status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, NULL, 0, &size);
|
|
|
|
if (status != STATUS_BUFFER_TOO_SMALL)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
groups = heap_alloc(size);
|
2005-06-21 22:49:54 +02:00
|
|
|
if (!groups)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, groups, size, &size);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(groups);
|
2005-06-21 22:49:54 +02:00
|
|
|
return set_ntstatus(status);
|
|
|
|
}
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
restricted = groups->GroupCount > 0;
|
|
|
|
heap_free(groups);
|
2005-06-21 22:49:54 +02:00
|
|
|
|
|
|
|
return restricted;
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* IsValidSid [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid []
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-02-12 18:47:07 +01:00
|
|
|
IsValidSid( PSID pSid )
|
1999-01-28 14:46:25 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlValidSid( pSid );
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* EqualSid [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid1 []
|
|
|
|
* pSid2 []
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-02-12 18:47:07 +01:00
|
|
|
EqualSid( PSID pSid1, PSID pSid2 )
|
1999-01-28 14:46:25 +01:00
|
|
|
{
|
2009-11-15 17:37:35 +01:00
|
|
|
BOOL ret = RtlEqualSid( pSid1, pSid2 );
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
return ret;
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* EqualPrefixSid [ADVAPI32.@]
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
|
|
|
return RtlEqualPrefixSid(pSid1, pSid2);
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSidLengthRequired [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* nSubAuthorityCount []
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-01-28 14:46:25 +01:00
|
|
|
DWORD WINAPI
|
|
|
|
GetSidLengthRequired( BYTE nSubAuthorityCount )
|
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlLengthRequiredSid(nSubAuthorityCount);
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* InitializeSid [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-02-19 17:29:05 +01:00
|
|
|
* pIdentifierAuthority []
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
InitializeSid (
|
|
|
|
PSID pSid,
|
|
|
|
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
|
|
|
|
BYTE nSubAuthorityCount)
|
1999-01-28 14:46:25 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
DWORD WINAPI
|
|
|
|
GetEffectiveRightsFromAclA( PACL pacl, PTRUSTEEA pTrustee, PACCESS_MASK pAccessRights )
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p - stub\n", pacl, pTrustee, pAccessRights);
|
|
|
|
|
2009-12-01 11:35:50 +01:00
|
|
|
*pAccessRights = STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL;
|
|
|
|
return 0;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI
|
|
|
|
GetEffectiveRightsFromAclW( PACL pacl, PTRUSTEEW pTrustee, PACCESS_MASK pAccessRights )
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p - stub\n", pacl, pTrustee, pAccessRights);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSidIdentifierAuthority [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-02-19 17:29:05 +01:00
|
|
|
* pSid []
|
1999-01-28 14:46:25 +01:00
|
|
|
*/
|
1999-02-19 17:29:05 +01:00
|
|
|
PSID_IDENTIFIER_AUTHORITY WINAPI
|
|
|
|
GetSidIdentifierAuthority( PSID pSid )
|
1999-01-28 14:46:25 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlIdentifierAuthoritySid(pSid);
|
1999-02-19 17:29:05 +01:00
|
|
|
}
|
1997-02-15 15:29:56 +01:00
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSidSubAuthority [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid []
|
|
|
|
* nSubAuthority []
|
|
|
|
*/
|
1999-07-04 13:01:21 +02:00
|
|
|
PDWORD WINAPI
|
1999-02-19 17:29:05 +01:00
|
|
|
GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
|
|
|
|
{
|
2009-06-27 12:48:46 +02:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlSubAuthoritySid(pSid, nSubAuthority);
|
1999-02-19 17:29:05 +01:00
|
|
|
}
|
1997-02-15 15:29:56 +01:00
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSidSubAuthorityCount [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid []
|
|
|
|
*/
|
1999-07-04 13:01:21 +02:00
|
|
|
PUCHAR WINAPI
|
1999-02-19 17:29:05 +01:00
|
|
|
GetSidSubAuthorityCount (PSID pSid)
|
|
|
|
{
|
2009-06-27 12:48:46 +02:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlSubAuthorityCountSid(pSid);
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-30 13:54:32 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetLengthSid [ADVAPI32.@]
|
1999-01-30 13:54:32 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pSid []
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-19 17:29:05 +01:00
|
|
|
DWORD WINAPI
|
|
|
|
GetLengthSid (PSID pSid)
|
Release 971101
Thu Oct 30 21:52:23 1997 Martin Boehme <boehme@informatik.mu-luebeck.de>
* [windows/nonclient.c]
Changed NC_TrackSysMenu to give the same behaviour as MS-Windows,
i.e. system menu already appears when mouse button is depressed.
Changed NC_HandleNCLButtonDblClk so that double clicks on scroll
bar arrows are handled the same way as single clicks.
* [windows/winpos.c]
Fixed SetWindowPos32 to clear WIN_NO_REDRAW when SWP_SHOWWINDOW is
set; this is the way MS-Windows behaves.
Thu Oct 30 21:08:57 1997 Morten Welinder <terra@diku.dk>
* [controls/status.c]
In SW_SetText, fix condition, I hope.
* [controls/menu.c]
(GetMenuState32): Don't mask return value. Print more debug info.
(MENU_MenuBarCalcSize): Be more careful when printing debug
information.
(MENU_SetItemData): Empty strings are separators.
* [graphics/x11drv/text.c]
Don't prototype CLIPPING_IntersectClipRect.
* [include/dc.h]
Prototype CLIPPING_IntersectClipRect.
* [objects/font.c]
Remove non-portable (and faulty) smartness in FONT_TextMetric*to*.
In CreateFont32W and CreateFont16, handle null font name.
* [objects/text.c]
(TEXT_NextLine): Fix end-of-line bug.
* [if1632/shell32.spec]
Activate existing implementation of ExtractIconA.
* [misc/shell.c]
For Control_RunDLL, add types for parameters.
Thu Oct 30 14:54:11 1997 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
* [controls/static.c] [include/windows.h] [misc/spy.c]
Added some win32 defines to static controls, basic SS_BITMAP style
handling implemented. [please add more, I am lacking knowledge and
time]
* [controls/status.c]
part_num 255 seems to indicate whole statusline (win95 cdplayer.exe)
* [if1632/thunk.c] [tools/build.c]
Support lret and 0x66 lret calls for CallTo16_regs
(needed for KERNEL32_45)
Fixed KERNEL32_45, QT_Thunk (should work now).
* [if1632/relay.c][if1632/builtin.c][tools/build.c][if1632/*32.spec]
Added string dumping to relay debugging for win32 apifuncs.
* [misc/ver.c]
Fixed and cleaned up VerQueryValue*.
* [multimedia/*.c][include/mmsystem.h][if1632/mmsystem.spec]
[if1632/winmm.spec]
Win32 support for lowlevel multimedia functions.
Added some mixer* lowlevel functions.
Some small fixes in the audio lowlevel queue handling, code
reformatting/cleanups.
* [debugger/hash.c]
Don't show difference between 16bit symbols if they are in
different segments.
* [objects/cursoricon.c]
Added GetIconInfo (partial) and CreateIconIndirect.
* [windows/mdi.c]
Fixed some "bad class" problems and crashes in MDICreateChild,
which happen in Win32 (jwp32.exe).
Wed Oct 29 00:57:27 1997 Bruce Milner <Bruce.Milner@genetics.utah.edu>
* [if1632/winaspi.spec] [misc/aspi.c] [include/aspi.c]
[documentation/aspi] [include/callback.h]
Added support for 16 bit ASPI calls to linux generic SCSI.
The support is not complete, but appears to run my Mustek
scanner from within ipplus.exe.
Mon Oct 27 00:59:41 1997 Alex Korobka <alex@trantor.pharm.sunysb.edu>
* [windows/dce.c]
DC reuse framework.
Sun Oct 26 18:41:21 1997 Huw D M Davies <h.davies1@physics.oxford.ac.uk>
* [graphics/x11drv/xfont.c]
Substituted fonts are removed from the alias table. References to
the old name are also updated.
* [controls/combo.c]
LB_SELECTSTRING32 not CB_SELECTSTRING32 should be sent to
ComboLBox.
Sun Oct 26 14:25:00 1997 Nikita V. Youshchenko <yoush@cs.msu.su>
* [include/drive.h] [files/drive.c] [msdos/int21.c]
Partially implemented DOS drive mapping (int21 AX=440F).
Sat Oct 25 13:03:29 1997 Alexandre Julliard <julliard@lrc.epfl.ch>
* [debugger/debug.l]
Support '.' in identifiers. Use "x . y" to access structure
fields.
* [debugger/hash.c] [loader/pe_image.c]
Load entry points of Win32 modules only when entering the
debugger.
* [debugger/break.c]
New function DEBUG_AddModuleBreakpoint() to set a breakpoint at
the start of every module.
* [files/file.c]
FILE_mmap() can now fake mmap() for unaligned offsets or broken
filesystems.
* [include/callback.h] [misc/callback.c] [if1632/thunk.c]
Use a table of callbacks instead of macros to differentiate
between emulator and Winelib.
* [loader/task.c]
Initialize current directory from cwd, not from module path.
* [tools/build.c]
Read CallTo16 prototypes directly from thunk.c source file.
* [windows/winproc.c] [windows/mdi.c]
Added translation for WM_MDIACTIVATE and WM_MDIGETACTIVE.
Fri Oct 24 21:41:25 1997 Uwe Bonnes <bon@elektron.ikp.tu-darmstadt.de>
* [files/drive.c]
Allow arguments like "a" for the drive related apis.
* [memory/global.c]
Keep the calculation for dwMemoryLoad in range.
* [misc/crtdll.c]
Make CRTDLL_getcwd use GetCurrentDirectory32A and alloc
its memory if requested.
Implemented CRTDLL_rename and CRTDLL_stat needed for
lcc-win32:wedit.exe.
Implemented CRTDLL__fullpath.
* [misc/comm.c]
High speed modes for the 16-bit mode Comm functions.
* [misc/cpu.c]
As applications may treat lpMaximumApplicationAddress as long,
use a valid long number.
* [misc/main.c]
In SystemParametersInfo16 ignore SPI_GETHIGHCONTRAST too.
* [misc/ole2nls.c]
Implement LCMAP_UPPERCASE for LCMapString32.
* [misc/wsprintf]
Made WPRINTF_ParseFormatA understand %ws.
* [win32/file.c]
Ignore FILE_ATTRIBUTE_NORMAL.
Stub for ReadFileEx.
Fri Oct 24 15:36:02 1997 Doug Ridgway <ridgway@routh.ucsd.edu>
* [memory/local.c]
Local heap exhaustion message now prints which builtin heap filled.
Fri Oct 24 00:46:34 1997 Huw D M Davies <h.davies1@physics.oxford.ac.uk>
* [windows/dialog.c]
Reversed CreateFont16/32W typo.
Thu Oct 23 23:44:20 1997 Kristian Nielsen <kristian.nielsen@risoe.dk>
* [if1632/user.spec]
Fixed argument list for ChangeClipboardChain.
* [windows/mdi.c]
Pass correct hInstance to CreateWindow16() in MDICreateChild().
Mon Oct 20 11:51:24 1997 Carsten Fallesen <cf@it.dtu.dk>
* [objects/metafile.c]
Added support for META_SETTEXTCHAREXTRA.
* [objects/region.c]
Fixed crash in XPolygonRegion if there is only one point in
in the region.
* [if1632/gdi32.spec][include/gdi.h][include/windows.h]
[objects/gdiobj.c]
Completed OBJ_XXX defines in gdi.h, removed OBJ_XXX in gdiobj.c
and included gdi.h instead. Implemented GetObjectType32().
Thu Oct 16 17:21:32 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
* [documentation/wine.texinfo]
Fixed WIN32 and Makefiles entries of Reference manual node, that
made makeinfo dump core.
Mon Oct 13 17:15:57 1997 Robert Wilhelm <robert@physiol.med.tu-muenchen.de>
* [if1632/crtdll.spec]
Added missing math functions y0(), y1(), y2(), floor(), frexp(),
ldexp(), modf().
1997-11-01 20:08:16 +01:00
|
|
|
{
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
return RtlLengthSid(pSid);
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/* ##############################################
|
|
|
|
###### SECURITY DESCRIPTOR FUNCTIONS ######
|
|
|
|
##############################################
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-06-23 13:40:57 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BuildSecurityDescriptorA [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Builds a SD from
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pOwner [I]
|
|
|
|
* pGroup [I]
|
|
|
|
* cCountOfAccessEntries [I]
|
|
|
|
* pListOfAccessEntries [I]
|
|
|
|
* cCountOfAuditEntries [I]
|
|
|
|
* pListofAuditEntries [I]
|
|
|
|
* pOldSD [I]
|
|
|
|
* lpdwBufferLength [I/O]
|
|
|
|
* pNewSD [O]
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code from Winerror.h
|
2005-06-23 13:40:57 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI BuildSecurityDescriptorA(
|
2005-11-21 13:06:00 +01:00
|
|
|
IN PTRUSTEEA pOwner,
|
|
|
|
IN PTRUSTEEA pGroup,
|
|
|
|
IN ULONG cCountOfAccessEntries,
|
|
|
|
IN PEXPLICIT_ACCESSA pListOfAccessEntries,
|
|
|
|
IN ULONG cCountOfAuditEntries,
|
|
|
|
IN PEXPLICIT_ACCESSA pListofAuditEntries,
|
2005-06-23 13:40:57 +02:00
|
|
|
IN PSECURITY_DESCRIPTOR pOldSD,
|
2005-11-21 13:06:00 +01:00
|
|
|
IN OUT PULONG lpdwBufferLength,
|
|
|
|
OUT PSECURITY_DESCRIPTOR* pNewSD)
|
2005-06-23 13:40:57 +02:00
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("(%p,%p,%d,%p,%d,%p,%p,%p,%p) stub!\n",pOwner,pGroup,
|
2005-06-23 13:40:57 +02:00
|
|
|
cCountOfAccessEntries,pListOfAccessEntries,cCountOfAuditEntries,
|
|
|
|
pListofAuditEntries,pOldSD,lpdwBufferLength,pNewSD);
|
|
|
|
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BuildSecurityDescriptorW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* See BuildSecurityDescriptorA.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI BuildSecurityDescriptorW(
|
2005-11-21 13:06:00 +01:00
|
|
|
IN PTRUSTEEW pOwner,
|
|
|
|
IN PTRUSTEEW pGroup,
|
|
|
|
IN ULONG cCountOfAccessEntries,
|
|
|
|
IN PEXPLICIT_ACCESSW pListOfAccessEntries,
|
|
|
|
IN ULONG cCountOfAuditEntries,
|
|
|
|
IN PEXPLICIT_ACCESSW pListofAuditEntries,
|
2005-06-23 13:40:57 +02:00
|
|
|
IN PSECURITY_DESCRIPTOR pOldSD,
|
2005-11-21 13:06:00 +01:00
|
|
|
IN OUT PULONG lpdwBufferLength,
|
|
|
|
OUT PSECURITY_DESCRIPTOR* pNewSD)
|
2005-06-23 13:40:57 +02:00
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("(%p,%p,%d,%p,%d,%p,%p,%p,%p) stub!\n",pOwner,pGroup,
|
2005-06-23 13:40:57 +02:00
|
|
|
cCountOfAccessEntries,pListOfAccessEntries,cCountOfAuditEntries,
|
|
|
|
pListofAuditEntries,pOldSD,lpdwBufferLength,pNewSD);
|
|
|
|
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-01-30 13:54:32 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* InitializeSecurityDescriptor [ADVAPI32.@]
|
1999-01-30 13:54:32 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pDescr []
|
|
|
|
* revision []
|
1997-10-12 18:30:17 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2004-08-14 01:55:43 +02:00
|
|
|
InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr, DWORD revision )
|
1997-10-12 18:30:17 +02:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlCreateSecurityDescriptor(pDescr, revision ));
|
1997-10-12 18:30:17 +02:00
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* MakeAbsoluteSD [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI MakeAbsoluteSD (
|
|
|
|
IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
|
|
|
|
OUT PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
|
|
|
|
OUT LPDWORD lpdwAbsoluteSecurityDescriptorSize,
|
|
|
|
OUT PACL pDacl,
|
|
|
|
OUT LPDWORD lpdwDaclSize,
|
|
|
|
OUT PACL pSacl,
|
|
|
|
OUT LPDWORD lpdwSaclSize,
|
|
|
|
OUT PSID pOwner,
|
|
|
|
OUT LPDWORD lpdwOwnerSize,
|
|
|
|
OUT PSID pPrimaryGroup,
|
|
|
|
OUT LPDWORD lpdwPrimaryGroupSize)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlSelfRelativeToAbsoluteSD(pSelfRelativeSecurityDescriptor,
|
|
|
|
pAbsoluteSecurityDescriptor,
|
|
|
|
lpdwAbsoluteSecurityDescriptorSize,
|
|
|
|
pDacl, lpdwDaclSize, pSacl, lpdwSaclSize,
|
|
|
|
pOwner, lpdwOwnerSize,
|
|
|
|
pPrimaryGroup, lpdwPrimaryGroupSize));
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
2005-06-17 11:52:06 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetKernelObjectSecurity [ADVAPI32.@]
|
|
|
|
*/
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI GetKernelObjectSecurity(
|
|
|
|
HANDLE Handle,
|
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
DWORD nLength,
|
|
|
|
LPDWORD lpnLengthNeeded )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x,%p)\n", Handle, RequestedInformation,
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
pSecurityDescriptor, nLength, lpnLengthNeeded);
|
|
|
|
|
2005-06-17 11:52:06 +02:00
|
|
|
return set_ntstatus( NtQuerySecurityObject(Handle, RequestedInformation, pSecurityDescriptor,
|
|
|
|
nLength, lpnLengthNeeded ));
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
}
|
|
|
|
|
2005-06-17 11:52:06 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetPrivateObjectSecurity [ADVAPI32.@]
|
|
|
|
*/
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI GetPrivateObjectSecurity(
|
|
|
|
PSECURITY_DESCRIPTOR ObjectDescriptor,
|
|
|
|
SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR ResultantDescriptor,
|
|
|
|
DWORD DescriptorLength,
|
|
|
|
PDWORD ReturnLength )
|
|
|
|
{
|
2007-09-27 21:01:49 +02:00
|
|
|
SECURITY_DESCRIPTOR desc;
|
|
|
|
BOOL defaulted, present;
|
|
|
|
PACL pacl;
|
|
|
|
PSID psid;
|
|
|
|
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x,%p)\n", ObjectDescriptor, SecurityInformation,
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
ResultantDescriptor, DescriptorLength, ReturnLength);
|
|
|
|
|
2007-09-27 21:01:49 +02:00
|
|
|
if (!InitializeSecurityDescriptor(&desc, SECURITY_DESCRIPTOR_REVISION))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (SecurityInformation & OWNER_SECURITY_INFORMATION)
|
|
|
|
{
|
|
|
|
if (!GetSecurityDescriptorOwner(ObjectDescriptor, &psid, &defaulted))
|
|
|
|
return FALSE;
|
|
|
|
SetSecurityDescriptorOwner(&desc, psid, defaulted);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityInformation & GROUP_SECURITY_INFORMATION)
|
|
|
|
{
|
|
|
|
if (!GetSecurityDescriptorGroup(ObjectDescriptor, &psid, &defaulted))
|
|
|
|
return FALSE;
|
|
|
|
SetSecurityDescriptorGroup(&desc, psid, defaulted);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityInformation & DACL_SECURITY_INFORMATION)
|
|
|
|
{
|
|
|
|
if (!GetSecurityDescriptorDacl(ObjectDescriptor, &present, &pacl, &defaulted))
|
|
|
|
return FALSE;
|
|
|
|
SetSecurityDescriptorDacl(&desc, present, pacl, defaulted);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityInformation & SACL_SECURITY_INFORMATION)
|
|
|
|
{
|
|
|
|
if (!GetSecurityDescriptorSacl(ObjectDescriptor, &present, &pacl, &defaulted))
|
|
|
|
return FALSE;
|
|
|
|
SetSecurityDescriptorSacl(&desc, present, pacl, defaulted);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ReturnLength = DescriptorLength;
|
2007-09-28 19:51:32 +02:00
|
|
|
return MakeSelfRelativeSD(&desc, ResultantDescriptor, ReturnLength);
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
1999-01-30 13:54:32 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSecurityDescriptorLength [ADVAPI32.@]
|
1999-01-17 17:55:11 +01:00
|
|
|
*/
|
2004-08-14 01:55:43 +02:00
|
|
|
DWORD WINAPI GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr)
|
1999-01-17 17:55:11 +01:00
|
|
|
{
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
return RtlLengthSecurityDescriptor(pDescr);
|
1999-01-17 17:55:11 +01:00
|
|
|
}
|
|
|
|
|
1999-01-30 13:54:32 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSecurityDescriptorOwner [ADVAPI32.@]
|
1999-01-30 13:54:32 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pOwner []
|
|
|
|
* lpbOwnerDefaulted []
|
1999-01-26 11:11:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2004-08-14 01:55:43 +02:00
|
|
|
GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr, PSID *pOwner,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPBOOL lpbOwnerDefaulted )
|
1999-01-26 11:11:22 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
BOOLEAN defaulted;
|
|
|
|
BOOL ret = set_ntstatus( RtlGetOwnerSecurityDescriptor( pDescr, pOwner, &defaulted ));
|
|
|
|
*lpbOwnerDefaulted = defaulted;
|
|
|
|
return ret;
|
1999-01-26 11:11:22 +01:00
|
|
|
}
|
1999-01-17 17:55:11 +01:00
|
|
|
|
1999-01-30 13:54:32 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetSecurityDescriptorOwner [ADVAPI32.@]
|
1999-01-30 13:54:32 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-01-26 11:11:22 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-02-26 12:11:13 +01:00
|
|
|
PSID pOwner, BOOL bOwnerDefaulted)
|
1999-02-19 17:29:05 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
|
1999-02-19 17:29:05 +01:00
|
|
|
}
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSecurityDescriptorGroup [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI GetSecurityDescriptorGroup(
|
1999-02-19 17:29:05 +01:00
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
PSID *Group,
|
1999-02-26 12:11:13 +01:00
|
|
|
LPBOOL GroupDefaulted)
|
1999-02-19 17:29:05 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
BOOLEAN defaulted;
|
|
|
|
BOOL ret = set_ntstatus( RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, &defaulted ));
|
|
|
|
*GroupDefaulted = defaulted;
|
|
|
|
return ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetSecurityDescriptorGroup [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
PSID Group, BOOL GroupDefaulted)
|
1999-01-26 11:11:22 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
|
1999-01-26 11:11:22 +01:00
|
|
|
}
|
1997-10-12 18:30:17 +02:00
|
|
|
|
1999-01-30 13:54:32 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* IsValidSecurityDescriptor [ADVAPI32.@]
|
1999-01-30 13:54:32 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-02-19 17:29:05 +01:00
|
|
|
* lpsecdesc []
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-02-19 17:29:05 +01:00
|
|
|
IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
|
1997-08-24 18:00:30 +02:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlValidSecurityDescriptor(SecurityDescriptor));
|
1999-02-19 17:29:05 +01:00
|
|
|
}
|
1997-02-15 15:29:56 +01:00
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSecurityDescriptorDacl [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI GetSecurityDescriptorDacl(
|
1999-02-19 17:29:05 +01:00
|
|
|
IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
1999-02-26 12:11:13 +01:00
|
|
|
OUT LPBOOL lpbDaclPresent,
|
1999-02-19 17:29:05 +01:00
|
|
|
OUT PACL *pDacl,
|
1999-02-26 12:11:13 +01:00
|
|
|
OUT LPBOOL lpbDaclDefaulted)
|
1999-02-19 17:29:05 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
BOOLEAN present, defaulted;
|
|
|
|
BOOL ret = set_ntstatus( RtlGetDaclSecurityDescriptor(pSecurityDescriptor, &present, pDacl, &defaulted));
|
|
|
|
*lpbDaclPresent = present;
|
|
|
|
*lpbDaclDefaulted = defaulted;
|
|
|
|
return ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1997-02-15 15:29:56 +01:00
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetSecurityDescriptorDacl [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI
|
1999-03-09 18:43:44 +01:00
|
|
|
SetSecurityDescriptorDacl (
|
|
|
|
PSECURITY_DESCRIPTOR lpsd,
|
|
|
|
BOOL daclpresent,
|
|
|
|
PACL dacl,
|
|
|
|
BOOL dacldefaulted )
|
1999-02-19 17:29:05 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ) );
|
1999-03-09 18:43:44 +01:00
|
|
|
}
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSecurityDescriptorSacl [ADVAPI32.@]
|
1999-03-09 18:43:44 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetSecurityDescriptorSacl(
|
|
|
|
IN PSECURITY_DESCRIPTOR lpsd,
|
|
|
|
OUT LPBOOL lpbSaclPresent,
|
|
|
|
OUT PACL *pSacl,
|
|
|
|
OUT LPBOOL lpbSaclDefaulted)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
BOOLEAN present, defaulted;
|
|
|
|
BOOL ret = set_ntstatus( RtlGetSaclSecurityDescriptor(lpsd, &present, pSacl, &defaulted) );
|
|
|
|
*lpbSaclPresent = present;
|
|
|
|
*lpbSaclDefaulted = defaulted;
|
|
|
|
return ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-03-09 18:43:44 +01:00
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/**************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetSecurityDescriptorSacl [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
BOOL WINAPI SetSecurityDescriptorSacl (
|
1999-02-19 17:29:05 +01:00
|
|
|
PSECURITY_DESCRIPTOR lpsd,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL saclpresent,
|
1999-03-09 18:43:44 +01:00
|
|
|
PACL lpsacl,
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL sacldefaulted)
|
1999-02-19 17:29:05 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* MakeSelfRelativeSD [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
1999-02-19 17:29:05 +01:00
|
|
|
* lpabssecdesc []
|
|
|
|
* lpselfsecdesc []
|
|
|
|
* lpbuflen []
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
MakeSelfRelativeSD(
|
|
|
|
IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
|
|
|
|
IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
|
|
|
|
IN OUT LPDWORD lpdwBufferLength)
|
1997-08-24 18:00:30 +02:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlMakeSelfRelativeSD( pAbsoluteSecurityDescriptor,
|
|
|
|
pSelfRelativeSecurityDescriptor, lpdwBufferLength));
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetSecurityDescriptorControl [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
|
|
|
|
1999-07-04 13:01:21 +02:00
|
|
|
BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-19 17:29:05 +01:00
|
|
|
|
2007-10-23 16:19:00 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* SetSecurityDescriptorControl [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetSecurityDescriptorControl( PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet )
|
|
|
|
{
|
|
|
|
return set_ntstatus( RtlSetControlSecurityDescriptor(
|
|
|
|
pSecurityDescriptor, ControlBitsOfInterest, ControlBitsToSet ) );
|
|
|
|
}
|
|
|
|
|
2015-06-24 02:35:27 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetWindowsAccountDomainSid [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetWindowsAccountDomainSid( PSID sid, PSID domain_sid, DWORD *size )
|
|
|
|
{
|
|
|
|
SID_IDENTIFIER_AUTHORITY domain_ident = { SECURITY_NT_AUTHORITY };
|
|
|
|
DWORD required_size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
FIXME( "(%p %p %p): semi-stub\n", sid, domain_sid, size );
|
|
|
|
|
|
|
|
if (!sid || !IsValidSid( sid ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_SID );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*GetSidSubAuthorityCount( sid ) < 4)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_SID );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
required_size = GetSidLengthRequired( 4 );
|
|
|
|
if (*size < required_size || !domain_sid)
|
|
|
|
{
|
|
|
|
*size = required_size;
|
|
|
|
SetLastError( domain_sid ? ERROR_INSUFFICIENT_BUFFER :
|
|
|
|
ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitializeSid( domain_sid, &domain_ident, 4 );
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
*GetSidSubAuthority( domain_sid, i ) = *GetSidSubAuthority( sid, i );
|
|
|
|
|
|
|
|
*size = required_size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/* ##############################
|
|
|
|
###### ACL FUNCTIONS ######
|
|
|
|
##############################
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* InitializeAcl [ADVAPI32.@]
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOL WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus( RtlCreateAcl(acl, size, rev));
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI ImpersonateNamedPipeClient( HANDLE hNamedPipe )
|
|
|
|
{
|
2007-09-13 15:03:20 +02:00
|
|
|
IO_STATUS_BLOCK io_block;
|
|
|
|
|
2005-06-24 13:54:15 +02:00
|
|
|
TRACE("(%p)\n", hNamedPipe);
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
|
2007-09-13 15:03:20 +02:00
|
|
|
return set_ntstatus( NtFsControlFile(hNamedPipe, NULL, NULL, NULL,
|
|
|
|
&io_block, FSCTL_PIPE_IMPERSONATE, NULL, 0, NULL, 0) );
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
}
|
|
|
|
|
2003-05-01 02:29:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AddAccessAllowedAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAccessAllowedAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
|
2003-06-16 21:44:06 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AddAccessAllowedAceEx [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAccessAllowedAceEx(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AceFlags,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlAddAccessAllowedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
|
2003-06-16 21:44:06 +02:00
|
|
|
}
|
|
|
|
|
2003-05-01 02:29:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AddAccessDeniedAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAccessDeniedAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlAddAccessDeniedAce(pAcl, dwAceRevision, AccessMask, pSid));
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-06-16 21:44:06 +02:00
|
|
|
* AddAccessDeniedAceEx [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAccessDeniedAceEx(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD AceFlags,
|
|
|
|
IN DWORD AccessMask,
|
|
|
|
IN PSID pSid)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlAddAccessDeniedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
|
2003-06-16 21:44:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddAce [ADVAPI32.@]
|
2003-05-01 02:29:26 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAce(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwStartingAceIndex,
|
|
|
|
LPVOID pAceList,
|
|
|
|
DWORD nAceListLength)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, pAceList, nAceListLength));
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
|
2013-01-22 22:52:09 +01:00
|
|
|
BOOL WINAPI AddMandatoryAce(ACL *acl, DWORD ace_revision, DWORD ace_flags, DWORD mandatory_policy, PSID label_sid)
|
|
|
|
{
|
|
|
|
FIXME("%p %x %x %x %p - stub\n", acl, ace_revision, ace_flags, mandatory_policy, label_sid);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* DeleteAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteAce(PACL pAcl, DWORD dwAceIndex)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlDeleteAce(pAcl, dwAceIndex));
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
2003-05-01 02:29:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* FindFirstFreeAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FindFirstFreeAce(IN PACL pAcl, LPVOID * pAce)
|
|
|
|
{
|
|
|
|
return RtlFirstFreeAce(pAcl, (PACE_HEADER *)pAce);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlGetAce(pAcl, dwAceIndex, pAce));
|
2003-05-01 02:29:26 +02:00
|
|
|
}
|
|
|
|
|
2003-06-16 21:44:06 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetAclInformation [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetAclInformation(
|
|
|
|
PACL pAcl,
|
|
|
|
LPVOID pAclInformation,
|
|
|
|
DWORD nAclInformationLength,
|
|
|
|
ACL_INFORMATION_CLASS dwAclInformationClass)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(RtlQueryInformationAcl(pAcl, pAclInformation,
|
|
|
|
nAclInformationLength, dwAclInformationClass));
|
2003-06-16 21:44:06 +02:00
|
|
|
}
|
|
|
|
|
2003-05-01 02:29:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* IsValidAcl [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsValidAcl(IN PACL pAcl)
|
|
|
|
{
|
|
|
|
return RtlValidAcl(pAcl);
|
|
|
|
}
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/* ##############################
|
|
|
|
###### MISC FUNCTIONS ######
|
|
|
|
##############################
|
|
|
|
*/
|
|
|
|
|
2004-11-04 05:52:17 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* AllocateLocallyUniqueId [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpLuid []
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AllocateLocallyUniqueId( PLUID lpLuid )
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus(NtAllocateLocallyUniqueId(lpLuid));
|
2004-11-04 05:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR SE_CREATE_TOKEN_NAME_W[] =
|
|
|
|
{ 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME_W[] =
|
|
|
|
{ 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_LOCK_MEMORY_NAME_W[] =
|
|
|
|
{ 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_INCREASE_QUOTA_NAME_W[] =
|
|
|
|
{ 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_MACHINE_ACCOUNT_NAME_W[] =
|
|
|
|
{ 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_TCB_NAME_W[] =
|
|
|
|
{ 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_SECURITY_NAME_W[] =
|
|
|
|
{ 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_TAKE_OWNERSHIP_NAME_W[] =
|
|
|
|
{ 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_LOAD_DRIVER_NAME_W[] =
|
|
|
|
{ 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_SYSTEM_PROFILE_NAME_W[] =
|
|
|
|
{ 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_SYSTEMTIME_NAME_W[] =
|
|
|
|
{ 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_PROF_SINGLE_PROCESS_NAME_W[] =
|
|
|
|
{ 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_INC_BASE_PRIORITY_NAME_W[] =
|
|
|
|
{ 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_CREATE_PAGEFILE_NAME_W[] =
|
|
|
|
{ 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_CREATE_PERMANENT_NAME_W[] =
|
|
|
|
{ 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_BACKUP_NAME_W[] =
|
|
|
|
{ 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_RESTORE_NAME_W[] =
|
|
|
|
{ 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_SHUTDOWN_NAME_W[] =
|
|
|
|
{ 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_DEBUG_NAME_W[] =
|
|
|
|
{ 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_AUDIT_NAME_W[] =
|
|
|
|
{ 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME_W[] =
|
|
|
|
{ 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_CHANGE_NOTIFY_NAME_W[] =
|
|
|
|
{ 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_REMOTE_SHUTDOWN_NAME_W[] =
|
|
|
|
{ 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_UNDOCK_NAME_W[] =
|
|
|
|
{ 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_SYNC_AGENT_NAME_W[] =
|
|
|
|
{ 'S','e','S','y','n','c','A','g','e','n','t','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_ENABLE_DELEGATION_NAME_W[] =
|
|
|
|
{ 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_MANAGE_VOLUME_NAME_W[] =
|
|
|
|
{ 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_IMPERSONATE_NAME_W[] =
|
|
|
|
{ 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
static const WCHAR SE_CREATE_GLOBAL_NAME_W[] =
|
|
|
|
{ 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
|
|
|
|
|
|
|
|
static const WCHAR * const WellKnownPrivNames[SE_MAX_WELL_KNOWN_PRIVILEGE + 1] =
|
|
|
|
{
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SE_CREATE_TOKEN_NAME_W,
|
|
|
|
SE_ASSIGNPRIMARYTOKEN_NAME_W,
|
|
|
|
SE_LOCK_MEMORY_NAME_W,
|
|
|
|
SE_INCREASE_QUOTA_NAME_W,
|
|
|
|
SE_MACHINE_ACCOUNT_NAME_W,
|
|
|
|
SE_TCB_NAME_W,
|
|
|
|
SE_SECURITY_NAME_W,
|
|
|
|
SE_TAKE_OWNERSHIP_NAME_W,
|
|
|
|
SE_LOAD_DRIVER_NAME_W,
|
|
|
|
SE_SYSTEM_PROFILE_NAME_W,
|
|
|
|
SE_SYSTEMTIME_NAME_W,
|
|
|
|
SE_PROF_SINGLE_PROCESS_NAME_W,
|
|
|
|
SE_INC_BASE_PRIORITY_NAME_W,
|
|
|
|
SE_CREATE_PAGEFILE_NAME_W,
|
|
|
|
SE_CREATE_PERMANENT_NAME_W,
|
|
|
|
SE_BACKUP_NAME_W,
|
|
|
|
SE_RESTORE_NAME_W,
|
|
|
|
SE_SHUTDOWN_NAME_W,
|
|
|
|
SE_DEBUG_NAME_W,
|
|
|
|
SE_AUDIT_NAME_W,
|
|
|
|
SE_SYSTEM_ENVIRONMENT_NAME_W,
|
|
|
|
SE_CHANGE_NOTIFY_NAME_W,
|
|
|
|
SE_REMOTE_SHUTDOWN_NAME_W,
|
|
|
|
SE_UNDOCK_NAME_W,
|
|
|
|
SE_SYNC_AGENT_NAME_W,
|
|
|
|
SE_ENABLE_DELEGATION_NAME_W,
|
|
|
|
SE_MANAGE_VOLUME_NAME_W,
|
|
|
|
SE_IMPERSONATE_NAME_W,
|
|
|
|
SE_CREATE_GLOBAL_NAME_W,
|
2003-07-24 02:01:16 +02:00
|
|
|
};
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* LookupPrivilegeValueW [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* See LookupPrivilegeValueA.
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-12-17 00:48:04 +01:00
|
|
|
LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, PLUID lpLuid )
|
1997-08-24 18:00:30 +02:00
|
|
|
{
|
2003-07-24 02:01:16 +02:00
|
|
|
UINT i;
|
|
|
|
|
|
|
|
TRACE("%s,%s,%p\n",debugstr_w(lpSystemName), debugstr_w(lpName), lpLuid);
|
|
|
|
|
2004-11-04 05:52:17 +01:00
|
|
|
if (!ADVAPI_IsLocalComputer(lpSystemName))
|
2003-07-24 02:01:16 +02:00
|
|
|
{
|
2004-11-04 05:52:17 +01:00
|
|
|
SetLastError(RPC_S_SERVER_UNAVAILABLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!lpName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NO_SUCH_PRIVILEGE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-11-10 09:47:29 +01:00
|
|
|
for( i=SE_MIN_WELL_KNOWN_PRIVILEGE; i<=SE_MAX_WELL_KNOWN_PRIVILEGE; i++ )
|
2004-11-04 05:52:17 +01:00
|
|
|
{
|
|
|
|
if( !WellKnownPrivNames[i] )
|
2003-07-24 02:01:16 +02:00
|
|
|
continue;
|
2004-11-04 05:52:17 +01:00
|
|
|
if( strcmpiW( WellKnownPrivNames[i], lpName) )
|
2003-07-24 02:01:16 +02:00
|
|
|
continue;
|
|
|
|
lpLuid->LowPart = i;
|
|
|
|
lpLuid->HighPart = 0;
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE( "%s -> %08x-%08x\n",debugstr_w( lpSystemName ),
|
2003-07-24 02:01:16 +02:00
|
|
|
lpLuid->HighPart, lpLuid->LowPart );
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-11-04 05:52:17 +01:00
|
|
|
SetLastError(ERROR_NO_SUCH_PRIVILEGE);
|
2003-07-24 02:01:16 +02:00
|
|
|
return FALSE;
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* LookupPrivilegeValueA [ADVAPI32.@]
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Retrieves LUID used on a system to represent the privilege name.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpSystemName [I] Name of the system
|
|
|
|
* lpName [I] Name of the privilege
|
2004-04-23 23:32:34 +02:00
|
|
|
* lpLuid [O] Destination for the resulting LUID
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-04-23 23:32:34 +02:00
|
|
|
* Success: TRUE. lpLuid contains the requested LUID.
|
2003-03-18 19:35:48 +01:00
|
|
|
* Failure: FALSE.
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-12-17 00:48:04 +01:00
|
|
|
LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid )
|
1997-08-24 18:00:30 +02:00
|
|
|
{
|
2003-01-21 00:23:12 +01:00
|
|
|
UNICODE_STRING lpSystemNameW;
|
|
|
|
UNICODE_STRING lpNameW;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
2003-01-21 00:23:12 +01:00
|
|
|
RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&lpNameW,lpName);
|
|
|
|
ret = LookupPrivilegeValueW(lpSystemNameW.Buffer, lpNameW.Buffer, lpLuid);
|
|
|
|
RtlFreeUnicodeString(&lpNameW);
|
|
|
|
RtlFreeUnicodeString(&lpSystemNameW);
|
1999-02-19 17:29:05 +01:00
|
|
|
return ret;
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI LookupPrivilegeDisplayNameA( LPCSTR lpSystemName, LPCSTR lpName, LPSTR lpDisplayName,
|
|
|
|
LPDWORD cchDisplayName, LPDWORD lpLanguageId )
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s %p %p - stub\n", debugstr_a(lpSystemName), debugstr_a(lpName),
|
|
|
|
debugstr_a(lpDisplayName), cchDisplayName, lpLanguageId);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI LookupPrivilegeDisplayNameW( LPCWSTR lpSystemName, LPCWSTR lpName, LPWSTR lpDisplayName,
|
|
|
|
LPDWORD cchDisplayName, LPDWORD lpLanguageId )
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s %p %p - stub\n", debugstr_w(lpSystemName), debugstr_w(lpName),
|
|
|
|
debugstr_w(lpDisplayName), cchDisplayName, lpLanguageId);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-24 02:01:16 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* LookupPrivilegeNameA [ADVAPI32.@]
|
2004-11-04 05:52:17 +01:00
|
|
|
*
|
2005-11-04 12:43:27 +01:00
|
|
|
* See LookupPrivilegeNameW.
|
2003-07-24 02:01:16 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2004-11-04 05:52:17 +01:00
|
|
|
LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName,
|
|
|
|
LPDWORD cchName)
|
2003-07-24 02:01:16 +02:00
|
|
|
{
|
2004-11-04 05:52:17 +01:00
|
|
|
UNICODE_STRING lpSystemNameW;
|
|
|
|
BOOL ret;
|
|
|
|
DWORD wLen = 0;
|
|
|
|
|
|
|
|
TRACE("%s %p %p %p\n", debugstr_a(lpSystemName), lpLuid, lpName, cchName);
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
|
|
|
|
ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, NULL, &wLen);
|
|
|
|
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
2014-08-27 13:48:17 +02:00
|
|
|
LPWSTR lpNameW = heap_alloc(wLen * sizeof(WCHAR));
|
2004-11-04 05:52:17 +01:00
|
|
|
|
|
|
|
ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, lpNameW,
|
|
|
|
&wLen);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
/* Windows crashes if cchName is NULL, so will I */
|
2007-09-21 22:17:23 +02:00
|
|
|
unsigned int len = WideCharToMultiByte(CP_ACP, 0, lpNameW, -1, lpName,
|
2004-11-04 05:52:17 +01:00
|
|
|
*cchName, NULL, NULL);
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
/* WideCharToMultiByte failed */
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else if (len > *cchName)
|
|
|
|
{
|
|
|
|
*cchName = len;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* WideCharToMultiByte succeeded, output length needs to be
|
|
|
|
* length not including NULL terminator
|
|
|
|
*/
|
|
|
|
*cchName = len - 1;
|
|
|
|
}
|
|
|
|
}
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(lpNameW);
|
2004-11-04 05:52:17 +01:00
|
|
|
}
|
|
|
|
RtlFreeUnicodeString(&lpSystemNameW);
|
|
|
|
return ret;
|
2003-07-24 02:01:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* LookupPrivilegeNameW [ADVAPI32.@]
|
2004-11-04 05:52:17 +01:00
|
|
|
*
|
|
|
|
* Retrieves the privilege name referred to by the LUID lpLuid.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpSystemName [I] Name of the system
|
|
|
|
* lpLuid [I] Privilege value
|
|
|
|
* lpName [O] Name of the privilege
|
|
|
|
* cchName [I/O] Number of characters in lpName.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. lpName contains the name of the privilege whose value is
|
|
|
|
* *lpLuid.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*
|
|
|
|
* REMARKS
|
|
|
|
* Only well-known privilege names (those defined in winnt.h) can be retrieved
|
|
|
|
* using this function.
|
|
|
|
* If the length of lpName is too small, on return *cchName will contain the
|
|
|
|
* number of WCHARs needed to contain the privilege, including the NULL
|
|
|
|
* terminator, and GetLastError will return ERROR_INSUFFICIENT_BUFFER.
|
|
|
|
* On success, *cchName will contain the number of characters stored in
|
|
|
|
* lpName, NOT including the NULL terminator.
|
2003-07-24 02:01:16 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
2004-11-04 05:52:17 +01:00
|
|
|
LookupPrivilegeNameW( LPCWSTR lpSystemName, PLUID lpLuid, LPWSTR lpName,
|
|
|
|
LPDWORD cchName)
|
2003-07-24 02:01:16 +02:00
|
|
|
{
|
2004-11-04 05:52:17 +01:00
|
|
|
size_t privNameLen;
|
|
|
|
|
|
|
|
TRACE("%s,%p,%p,%p\n",debugstr_w(lpSystemName), lpLuid, lpName, cchName);
|
|
|
|
|
|
|
|
if (!ADVAPI_IsLocalComputer(lpSystemName))
|
|
|
|
{
|
|
|
|
SetLastError(RPC_S_SERVER_UNAVAILABLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (lpLuid->HighPart || (lpLuid->LowPart < SE_MIN_WELL_KNOWN_PRIVILEGE ||
|
|
|
|
lpLuid->LowPart > SE_MAX_WELL_KNOWN_PRIVILEGE))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NO_SUCH_PRIVILEGE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
privNameLen = strlenW(WellKnownPrivNames[lpLuid->LowPart]);
|
|
|
|
/* Windows crashes if cchName is NULL, so will I */
|
|
|
|
if (*cchName <= privNameLen)
|
|
|
|
{
|
|
|
|
*cchName = privNameLen + 1;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpyW(lpName, WellKnownPrivNames[lpLuid->LowPart]);
|
|
|
|
*cchName = privNameLen;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-07-24 02:01:16 +02:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetFileSecurityA [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Obtains Specified information about the security of a file or directory.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpFileName [I] Name of the file to get info for
|
|
|
|
* RequestedInformation [I] SE_ flags from "winnt.h"
|
|
|
|
* pSecurityDescriptor [O] Destination for security information
|
|
|
|
* nLength [I] Length of pSecurityDescriptor
|
|
|
|
* lpnLengthNeeded [O] Destination for length of returned security information
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. pSecurityDescriptor contains the requested information.
|
|
|
|
* Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The information returned is constrained by the callers access rights and
|
|
|
|
* privileges.
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-06-01 01:06:46 +02:00
|
|
|
GetFileSecurityA( LPCSTR lpFileName,
|
1999-02-19 17:29:05 +01:00
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
DWORD nLength, LPDWORD lpnLengthNeeded )
|
1997-08-24 18:00:30 +02:00
|
|
|
{
|
2004-08-17 01:18:23 +02:00
|
|
|
BOOL r;
|
2012-09-13 22:54:37 +02:00
|
|
|
LPWSTR name;
|
2004-08-17 01:18:23 +02:00
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
name = SERV_dup(lpFileName);
|
2004-08-17 01:18:23 +02:00
|
|
|
r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor,
|
|
|
|
nLength, lpnLengthNeeded );
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( name );
|
2004-08-17 01:18:23 +02:00
|
|
|
|
|
|
|
return r;
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
|
|
|
|
1999-01-03 13:48:29 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* GetFileSecurityW [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* See GetFileSecurityA.
|
1997-02-15 15:29:56 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-06-01 01:06:46 +02:00
|
|
|
GetFileSecurityW( LPCWSTR lpFileName,
|
1999-02-19 17:29:05 +01:00
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
DWORD nLength, LPDWORD lpnLengthNeeded )
|
1999-01-28 14:46:25 +01:00
|
|
|
{
|
2007-04-21 11:12:36 +02:00
|
|
|
HANDLE hfile;
|
|
|
|
NTSTATUS status;
|
2015-03-27 11:11:31 +01:00
|
|
|
DWORD access = 0, err;
|
2005-03-05 11:46:34 +01:00
|
|
|
|
2008-11-03 21:42:45 +01:00
|
|
|
TRACE("(%s,%d,%p,%d,%p)\n", debugstr_w(lpFileName),
|
|
|
|
RequestedInformation, pSecurityDescriptor,
|
|
|
|
nLength, lpnLengthNeeded);
|
|
|
|
|
2007-10-02 16:56:35 +02:00
|
|
|
if (RequestedInformation & (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|
|
|
|
|
DACL_SECURITY_INFORMATION))
|
|
|
|
access |= READ_CONTROL;
|
|
|
|
if (RequestedInformation & SACL_SECURITY_INFORMATION)
|
|
|
|
access |= ACCESS_SYSTEM_SECURITY;
|
|
|
|
|
2015-03-27 11:11:31 +01:00
|
|
|
err = get_security_file( lpFileName, access, &hfile);
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
SetLastError(err);
|
2005-03-29 13:31:18 +02:00
|
|
|
return FALSE;
|
2015-03-27 11:11:31 +01:00
|
|
|
}
|
2005-03-29 13:31:18 +02:00
|
|
|
|
2007-04-21 11:12:36 +02:00
|
|
|
status = NtQuerySecurityObject( hfile, RequestedInformation, pSecurityDescriptor,
|
|
|
|
nLength, lpnLengthNeeded );
|
|
|
|
CloseHandle( hfile );
|
|
|
|
return set_ntstatus( status );
|
1997-02-15 15:29:56 +01:00
|
|
|
}
|
1997-11-30 18:45:40 +01:00
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* LookupAccountSidA [ADVAPI32.@]
|
1997-11-30 18:45:40 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
LookupAccountSidA(
|
|
|
|
IN LPCSTR system,
|
|
|
|
IN PSID sid,
|
|
|
|
OUT LPSTR account,
|
|
|
|
IN OUT LPDWORD accountSize,
|
|
|
|
OUT LPSTR domain,
|
|
|
|
IN OUT LPDWORD domainSize,
|
|
|
|
OUT PSID_NAME_USE name_use )
|
|
|
|
{
|
2006-07-20 13:05:46 +02:00
|
|
|
DWORD len;
|
|
|
|
BOOL r;
|
2012-09-13 22:54:37 +02:00
|
|
|
LPWSTR systemW;
|
2006-07-20 13:05:46 +02:00
|
|
|
LPWSTR accountW = NULL;
|
|
|
|
LPWSTR domainW = NULL;
|
2006-08-19 15:16:05 +02:00
|
|
|
DWORD accountSizeW = *accountSize;
|
|
|
|
DWORD domainSizeW = *domainSize;
|
2006-07-20 13:05:46 +02:00
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
systemW = SERV_dup(system);
|
2006-08-19 15:16:05 +02:00
|
|
|
if (account)
|
2014-08-27 13:48:17 +02:00
|
|
|
accountW = heap_alloc( accountSizeW * sizeof(WCHAR) );
|
2006-08-19 15:16:05 +02:00
|
|
|
if (domain)
|
2014-08-27 13:48:17 +02:00
|
|
|
domainW = heap_alloc( domainSizeW * sizeof(WCHAR) );
|
2006-07-20 13:05:46 +02:00
|
|
|
|
2006-08-19 15:16:05 +02:00
|
|
|
r = LookupAccountSidW( systemW, sid, accountW, &accountSizeW, domainW, &domainSizeW, name_use );
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2006-07-20 13:05:46 +02:00
|
|
|
if (r) {
|
2006-08-19 15:16:05 +02:00
|
|
|
if (accountW && *accountSize) {
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, accountW, -1, NULL, 0, NULL, NULL );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, accountW, -1, account, len, NULL, NULL );
|
|
|
|
*accountSize = len;
|
|
|
|
} else
|
2006-08-26 00:14:58 +02:00
|
|
|
*accountSize = accountSizeW + 1;
|
2006-08-19 15:16:05 +02:00
|
|
|
|
|
|
|
if (domainW && *domainSize) {
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, domainW, -1, NULL, 0, NULL, NULL );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, domainW, -1, domain, len, NULL, NULL );
|
|
|
|
*domainSize = len;
|
|
|
|
} else
|
2006-08-26 00:14:58 +02:00
|
|
|
*domainSize = domainSizeW + 1;
|
2006-07-20 13:05:46 +02:00
|
|
|
}
|
2010-09-21 12:54:50 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*accountSize = accountSizeW + 1;
|
|
|
|
*domainSize = domainSizeW + 1;
|
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( systemW );
|
|
|
|
heap_free( accountW );
|
|
|
|
heap_free( domainW );
|
2006-07-20 13:05:46 +02:00
|
|
|
|
|
|
|
return r;
|
1997-11-30 18:45:40 +01:00
|
|
|
}
|
|
|
|
|
1999-01-28 14:46:25 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* LookupAccountSidW [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* system []
|
|
|
|
* sid []
|
|
|
|
* account []
|
|
|
|
* accountSize []
|
|
|
|
* domain []
|
|
|
|
* domainSize []
|
|
|
|
* name_use []
|
|
|
|
*/
|
2006-07-20 13:05:46 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
LookupAccountSidW(
|
|
|
|
IN LPCWSTR system,
|
|
|
|
IN PSID sid,
|
|
|
|
OUT LPWSTR account,
|
|
|
|
IN OUT LPDWORD accountSize,
|
|
|
|
OUT LPWSTR domain,
|
|
|
|
IN OUT LPDWORD domainSize,
|
|
|
|
OUT PSID_NAME_USE name_use )
|
|
|
|
{
|
2007-09-21 22:17:23 +02:00
|
|
|
unsigned int i, j;
|
2006-07-31 13:09:21 +02:00
|
|
|
const WCHAR * ac = NULL;
|
|
|
|
const WCHAR * dm = NULL;
|
|
|
|
SID_NAME_USE use = 0;
|
|
|
|
LPWSTR computer_name = NULL;
|
2008-10-18 22:53:24 +02:00
|
|
|
LPWSTR account_name = NULL;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("(%s,sid=%s,%p,%p(%u),%p,%p(%u),%p)\n",
|
2006-07-20 13:05:46 +02:00
|
|
|
debugstr_w(system),debugstr_sid(sid),
|
|
|
|
account,accountSize,accountSize?*accountSize:0,
|
|
|
|
domain,domainSize,domainSize?*domainSize:0,
|
|
|
|
name_use);
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2006-07-20 13:05:46 +02:00
|
|
|
if (!ADVAPI_IsLocalComputer(system)) {
|
|
|
|
FIXME("Only local computer supported!\n");
|
2008-10-18 23:09:14 +02:00
|
|
|
SetLastError(RPC_S_SERVER_UNAVAILABLE);
|
2006-07-20 13:05:46 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-07-31 13:09:21 +02:00
|
|
|
|
|
|
|
/* check the well known SIDs first */
|
2015-08-26 08:44:45 +02:00
|
|
|
for (i = 0; i <= WinAccountProtectedUsersSid; i++) {
|
2006-07-20 13:05:46 +02:00
|
|
|
if (IsWellKnownSid(sid, i)) {
|
|
|
|
for (j = 0; j < (sizeof(ACCOUNT_SIDS) / sizeof(ACCOUNT_SIDS[0])); j++) {
|
|
|
|
if (ACCOUNT_SIDS[j].type == i) {
|
|
|
|
ac = ACCOUNT_SIDS[j].account;
|
|
|
|
dm = ACCOUNT_SIDS[j].domain;
|
|
|
|
use = ACCOUNT_SIDS[j].name_use;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-31 13:09:21 +02:00
|
|
|
if (dm == NULL) {
|
|
|
|
MAX_SID local;
|
|
|
|
|
|
|
|
/* check for the local computer next */
|
|
|
|
if (ADVAPI_GetComputerSid(&local)) {
|
|
|
|
DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
|
|
|
|
BOOL result;
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
computer_name = heap_alloc(size * sizeof(WCHAR));
|
2006-07-31 13:09:21 +02:00
|
|
|
result = GetComputerNameW(computer_name, &size);
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (EqualSid(sid, &local)) {
|
|
|
|
dm = computer_name;
|
|
|
|
ac = Blank;
|
|
|
|
use = 3;
|
2006-08-12 14:00:34 +02:00
|
|
|
} else {
|
|
|
|
local.SubAuthorityCount++;
|
|
|
|
|
|
|
|
if (EqualPrefixSid(sid, &local)) {
|
|
|
|
dm = computer_name;
|
|
|
|
use = 1;
|
|
|
|
switch (((MAX_SID *)sid)->SubAuthority[4]) {
|
|
|
|
case DOMAIN_USER_RID_ADMIN:
|
|
|
|
ac = Administrator;
|
|
|
|
break;
|
|
|
|
case DOMAIN_USER_RID_GUEST:
|
|
|
|
ac = Guest;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_ADMINS:
|
|
|
|
ac = Domain_Admins;
|
|
|
|
break;
|
2006-08-26 00:14:58 +02:00
|
|
|
case DOMAIN_GROUP_RID_USERS:
|
2006-08-12 14:00:34 +02:00
|
|
|
ac = Domain_Users;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_GUESTS:
|
|
|
|
ac = Domain_Guests;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_COMPUTERS:
|
|
|
|
ac = Domain_Computers;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_CONTROLLERS:
|
|
|
|
ac = Domain_Controllers;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_CERT_ADMINS:
|
|
|
|
ac = Cert_Publishers;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_SCHEMA_ADMINS:
|
|
|
|
ac = Schema_Admins;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_ENTERPRISE_ADMINS:
|
|
|
|
ac = Enterprise_Admins;
|
|
|
|
break;
|
|
|
|
case DOMAIN_GROUP_RID_POLICY_ADMINS:
|
|
|
|
ac = Group_Policy_Creator_Owners;
|
|
|
|
break;
|
|
|
|
case DOMAIN_ALIAS_RID_RAS_SERVERS:
|
|
|
|
ac = RAS_and_IAS_Servers;
|
2008-10-18 22:53:24 +02:00
|
|
|
break;
|
|
|
|
case 1000: /* first user account */
|
|
|
|
size = UNLEN + 1;
|
2014-08-27 13:48:17 +02:00
|
|
|
account_name = heap_alloc(size * sizeof(WCHAR));
|
2008-10-18 22:53:24 +02:00
|
|
|
if (GetUserNameW(account_name, &size))
|
|
|
|
ac = account_name;
|
|
|
|
else
|
|
|
|
dm = NULL;
|
|
|
|
|
2006-08-12 14:00:34 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dm = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-07-31 13:09:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dm) {
|
2008-07-21 23:12:04 +02:00
|
|
|
DWORD ac_len = lstrlenW(ac);
|
|
|
|
DWORD dm_len = lstrlenW(dm);
|
2006-08-19 15:16:05 +02:00
|
|
|
BOOL status = TRUE;
|
2008-07-21 23:12:04 +02:00
|
|
|
|
|
|
|
if (*accountSize > ac_len) {
|
2006-08-19 15:16:05 +02:00
|
|
|
if (account)
|
|
|
|
lstrcpyW(account, ac);
|
|
|
|
}
|
2008-07-21 23:12:04 +02:00
|
|
|
if (*domainSize > dm_len) {
|
2006-08-19 15:16:05 +02:00
|
|
|
if (domain)
|
|
|
|
lstrcpyW(domain, dm);
|
|
|
|
}
|
2010-09-21 12:54:50 +02:00
|
|
|
if ((*accountSize && *accountSize < ac_len) ||
|
|
|
|
(!account && !*accountSize && ac_len) ||
|
|
|
|
(*domainSize && *domainSize < dm_len) ||
|
|
|
|
(!domain && !*domainSize && dm_len))
|
|
|
|
{
|
2006-08-26 00:14:58 +02:00
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
2006-08-19 15:16:05 +02:00
|
|
|
status = FALSE;
|
|
|
|
}
|
2006-08-26 00:14:58 +02:00
|
|
|
if (*domainSize)
|
2008-07-21 23:12:04 +02:00
|
|
|
*domainSize = dm_len;
|
2006-08-26 00:14:58 +02:00
|
|
|
else
|
2008-07-21 23:12:04 +02:00
|
|
|
*domainSize = dm_len + 1;
|
2006-08-26 00:14:58 +02:00
|
|
|
if (*accountSize)
|
2008-07-21 23:12:04 +02:00
|
|
|
*accountSize = ac_len;
|
2006-08-26 00:14:58 +02:00
|
|
|
else
|
2008-07-21 23:12:04 +02:00
|
|
|
*accountSize = ac_len + 1;
|
2010-09-21 12:54:50 +02:00
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(account_name);
|
|
|
|
heap_free(computer_name);
|
2010-09-21 12:54:50 +02:00
|
|
|
if (status) *name_use = use;
|
2006-08-19 15:16:05 +02:00
|
|
|
return status;
|
2006-07-31 13:09:21 +02:00
|
|
|
}
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(account_name);
|
|
|
|
heap_free(computer_name);
|
2006-07-31 13:09:21 +02:00
|
|
|
SetLastError(ERROR_NONE_MAPPED);
|
|
|
|
return FALSE;
|
1997-11-30 18:45:40 +01:00
|
|
|
}
|
|
|
|
|
1999-01-03 13:48:29 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetFileSecurityA [ADVAPI32.@]
|
2005-11-04 12:43:27 +01:00
|
|
|
*
|
|
|
|
* See SetFileSecurityW.
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
|
1999-01-03 13:48:29 +01:00
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
1999-02-12 18:47:07 +01:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
2004-08-17 01:18:23 +02:00
|
|
|
BOOL r;
|
2012-09-13 22:54:37 +02:00
|
|
|
LPWSTR name;
|
2004-08-17 01:18:23 +02:00
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
name = SERV_dup(lpFileName);
|
2004-08-17 01:18:23 +02:00
|
|
|
r = SetFileSecurityW( name, RequestedInformation, pSecurityDescriptor );
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( name );
|
2004-08-17 01:18:23 +02:00
|
|
|
|
|
|
|
return r;
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetFileSecurityW [ADVAPI32.@]
|
2005-11-04 12:43:27 +01:00
|
|
|
*
|
|
|
|
* Sets the security of a file or directory.
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpFileName []
|
|
|
|
* RequestedInformation []
|
|
|
|
* pSecurityDescriptor []
|
2005-11-04 12:43:27 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
1999-01-28 14:46:25 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2002-06-01 01:06:46 +02:00
|
|
|
SetFileSecurityW( LPCWSTR lpFileName,
|
1999-01-28 14:46:25 +01:00
|
|
|
SECURITY_INFORMATION RequestedInformation,
|
1999-02-12 18:47:07 +01:00
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor )
|
1999-01-03 13:48:29 +01:00
|
|
|
{
|
2007-10-02 17:34:42 +02:00
|
|
|
HANDLE file;
|
2015-03-27 11:11:31 +01:00
|
|
|
DWORD access = 0, err;
|
2007-10-02 17:34:42 +02:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("(%s, 0x%x, %p)\n", debugstr_w(lpFileName), RequestedInformation,
|
|
|
|
pSecurityDescriptor );
|
|
|
|
|
|
|
|
if (RequestedInformation & OWNER_SECURITY_INFORMATION ||
|
|
|
|
RequestedInformation & GROUP_SECURITY_INFORMATION)
|
|
|
|
access |= WRITE_OWNER;
|
|
|
|
if (RequestedInformation & SACL_SECURITY_INFORMATION)
|
|
|
|
access |= ACCESS_SYSTEM_SECURITY;
|
|
|
|
if (RequestedInformation & DACL_SECURITY_INFORMATION)
|
|
|
|
access |= WRITE_DAC;
|
|
|
|
|
2015-03-27 11:11:31 +01:00
|
|
|
err = get_security_file( lpFileName, access, &file);
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
SetLastError(err);
|
2007-10-02 17:34:42 +02:00
|
|
|
return FALSE;
|
2015-03-27 11:11:31 +01:00
|
|
|
}
|
2007-10-02 17:34:42 +02:00
|
|
|
|
|
|
|
status = NtSetSecurityObject( file, RequestedInformation, pSecurityDescriptor );
|
|
|
|
CloseHandle( file );
|
|
|
|
return set_ntstatus( status );
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
1999-01-28 14:46:25 +01:00
|
|
|
|
1999-01-03 13:48:29 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* QueryWindows31FilesMigration [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* x1 []
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-01-28 14:46:25 +01:00
|
|
|
QueryWindows31FilesMigration( DWORD x1 )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("(%d):stub\n",x1);
|
1999-01-03 13:48:29 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* x1 []
|
|
|
|
* x2 []
|
|
|
|
* x3 []
|
|
|
|
* x4 []
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-01-28 14:46:25 +01:00
|
|
|
SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
|
|
|
|
DWORD x4 )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("(0x%08x,0x%08x,0x%08x,0x%08x):stub\n",x1,x2,x3,x4);
|
1999-01-03 13:48:29 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* NotifyBootConfigStatus [ADVAPI32.@]
|
1999-01-28 14:46:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* x1 []
|
1999-01-03 13:48:29 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
2005-11-21 13:06:00 +01:00
|
|
|
NotifyBootConfigStatus( BOOL x1 )
|
1999-01-28 14:46:25 +01:00
|
|
|
{
|
2005-11-21 13:06:00 +01:00
|
|
|
FIXME("(0x%08d):stub\n",x1);
|
2014-01-29 22:25:44 +01:00
|
|
|
return TRUE;
|
1999-01-03 13:48:29 +01:00
|
|
|
}
|
1999-01-26 11:11:22 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* RevertToSelf [ADVAPI32.@]
|
1999-01-30 13:54:32 +01:00
|
|
|
*
|
2005-06-20 13:44:45 +02:00
|
|
|
* Ends the impersonation of a user.
|
|
|
|
*
|
1999-01-30 13:54:32 +01:00
|
|
|
* PARAMS
|
|
|
|
* void []
|
2005-06-20 13:44:45 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
1999-01-26 11:11:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-01-30 13:54:32 +01:00
|
|
|
RevertToSelf( void )
|
|
|
|
{
|
2005-06-20 13:44:45 +02:00
|
|
|
HANDLE Token = NULL;
|
|
|
|
return set_ntstatus( NtSetInformationThread( GetCurrentThread(),
|
|
|
|
ThreadImpersonationToken, &Token, sizeof(Token) ) );
|
1999-01-26 11:11:22 +01:00
|
|
|
}
|
1999-02-10 07:39:51 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* ImpersonateSelf [ADVAPI32.@]
|
2005-06-20 13:44:45 +02:00
|
|
|
*
|
|
|
|
* Makes an impersonation token that represents the process user and assigns
|
|
|
|
* to the current thread.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ImpersonationLevel [I] Level at which to impersonate.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
1999-02-10 07:39:51 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
1999-07-04 13:01:21 +02:00
|
|
|
ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
1999-02-10 07:39:51 +01:00
|
|
|
{
|
2005-06-20 13:44:45 +02:00
|
|
|
return set_ntstatus( RtlImpersonateSelf( ImpersonationLevel ) );
|
1999-02-10 07:39:51 +01:00
|
|
|
}
|
|
|
|
|
2002-04-03 21:53:31 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* ImpersonateLoggedOnUser [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
|
|
|
|
{
|
2006-07-06 04:55:02 +02:00
|
|
|
DWORD size;
|
2006-04-26 16:43:54 +02:00
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE ImpersonationToken;
|
2006-07-06 04:55:02 +02:00
|
|
|
TOKEN_TYPE Type;
|
2008-10-15 05:43:23 +02:00
|
|
|
static BOOL warn = TRUE;
|
2006-04-26 16:43:54 +02:00
|
|
|
|
2008-10-15 05:43:23 +02:00
|
|
|
if (warn)
|
|
|
|
{
|
|
|
|
FIXME( "(%p)\n", hToken );
|
|
|
|
warn = FALSE;
|
|
|
|
}
|
2006-07-06 04:55:02 +02:00
|
|
|
if (!GetTokenInformation( hToken, TokenType, &Type,
|
|
|
|
sizeof(TOKEN_TYPE), &size ))
|
|
|
|
return FALSE;
|
2006-04-26 16:43:54 +02:00
|
|
|
|
|
|
|
if (Type == TokenPrimary)
|
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
|
|
|
|
InitializeObjectAttributes( &ObjectAttributes, NULL, 0, NULL, NULL );
|
|
|
|
|
|
|
|
Status = NtDuplicateToken( hToken,
|
|
|
|
TOKEN_IMPERSONATE | TOKEN_QUERY,
|
|
|
|
&ObjectAttributes,
|
|
|
|
SecurityImpersonation,
|
|
|
|
TokenImpersonation,
|
|
|
|
&ImpersonationToken );
|
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
ERR( "NtDuplicateToken failed with error 0x%08x\n", Status );
|
2006-04-26 16:43:54 +02:00
|
|
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ImpersonationToken = hToken;
|
|
|
|
|
|
|
|
Status = NtSetInformationThread( GetCurrentThread(),
|
|
|
|
ThreadImpersonationToken,
|
|
|
|
&ImpersonationToken,
|
|
|
|
sizeof(ImpersonationToken) );
|
|
|
|
|
|
|
|
if (Type == TokenPrimary)
|
|
|
|
NtClose( ImpersonationToken );
|
|
|
|
|
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
ERR( "NtSetInformationThread failed with error 0x%08x\n", Status );
|
2006-04-26 16:43:54 +02:00
|
|
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2002-04-03 21:53:31 +02:00
|
|
|
}
|
|
|
|
|
2015-05-21 06:43:29 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* ImpersonateAnonymousToken [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ImpersonateAnonymousToken( HANDLE thread )
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", thread);
|
|
|
|
return set_ntstatus( NtImpersonateAnonymousToken( thread ) );
|
|
|
|
}
|
|
|
|
|
1999-02-19 17:29:05 +01:00
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* AccessCheck [ADVAPI32.@]
|
1999-02-19 17:29:05 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
AccessCheck(
|
|
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
HANDLE ClientToken,
|
|
|
|
DWORD DesiredAccess,
|
|
|
|
PGENERIC_MAPPING GenericMapping,
|
|
|
|
PPRIVILEGE_SET PrivilegeSet,
|
|
|
|
LPDWORD PrivilegeSetLength,
|
|
|
|
LPDWORD GrantedAccess,
|
|
|
|
LPBOOL AccessStatus)
|
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
NTSTATUS access_status;
|
|
|
|
BOOL ret = set_ntstatus( NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
|
|
|
|
GenericMapping, PrivilegeSet, PrivilegeSetLength,
|
|
|
|
GrantedAccess, &access_status) );
|
|
|
|
if (ret) *AccessStatus = set_ntstatus( access_status );
|
|
|
|
return ret;
|
1999-02-10 07:39:51 +01:00
|
|
|
}
|
1999-07-10 12:17:27 +02:00
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AccessCheckByType [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AccessCheckByType(
|
|
|
|
PSECURITY_DESCRIPTOR pSecurityDescriptor,
|
|
|
|
PSID PrincipalSelfSid,
|
|
|
|
HANDLE ClientToken,
|
|
|
|
DWORD DesiredAccess,
|
|
|
|
POBJECT_TYPE_LIST ObjectTypeList,
|
|
|
|
DWORD ObjectTypeListLength,
|
|
|
|
PGENERIC_MAPPING GenericMapping,
|
|
|
|
PPRIVILEGE_SET PrivilegeSet,
|
|
|
|
LPDWORD PrivilegeSetLength,
|
|
|
|
LPDWORD GrantedAccess,
|
|
|
|
LPBOOL AccessStatus)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
|
|
|
|
*AccessStatus = TRUE;
|
|
|
|
|
|
|
|
return !*AccessStatus;
|
|
|
|
}
|
|
|
|
|
2005-06-20 13:44:45 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* MapGenericMask [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Maps generic access rights into specific access rights according to the
|
|
|
|
* supplied mapping.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* AccessMask [I/O] Access rights.
|
|
|
|
* GenericMapping [I] The mapping between generic and specific rights.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
VOID WINAPI MapGenericMask( PDWORD AccessMask, PGENERIC_MAPPING GenericMapping )
|
|
|
|
{
|
2005-06-20 13:44:45 +02:00
|
|
|
RtlMapGenericMask( AccessMask, GenericMapping );
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
1999-07-10 12:17:27 +02:00
|
|
|
/*************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* SetKernelObjectSecurity [ADVAPI32.@]
|
1999-07-10 12:17:27 +02:00
|
|
|
*/
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
BOOL WINAPI SetKernelObjectSecurity (
|
|
|
|
IN HANDLE Handle,
|
|
|
|
IN SECURITY_INFORMATION SecurityInformation,
|
|
|
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor )
|
1999-07-10 12:17:27 +02:00
|
|
|
{
|
2004-12-22 16:31:16 +01:00
|
|
|
return set_ntstatus (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
|
1999-07-10 12:17:27 +02:00
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddAuditAccessAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAuditAccessAce(
|
2005-06-23 13:03:52 +02:00
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN PSID pSid,
|
|
|
|
IN BOOL bAuditSuccess,
|
|
|
|
IN BOOL bAuditFailure)
|
|
|
|
{
|
|
|
|
return set_ntstatus( RtlAddAuditAccessAce(pAcl, dwAceRevision, dwAccessMask, pSid,
|
|
|
|
bAuditSuccess, bAuditFailure) );
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
2007-09-25 02:30:30 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AddAuditAccessAce [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddAuditAccessAceEx(
|
|
|
|
IN OUT PACL pAcl,
|
|
|
|
IN DWORD dwAceRevision,
|
|
|
|
IN DWORD dwAceFlags,
|
|
|
|
IN DWORD dwAccessMask,
|
|
|
|
IN PSID pSid,
|
|
|
|
IN BOOL bAuditSuccess,
|
|
|
|
IN BOOL bAuditFailure)
|
|
|
|
{
|
|
|
|
return set_ntstatus( RtlAddAuditAccessAceEx(pAcl, dwAceRevision, dwAceFlags, dwAccessMask, pSid,
|
|
|
|
bAuditSuccess, bAuditFailure) );
|
|
|
|
}
|
|
|
|
|
2000-10-15 02:23:56 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* LookupAccountNameA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
LookupAccountNameA(
|
|
|
|
IN LPCSTR system,
|
|
|
|
IN LPCSTR account,
|
|
|
|
OUT PSID sid,
|
|
|
|
OUT LPDWORD cbSid,
|
|
|
|
LPSTR ReferencedDomainName,
|
|
|
|
IN OUT LPDWORD cbReferencedDomainName,
|
|
|
|
OUT PSID_NAME_USE name_use )
|
2006-02-21 20:17:24 +01:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
UNICODE_STRING lpSystemW;
|
|
|
|
UNICODE_STRING lpAccountW;
|
|
|
|
LPWSTR lpReferencedDomainNameW = NULL;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&lpSystemW, system);
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&lpAccountW, account);
|
|
|
|
|
|
|
|
if (ReferencedDomainName)
|
2014-08-27 13:48:17 +02:00
|
|
|
lpReferencedDomainNameW = heap_alloc(*cbReferencedDomainName * sizeof(WCHAR));
|
2006-02-21 20:17:24 +01:00
|
|
|
|
|
|
|
ret = LookupAccountNameW(lpSystemW.Buffer, lpAccountW.Buffer, sid, cbSid, lpReferencedDomainNameW,
|
|
|
|
cbReferencedDomainName, name_use);
|
|
|
|
|
|
|
|
if (ret && lpReferencedDomainNameW)
|
|
|
|
{
|
2008-10-18 21:46:35 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpReferencedDomainNameW, -1,
|
|
|
|
ReferencedDomainName, *cbReferencedDomainName+1, NULL, NULL);
|
2006-02-21 20:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&lpSystemW);
|
|
|
|
RtlFreeUnicodeString(&lpAccountW);
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(lpReferencedDomainNameW);
|
2006-02-21 20:17:24 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-02-04 22:20:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* lookup_user_account_name
|
|
|
|
*/
|
|
|
|
static BOOL lookup_user_account_name(PSID Sid, PDWORD cbSid, LPWSTR ReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
|
|
|
|
{
|
2009-10-06 16:49:22 +02:00
|
|
|
char buffer[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD)*SID_MAX_SUB_AUTHORITIES];
|
|
|
|
DWORD len = sizeof(buffer);
|
|
|
|
HANDLE token;
|
2009-02-04 22:20:39 +01:00
|
|
|
BOOL ret;
|
|
|
|
PSID pSid;
|
2010-12-10 12:53:25 +01:00
|
|
|
WCHAR domainName[MAX_COMPUTERNAME_LENGTH + 1];
|
2009-02-04 22:20:39 +01:00
|
|
|
DWORD nameLen;
|
|
|
|
|
2009-10-06 16:49:22 +02:00
|
|
|
if (!OpenThreadToken(GetCurrentThread(), TOKEN_READ, TRUE, &token))
|
2009-02-04 22:20:39 +01:00
|
|
|
{
|
2009-10-06 16:49:22 +02:00
|
|
|
if (GetLastError() != ERROR_NO_TOKEN) return FALSE;
|
|
|
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token)) return FALSE;
|
2009-02-04 22:20:39 +01:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:49:22 +02:00
|
|
|
ret = GetTokenInformation(token, TokenUser, buffer, len, &len);
|
|
|
|
CloseHandle( token );
|
|
|
|
|
|
|
|
if (!ret) return FALSE;
|
|
|
|
|
|
|
|
pSid = ((TOKEN_USER *)buffer)->User.Sid;
|
|
|
|
|
2009-02-04 22:20:39 +01:00
|
|
|
if (Sid != NULL && (*cbSid >= GetLengthSid(pSid)))
|
|
|
|
CopySid(*cbSid, Sid, pSid);
|
|
|
|
if (*cbSid < GetLengthSid(pSid))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
*cbSid = GetLengthSid(pSid);
|
|
|
|
|
2010-12-10 12:53:25 +01:00
|
|
|
nameLen = MAX_COMPUTERNAME_LENGTH + 1;
|
|
|
|
if (!GetComputerNameW(domainName, &nameLen))
|
|
|
|
{
|
|
|
|
domainName[0] = 0;
|
|
|
|
nameLen = 0;
|
|
|
|
}
|
2009-02-04 22:20:39 +01:00
|
|
|
if (*cchReferencedDomainName <= nameLen || !ret)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
nameLen += 1;
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else if (ReferencedDomainName)
|
|
|
|
strcpyW(ReferencedDomainName, domainName);
|
|
|
|
|
|
|
|
*cchReferencedDomainName = nameLen;
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
*peUse = SidTypeUser;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* lookup_computer_account_name
|
|
|
|
*/
|
|
|
|
static BOOL lookup_computer_account_name(PSID Sid, PDWORD cbSid, LPWSTR ReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
|
|
|
|
{
|
|
|
|
MAX_SID local;
|
|
|
|
BOOL ret;
|
2010-12-10 12:53:25 +01:00
|
|
|
WCHAR domainName[MAX_COMPUTERNAME_LENGTH + 1];
|
2009-02-04 22:20:39 +01:00
|
|
|
DWORD nameLen;
|
|
|
|
|
|
|
|
if ((ret = ADVAPI_GetComputerSid(&local)))
|
|
|
|
{
|
|
|
|
if (Sid != NULL && (*cbSid >= GetLengthSid(&local)))
|
|
|
|
CopySid(*cbSid, Sid, &local);
|
|
|
|
if (*cbSid < GetLengthSid(&local))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
*cbSid = GetLengthSid(&local);
|
|
|
|
}
|
|
|
|
|
2010-12-10 12:53:25 +01:00
|
|
|
nameLen = MAX_COMPUTERNAME_LENGTH + 1;
|
|
|
|
if (!GetComputerNameW(domainName, &nameLen))
|
|
|
|
{
|
|
|
|
domainName[0] = 0;
|
|
|
|
nameLen = 0;
|
|
|
|
}
|
2009-02-04 22:20:39 +01:00
|
|
|
if (*cchReferencedDomainName <= nameLen || !ret)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
nameLen += 1;
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else if (ReferencedDomainName)
|
|
|
|
strcpyW(ReferencedDomainName, domainName);
|
|
|
|
|
|
|
|
*cchReferencedDomainName = nameLen;
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
*peUse = SidTypeDomain;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
static void split_domain_account( const LSA_UNICODE_STRING *str, LSA_UNICODE_STRING *account,
|
|
|
|
LSA_UNICODE_STRING *domain )
|
2000-10-15 02:23:56 +02:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
WCHAR *p = str->Buffer + str->Length / sizeof(WCHAR) - 1;
|
2004-09-07 22:41:35 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
while (p > str->Buffer && *p != '\\') p--;
|
2004-09-07 22:41:35 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
if (*p == '\\')
|
2008-10-18 23:09:14 +02:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
domain->Buffer = str->Buffer;
|
|
|
|
domain->Length = (p - str->Buffer) * sizeof(WCHAR);
|
2008-10-18 23:09:14 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
account->Buffer = p + 1;
|
|
|
|
account->Length = str->Length - ((p - str->Buffer + 1) * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
else
|
2008-10-18 22:40:21 +02:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
domain->Buffer = NULL;
|
|
|
|
domain->Length = 0;
|
|
|
|
|
|
|
|
account->Buffer = str->Buffer;
|
|
|
|
account->Length = str->Length;
|
2008-10-18 22:40:21 +02:00
|
|
|
}
|
2009-08-06 11:12:51 +02:00
|
|
|
}
|
2008-10-18 22:40:21 +02:00
|
|
|
|
2010-07-25 23:06:07 +02:00
|
|
|
static BOOL match_domain( ULONG idx, const LSA_UNICODE_STRING *domain )
|
2009-08-06 11:12:51 +02:00
|
|
|
{
|
|
|
|
ULONG len = strlenW( ACCOUNT_SIDS[idx].domain );
|
|
|
|
|
|
|
|
if (len == domain->Length / sizeof(WCHAR) && !strncmpiW( domain->Buffer, ACCOUNT_SIDS[idx].domain, len ))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-07-25 23:06:07 +02:00
|
|
|
static BOOL match_account( ULONG idx, const LSA_UNICODE_STRING *account )
|
2009-08-06 11:12:51 +02:00
|
|
|
{
|
|
|
|
ULONG len = strlenW( ACCOUNT_SIDS[idx].account );
|
|
|
|
|
|
|
|
if (len == account->Length / sizeof(WCHAR) && !strncmpiW( account->Buffer, ACCOUNT_SIDS[idx].account, len ))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (ACCOUNT_SIDS[idx].alias)
|
2009-03-31 16:00:11 +02:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
len = strlenW( ACCOUNT_SIDS[idx].alias );
|
|
|
|
if (len == account->Length / sizeof(WCHAR) && !strncmpiW( account->Buffer, ACCOUNT_SIDS[idx].alias, len ))
|
|
|
|
return TRUE;
|
2009-03-31 16:00:11 +02:00
|
|
|
}
|
2009-08-06 11:12:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-10-18 23:09:14 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
/*
|
|
|
|
* Helper function for LookupAccountNameW
|
|
|
|
*/
|
2010-07-26 22:54:20 +02:00
|
|
|
BOOL lookup_local_wellknown_name( const LSA_UNICODE_STRING *account_and_domain,
|
2009-08-06 11:12:51 +02:00
|
|
|
PSID Sid, LPDWORD cbSid,
|
|
|
|
LPWSTR ReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName,
|
|
|
|
PSID_NAME_USE peUse, BOOL *handled )
|
|
|
|
{
|
|
|
|
PSID pSid;
|
|
|
|
LSA_UNICODE_STRING account, domain;
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
*handled = FALSE;
|
|
|
|
split_domain_account( account_and_domain, &account, &domain );
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(ACCOUNT_SIDS) / sizeof(ACCOUNT_SIDS[0]); i++)
|
2008-01-22 16:37:01 +01:00
|
|
|
{
|
2009-03-31 16:00:11 +02:00
|
|
|
/* check domain first */
|
2009-08-06 11:12:51 +02:00
|
|
|
if (domain.Buffer && !match_domain( i, &domain )) continue;
|
2009-03-31 16:00:11 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
if (match_account( i, &account ))
|
2008-01-22 16:37:01 +01:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
DWORD len, sidLen = SECURITY_MAX_SID_SIZE;
|
2008-10-18 22:28:39 +02:00
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
if (!(pSid = heap_alloc( sidLen ))) return FALSE;
|
2008-10-18 22:28:39 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
if ((ret = CreateWellKnownSid( ACCOUNT_SIDS[i].type, NULL, pSid, &sidLen )))
|
2008-10-18 22:28:39 +02:00
|
|
|
{
|
|
|
|
if (*cbSid < sidLen)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else if (Sid)
|
|
|
|
{
|
|
|
|
CopySid(*cbSid, Sid, pSid);
|
|
|
|
}
|
|
|
|
*cbSid = sidLen;
|
|
|
|
}
|
2008-10-18 21:51:58 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
len = strlenW( ACCOUNT_SIDS[i].domain );
|
|
|
|
if (*cchReferencedDomainName <= len || !ret)
|
2008-10-18 21:51:58 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
2009-08-06 11:12:51 +02:00
|
|
|
len++;
|
2008-10-18 21:51:58 +02:00
|
|
|
ret = FALSE;
|
|
|
|
}
|
2009-02-09 08:52:42 +01:00
|
|
|
else if (ReferencedDomainName)
|
2008-10-18 21:51:58 +02:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
strcpyW( ReferencedDomainName, ACCOUNT_SIDS[i].domain );
|
2008-10-18 21:51:58 +02:00
|
|
|
}
|
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
*cchReferencedDomainName = len;
|
2008-10-18 21:51:58 +02:00
|
|
|
if (ret)
|
|
|
|
*peUse = ACCOUNT_SIDS[i].name_use;
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(pSid);
|
2009-08-06 11:12:51 +02:00
|
|
|
*handled = TRUE;
|
2008-10-18 21:51:58 +02:00
|
|
|
return ret;
|
2008-01-22 16:37:01 +01:00
|
|
|
}
|
|
|
|
}
|
2009-08-06 11:12:51 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-07-26 22:54:20 +02:00
|
|
|
BOOL lookup_local_user_name( const LSA_UNICODE_STRING *account_and_domain,
|
2009-08-06 11:12:51 +02:00
|
|
|
PSID Sid, LPDWORD cbSid,
|
|
|
|
LPWSTR ReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName,
|
|
|
|
PSID_NAME_USE peUse, BOOL *handled )
|
|
|
|
{
|
|
|
|
DWORD nameLen;
|
|
|
|
LPWSTR userName = NULL;
|
|
|
|
LSA_UNICODE_STRING account, domain;
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
|
|
|
*handled = FALSE;
|
|
|
|
split_domain_account( account_and_domain, &account, &domain );
|
2008-01-22 16:37:01 +01:00
|
|
|
|
2008-10-18 23:09:14 +02:00
|
|
|
/* Let the current Unix user id masquerade as first Windows user account */
|
|
|
|
|
|
|
|
nameLen = UNLEN + 1;
|
2014-08-27 13:48:17 +02:00
|
|
|
if (!(userName = heap_alloc( nameLen * sizeof(WCHAR) ))) return FALSE;
|
2008-10-18 23:09:14 +02:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
if (domain.Buffer)
|
2009-05-18 21:47:36 +02:00
|
|
|
{
|
|
|
|
/* check to make sure this account is on this computer */
|
2009-08-06 11:12:51 +02:00
|
|
|
if (GetComputerNameW( userName, &nameLen ) &&
|
|
|
|
(domain.Length / sizeof(WCHAR) != nameLen || strncmpW( domain.Buffer, userName, nameLen )))
|
2009-05-18 21:47:36 +02:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_NONE_MAPPED);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2009-05-27 21:31:10 +02:00
|
|
|
nameLen = UNLEN + 1;
|
2009-05-18 21:47:36 +02:00
|
|
|
}
|
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
if (GetUserNameW( userName, &nameLen ) &&
|
|
|
|
account.Length / sizeof(WCHAR) == nameLen - 1 && !strncmpW( account.Buffer, userName, nameLen - 1 ))
|
|
|
|
{
|
|
|
|
ret = lookup_user_account_name( Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse );
|
|
|
|
*handled = TRUE;
|
|
|
|
}
|
2009-02-04 22:20:39 +01:00
|
|
|
else
|
2008-10-18 23:09:14 +02:00
|
|
|
{
|
2009-02-04 22:20:39 +01:00
|
|
|
nameLen = UNLEN + 1;
|
2009-08-06 11:12:51 +02:00
|
|
|
if (GetComputerNameW( userName, &nameLen ) &&
|
|
|
|
account.Length / sizeof(WCHAR) == nameLen && !strncmpW( account.Buffer, userName , nameLen ))
|
2009-02-04 22:20:39 +01:00
|
|
|
{
|
2009-08-06 11:12:51 +02:00
|
|
|
ret = lookup_computer_account_name( Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse );
|
|
|
|
*handled = TRUE;
|
2009-02-04 22:20:39 +01:00
|
|
|
}
|
2008-10-18 23:09:14 +02:00
|
|
|
}
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(userName);
|
2004-09-07 22:41:35 +02:00
|
|
|
return ret;
|
2000-10-15 02:23:56 +02:00
|
|
|
}
|
2002-01-31 21:44:02 +01:00
|
|
|
|
2009-08-06 11:12:51 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* LookupAccountNameW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID Sid,
|
|
|
|
LPDWORD cbSid, LPWSTR ReferencedDomainName,
|
|
|
|
LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
|
|
|
|
{
|
|
|
|
BOOL ret, handled;
|
|
|
|
LSA_UNICODE_STRING account;
|
|
|
|
|
2010-12-10 12:53:25 +01:00
|
|
|
TRACE("%s %s %p %p %p %p %p\n", debugstr_w(lpSystemName), debugstr_w(lpAccountName),
|
2009-08-06 11:12:51 +02:00
|
|
|
Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse);
|
|
|
|
|
|
|
|
if (!ADVAPI_IsLocalComputer( lpSystemName ))
|
|
|
|
{
|
2010-12-10 12:53:25 +01:00
|
|
|
FIXME("remote computer not supported\n");
|
2009-08-06 11:12:51 +02:00
|
|
|
SetLastError( RPC_S_SERVER_UNAVAILABLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lpAccountName || !strcmpW( lpAccountName, Blank ))
|
|
|
|
{
|
|
|
|
lpAccountName = BUILTIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlInitUnicodeString( &account, lpAccountName );
|
|
|
|
|
|
|
|
/* Check well known SIDs first */
|
|
|
|
ret = lookup_local_wellknown_name( &account, Sid, cbSid, ReferencedDomainName,
|
|
|
|
cchReferencedDomainName, peUse, &handled );
|
|
|
|
if (handled)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Check user names */
|
|
|
|
ret = lookup_local_user_name( &account, Sid, cbSid, ReferencedDomainName,
|
|
|
|
cchReferencedDomainName, peUse, &handled);
|
|
|
|
if (handled)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
SetLastError( ERROR_NONE_MAPPED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-04-19 02:04:27 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PrivilegeCheck [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI PrivilegeCheck( HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
|
|
|
|
{
|
2005-04-22 23:17:42 +02:00
|
|
|
BOOL ret;
|
|
|
|
BOOLEAN Result;
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", ClientToken, RequiredPrivileges, pfResult);
|
|
|
|
|
|
|
|
ret = set_ntstatus (NtPrivilegeCheck (ClientToken, RequiredPrivileges, &Result));
|
|
|
|
if (ret)
|
|
|
|
*pfResult = Result;
|
|
|
|
return ret;
|
2002-04-19 02:04:27 +02:00
|
|
|
}
|
2002-12-19 05:15:23 +01:00
|
|
|
|
2003-05-11 04:37:11 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AccessCheckAndAuditAlarmA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AccessCheckAndAuditAlarmA(LPCSTR Subsystem, LPVOID HandleId, LPSTR ObjectTypeName,
|
|
|
|
LPSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
|
|
|
|
PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
|
|
|
|
LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("stub (%s,%p,%s,%s,%p,%08x,%p,%x,%p,%p,%p)\n", debugstr_a(Subsystem),
|
2003-05-11 04:37:11 +02:00
|
|
|
HandleId, debugstr_a(ObjectTypeName), debugstr_a(ObjectName),
|
|
|
|
SecurityDescriptor, DesiredAccess, GenericMapping,
|
|
|
|
ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AccessCheckAndAuditAlarmW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AccessCheckAndAuditAlarmW(LPCWSTR Subsystem, LPVOID HandleId, LPWSTR ObjectTypeName,
|
|
|
|
LPWSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
|
|
|
|
PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
|
|
|
|
LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("stub (%s,%p,%s,%s,%p,%08x,%p,%x,%p,%p,%p)\n", debugstr_w(Subsystem),
|
2003-05-11 04:37:11 +02:00
|
|
|
HandleId, debugstr_w(ObjectTypeName), debugstr_w(ObjectName),
|
|
|
|
SecurityDescriptor, DesiredAccess, GenericMapping,
|
|
|
|
ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI ObjectCloseAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, BOOL GenerateOnClose)
|
|
|
|
{
|
|
|
|
FIXME("stub (%s,%p,%x)\n", debugstr_a(SubsystemName), HandleId, GenerateOnClose);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI ObjectCloseAuditAlarmW(LPCWSTR SubsystemName, LPVOID HandleId, BOOL GenerateOnClose)
|
|
|
|
{
|
|
|
|
FIXME("stub (%s,%p,%x)\n", debugstr_w(SubsystemName), HandleId, GenerateOnClose);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-02 13:19:11 +01:00
|
|
|
BOOL WINAPI ObjectDeleteAuditAlarmW(LPCWSTR SubsystemName, LPVOID HandleId, BOOL GenerateOnClose)
|
|
|
|
{
|
|
|
|
FIXME("stub (%s,%p,%x)\n", debugstr_w(SubsystemName), HandleId, GenerateOnClose);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI ObjectOpenAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, LPSTR ObjectTypeName,
|
|
|
|
LPSTR ObjectName, PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess,
|
|
|
|
DWORD GrantedAccess, PPRIVILEGE_SET Privileges, BOOL ObjectCreation, BOOL AccessGranted,
|
|
|
|
LPBOOL GenerateOnClose)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08x,0x%08x,%p,%x,%x,%p)\n", debugstr_a(SubsystemName),
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
HandleId, debugstr_a(ObjectTypeName), debugstr_a(ObjectName), pSecurityDescriptor,
|
|
|
|
ClientToken, DesiredAccess, GrantedAccess, Privileges, ObjectCreation, AccessGranted,
|
|
|
|
GenerateOnClose);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI ObjectOpenAuditAlarmW(LPCWSTR SubsystemName, LPVOID HandleId, LPWSTR ObjectTypeName,
|
|
|
|
LPWSTR ObjectName, PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess,
|
|
|
|
DWORD GrantedAccess, PPRIVILEGE_SET Privileges, BOOL ObjectCreation, BOOL AccessGranted,
|
|
|
|
LPBOOL GenerateOnClose)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08x,0x%08x,%p,%x,%x,%p)\n", debugstr_w(SubsystemName),
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
HandleId, debugstr_w(ObjectTypeName), debugstr_w(ObjectName), pSecurityDescriptor,
|
|
|
|
ClientToken, DesiredAccess, GrantedAccess, Privileges, ObjectCreation, AccessGranted,
|
|
|
|
GenerateOnClose);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI ObjectPrivilegeAuditAlarmA( LPCSTR SubsystemName, LPVOID HandleId, HANDLE ClientToken,
|
|
|
|
DWORD DesiredAccess, PPRIVILEGE_SET Privileges, BOOL AccessGranted)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("stub (%s,%p,%p,0x%08x,%p,%x)\n", debugstr_a(SubsystemName), HandleId, ClientToken,
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
DesiredAccess, Privileges, AccessGranted);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI ObjectPrivilegeAuditAlarmW( LPCWSTR SubsystemName, LPVOID HandleId, HANDLE ClientToken,
|
|
|
|
DWORD DesiredAccess, PPRIVILEGE_SET Privileges, BOOL AccessGranted)
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("stub (%s,%p,%p,0x%08x,%p,%x)\n", debugstr_w(SubsystemName), HandleId, ClientToken,
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
DesiredAccess, Privileges, AccessGranted);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI PrivilegedServiceAuditAlarmA( LPCSTR SubsystemName, LPCSTR ServiceName, HANDLE ClientToken,
|
|
|
|
PPRIVILEGE_SET Privileges, BOOL AccessGranted)
|
|
|
|
{
|
|
|
|
FIXME("stub (%s,%s,%p,%p,%x)\n", debugstr_a(SubsystemName), debugstr_a(ServiceName),
|
|
|
|
ClientToken, Privileges, AccessGranted);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI PrivilegedServiceAuditAlarmW( LPCWSTR SubsystemName, LPCWSTR ServiceName, HANDLE ClientToken,
|
|
|
|
PPRIVILEGE_SET Privileges, BOOL AccessGranted)
|
|
|
|
{
|
|
|
|
FIXME("stub %s,%s,%p,%p,%x)\n", debugstr_w(SubsystemName), debugstr_w(ServiceName),
|
|
|
|
ClientToken, Privileges, AccessGranted);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-05-11 04:37:11 +02:00
|
|
|
|
2004-08-26 02:29:06 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetSecurityInfo [ADVAPI32.@]
|
2008-08-07 21:54:58 +02:00
|
|
|
*
|
|
|
|
* Retrieves a copy of the security descriptor associated with an object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hObject [I] A handle for the object.
|
|
|
|
* ObjectType [I] The type of object.
|
|
|
|
* SecurityInfo [I] A bitmask indicating what info to retrieve.
|
|
|
|
* ppsidOwner [O] If non-null, receives a pointer to the owner SID.
|
|
|
|
* ppsidGroup [O] If non-null, receives a pointer to the group SID.
|
|
|
|
* ppDacl [O] If non-null, receives a pointer to the DACL.
|
|
|
|
* ppSacl [O] If non-null, receives a pointer to the SACL.
|
|
|
|
* ppSecurityDescriptor [O] Receives a pointer to the security descriptor,
|
|
|
|
* which must be freed with LocalFree.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* ERROR_SUCCESS if all's well, and a WIN32 error code otherwise.
|
2004-08-26 02:29:06 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetSecurityInfo(
|
|
|
|
HANDLE hObject, SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo, PSID *ppsidOwner,
|
|
|
|
PSID *ppsidGroup, PACL *ppDacl, PACL *ppSacl,
|
|
|
|
PSECURITY_DESCRIPTOR *ppSecurityDescriptor
|
|
|
|
)
|
|
|
|
{
|
2008-08-07 21:54:58 +02:00
|
|
|
PSECURITY_DESCRIPTOR sd;
|
|
|
|
NTSTATUS status;
|
|
|
|
ULONG n1, n2;
|
|
|
|
BOOL present, defaulted;
|
|
|
|
|
2012-12-13 22:08:05 +01:00
|
|
|
/* A NULL descriptor is allowed if any one of the other pointers is not NULL */
|
|
|
|
if (!(ppsidOwner||ppsidGroup||ppDacl||ppSacl||ppSecurityDescriptor)) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* If no descriptor, we have to check that there's a pointer for the requested information */
|
|
|
|
if( !ppSecurityDescriptor && (
|
|
|
|
((SecurityInfo & OWNER_SECURITY_INFORMATION) && !ppsidOwner)
|
|
|
|
|| ((SecurityInfo & GROUP_SECURITY_INFORMATION) && !ppsidGroup)
|
|
|
|
|| ((SecurityInfo & DACL_SECURITY_INFORMATION) && !ppDacl)
|
|
|
|
|| ((SecurityInfo & SACL_SECURITY_INFORMATION) && !ppSacl) ))
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
switch (ObjectType)
|
|
|
|
{
|
|
|
|
case SE_SERVICE:
|
|
|
|
status = SERV_QueryServiceObjectSecurity(hObject, SecurityInfo, NULL, 0, &n1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = NtQuerySecurityObject(hObject, SecurityInfo, NULL, 0, &n1);
|
|
|
|
break;
|
|
|
|
}
|
2008-08-07 21:54:58 +02:00
|
|
|
if (status != STATUS_BUFFER_TOO_SMALL && status != STATUS_SUCCESS)
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
|
|
|
|
sd = LocalAlloc(0, n1);
|
|
|
|
if (!sd)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
2012-12-13 22:08:05 +01:00
|
|
|
switch (ObjectType)
|
|
|
|
{
|
|
|
|
case SE_SERVICE:
|
|
|
|
status = SERV_QueryServiceObjectSecurity(hObject, SecurityInfo, sd, n1, &n2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = NtQuerySecurityObject(hObject, SecurityInfo, sd, n1, &n2);
|
|
|
|
break;
|
|
|
|
}
|
2008-08-07 21:54:58 +02:00
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
LocalFree(sd);
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppsidOwner)
|
|
|
|
{
|
|
|
|
*ppsidOwner = NULL;
|
|
|
|
GetSecurityDescriptorOwner(sd, ppsidOwner, &defaulted);
|
|
|
|
}
|
|
|
|
if (ppsidGroup)
|
|
|
|
{
|
|
|
|
*ppsidGroup = NULL;
|
|
|
|
GetSecurityDescriptorGroup(sd, ppsidGroup, &defaulted);
|
|
|
|
}
|
|
|
|
if (ppDacl)
|
|
|
|
{
|
|
|
|
*ppDacl = NULL;
|
|
|
|
GetSecurityDescriptorDacl(sd, &present, ppDacl, &defaulted);
|
|
|
|
}
|
|
|
|
if (ppSacl)
|
|
|
|
{
|
|
|
|
*ppSacl = NULL;
|
|
|
|
GetSecurityDescriptorSacl(sd, &present, ppSacl, &defaulted);
|
|
|
|
}
|
|
|
|
if (ppSecurityDescriptor)
|
|
|
|
*ppSecurityDescriptor = sd;
|
2010-01-14 20:35:09 +01:00
|
|
|
|
|
|
|
/* The security descriptor (sd) cannot be freed if ppSecurityDescriptor is
|
|
|
|
* NULL, because native happily returns the SIDs and ACLs that are requested
|
|
|
|
* in this case.
|
|
|
|
*/
|
2008-08-07 21:54:58 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2004-08-26 02:29:06 +02:00
|
|
|
}
|
|
|
|
|
2009-02-23 20:31:05 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* GetSecurityInfoExA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetSecurityInfoExA(
|
|
|
|
HANDLE hObject, SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo, LPCSTR lpProvider,
|
|
|
|
LPCSTR lpProperty, PACTRL_ACCESSA *ppAccessList,
|
|
|
|
PACTRL_AUDITA *ppAuditList, LPSTR *lppOwner, LPSTR *lppGroup
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FIXME("stub!\n");
|
|
|
|
return ERROR_BAD_PROVIDER;
|
|
|
|
}
|
|
|
|
|
2002-12-19 05:15:23 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* GetSecurityInfoExW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetSecurityInfoExW(
|
|
|
|
HANDLE hObject, SE_OBJECT_TYPE ObjectType,
|
|
|
|
SECURITY_INFORMATION SecurityInfo, LPCWSTR lpProvider,
|
|
|
|
LPCWSTR lpProperty, PACTRL_ACCESSW *ppAccessList,
|
|
|
|
PACTRL_AUDITW *ppAuditList, LPWSTR *lppOwner, LPWSTR *lppGroup
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FIXME("stub!\n");
|
|
|
|
return ERROR_BAD_PROVIDER;
|
|
|
|
}
|
2003-08-11 20:41:28 +02:00
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* BuildExplicitAccessWithNameA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildExplicitAccessWithNameA( PEXPLICIT_ACCESSA pExplicitAccess,
|
|
|
|
LPSTR pTrusteeName, DWORD AccessPermissions,
|
|
|
|
ACCESS_MODE AccessMode, DWORD Inheritance )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("%p %s 0x%08x 0x%08x 0x%08x\n", pExplicitAccess, debugstr_a(pTrusteeName),
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
AccessPermissions, AccessMode, Inheritance);
|
|
|
|
|
|
|
|
pExplicitAccess->grfAccessPermissions = AccessPermissions;
|
|
|
|
pExplicitAccess->grfAccessMode = AccessMode;
|
|
|
|
pExplicitAccess->grfInheritance = Inheritance;
|
|
|
|
|
|
|
|
pExplicitAccess->Trustee.pMultipleTrustee = NULL;
|
|
|
|
pExplicitAccess->Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pExplicitAccess->Trustee.TrusteeForm = TRUSTEE_IS_NAME;
|
|
|
|
pExplicitAccess->Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
|
|
|
|
pExplicitAccess->Trustee.ptstrName = pTrusteeName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BuildExplicitAccessWithNameW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildExplicitAccessWithNameW( PEXPLICIT_ACCESSW pExplicitAccess,
|
|
|
|
LPWSTR pTrusteeName, DWORD AccessPermissions,
|
|
|
|
ACCESS_MODE AccessMode, DWORD Inheritance )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("%p %s 0x%08x 0x%08x 0x%08x\n", pExplicitAccess, debugstr_w(pTrusteeName),
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
AccessPermissions, AccessMode, Inheritance);
|
|
|
|
|
|
|
|
pExplicitAccess->grfAccessPermissions = AccessPermissions;
|
|
|
|
pExplicitAccess->grfAccessMode = AccessMode;
|
|
|
|
pExplicitAccess->grfInheritance = Inheritance;
|
|
|
|
|
|
|
|
pExplicitAccess->Trustee.pMultipleTrustee = NULL;
|
|
|
|
pExplicitAccess->Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pExplicitAccess->Trustee.TrusteeForm = TRUSTEE_IS_NAME;
|
|
|
|
pExplicitAccess->Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
|
|
|
|
pExplicitAccess->Trustee.ptstrName = pTrusteeName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildTrusteeWithObjectsAndNameA( PTRUSTEEA pTrustee, POBJECTS_AND_NAME_A pObjName,
|
|
|
|
SE_OBJECT_TYPE ObjectType, LPSTR ObjectTypeName,
|
|
|
|
LPSTR InheritedObjectTypeName, LPSTR Name )
|
|
|
|
{
|
2006-03-26 13:39:58 +02:00
|
|
|
DWORD ObjectsPresent = 0;
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
TRACE("%p %p 0x%08x %p %p %s\n", pTrustee, pObjName,
|
|
|
|
ObjectType, ObjectTypeName, InheritedObjectTypeName, debugstr_a(Name));
|
|
|
|
|
2006-03-26 13:39:58 +02:00
|
|
|
/* Fill the OBJECTS_AND_NAME structure */
|
|
|
|
pObjName->ObjectType = ObjectType;
|
|
|
|
if (ObjectTypeName != NULL)
|
|
|
|
{
|
|
|
|
ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
pObjName->InheritedObjectTypeName = InheritedObjectTypeName;
|
|
|
|
if (InheritedObjectTypeName != NULL)
|
|
|
|
{
|
|
|
|
ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
pObjName->ObjectsPresent = ObjectsPresent;
|
|
|
|
pObjName->ptstrName = Name;
|
|
|
|
|
|
|
|
/* Fill the TRUSTEE structure */
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_NAME;
|
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
2006-03-28 14:43:18 +02:00
|
|
|
pTrustee->ptstrName = (LPSTR)pObjName;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildTrusteeWithObjectsAndNameW( PTRUSTEEW pTrustee, POBJECTS_AND_NAME_W pObjName,
|
|
|
|
SE_OBJECT_TYPE ObjectType, LPWSTR ObjectTypeName,
|
|
|
|
LPWSTR InheritedObjectTypeName, LPWSTR Name )
|
|
|
|
{
|
2006-03-26 13:39:58 +02:00
|
|
|
DWORD ObjectsPresent = 0;
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
TRACE("%p %p 0x%08x %p %p %s\n", pTrustee, pObjName,
|
|
|
|
ObjectType, ObjectTypeName, InheritedObjectTypeName, debugstr_w(Name));
|
|
|
|
|
2006-03-26 13:39:58 +02:00
|
|
|
/* Fill the OBJECTS_AND_NAME structure */
|
|
|
|
pObjName->ObjectType = ObjectType;
|
|
|
|
if (ObjectTypeName != NULL)
|
|
|
|
{
|
|
|
|
ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
pObjName->InheritedObjectTypeName = InheritedObjectTypeName;
|
|
|
|
if (InheritedObjectTypeName != NULL)
|
|
|
|
{
|
|
|
|
ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
pObjName->ObjectsPresent = ObjectsPresent;
|
|
|
|
pObjName->ptstrName = Name;
|
|
|
|
|
|
|
|
/* Fill the TRUSTEE structure */
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_NAME;
|
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
2006-03-26 13:39:58 +02:00
|
|
|
pTrustee->ptstrName = (LPWSTR)pObjName;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
2006-05-12 00:34:55 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithObjectsAndSidA [ADVAPI32.@]
|
|
|
|
*/
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
VOID WINAPI BuildTrusteeWithObjectsAndSidA( PTRUSTEEA pTrustee, POBJECTS_AND_SID pObjSid,
|
|
|
|
GUID* pObjectGuid, GUID* pInheritedObjectGuid, PSID pSid )
|
|
|
|
{
|
2006-03-26 13:39:58 +02:00
|
|
|
DWORD ObjectsPresent = 0;
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
TRACE("%p %p %p %p %p\n", pTrustee, pObjSid, pObjectGuid, pInheritedObjectGuid, pSid);
|
|
|
|
|
2006-03-26 13:39:58 +02:00
|
|
|
/* Fill the OBJECTS_AND_SID structure */
|
|
|
|
if (pObjectGuid != NULL)
|
|
|
|
{
|
|
|
|
pObjSid->ObjectTypeGuid = *pObjectGuid;
|
|
|
|
ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(&pObjSid->ObjectTypeGuid,
|
|
|
|
sizeof(GUID));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pInheritedObjectGuid != NULL)
|
|
|
|
{
|
|
|
|
pObjSid->InheritedObjectTypeGuid = *pInheritedObjectGuid;
|
|
|
|
ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(&pObjSid->InheritedObjectTypeGuid,
|
|
|
|
sizeof(GUID));
|
|
|
|
}
|
|
|
|
|
|
|
|
pObjSid->ObjectsPresent = ObjectsPresent;
|
|
|
|
pObjSid->pSid = pSid;
|
|
|
|
|
|
|
|
/* Fill the TRUSTEE structure */
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_SID;
|
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
2006-03-26 13:39:58 +02:00
|
|
|
pTrustee->ptstrName = (LPSTR) pObjSid;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
2006-05-12 00:34:55 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithObjectsAndSidW [ADVAPI32.@]
|
|
|
|
*/
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
VOID WINAPI BuildTrusteeWithObjectsAndSidW( PTRUSTEEW pTrustee, POBJECTS_AND_SID pObjSid,
|
|
|
|
GUID* pObjectGuid, GUID* pInheritedObjectGuid, PSID pSid )
|
|
|
|
{
|
2006-03-26 13:39:58 +02:00
|
|
|
DWORD ObjectsPresent = 0;
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
TRACE("%p %p %p %p %p\n", pTrustee, pObjSid, pObjectGuid, pInheritedObjectGuid, pSid);
|
|
|
|
|
2006-03-26 13:39:58 +02:00
|
|
|
/* Fill the OBJECTS_AND_SID structure */
|
|
|
|
if (pObjectGuid != NULL)
|
|
|
|
{
|
|
|
|
pObjSid->ObjectTypeGuid = *pObjectGuid;
|
|
|
|
ObjectsPresent |= ACE_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(&pObjSid->ObjectTypeGuid,
|
|
|
|
sizeof(GUID));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pInheritedObjectGuid != NULL)
|
|
|
|
{
|
|
|
|
pObjSid->InheritedObjectTypeGuid = *pInheritedObjectGuid;
|
|
|
|
ObjectsPresent |= ACE_INHERITED_OBJECT_TYPE_PRESENT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(&pObjSid->InheritedObjectTypeGuid,
|
|
|
|
sizeof(GUID));
|
|
|
|
}
|
|
|
|
|
|
|
|
pObjSid->ObjectsPresent = ObjectsPresent;
|
|
|
|
pObjSid->pSid = pSid;
|
|
|
|
|
|
|
|
/* Fill the TRUSTEE structure */
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_SID;
|
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
2006-03-26 13:39:58 +02:00
|
|
|
pTrustee->ptstrName = (LPWSTR) pObjSid;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
2003-08-11 20:41:28 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithSidA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildTrusteeWithSidA(PTRUSTEEA pTrustee, PSID pSid)
|
|
|
|
{
|
2004-08-16 23:07:50 +02:00
|
|
|
TRACE("%p %p\n", pTrustee, pSid);
|
|
|
|
|
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
2004-08-19 21:01:12 +02:00
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_SID;
|
2004-08-16 23:07:50 +02:00
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
2009-02-16 09:53:37 +01:00
|
|
|
pTrustee->ptstrName = pSid;
|
2003-08-11 20:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithSidW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildTrusteeWithSidW(PTRUSTEEW pTrustee, PSID pSid)
|
|
|
|
{
|
2004-08-16 23:07:50 +02:00
|
|
|
TRACE("%p %p\n", pTrustee, pSid);
|
|
|
|
|
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
2004-08-19 21:01:12 +02:00
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_SID;
|
2004-08-16 23:07:50 +02:00
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
2009-02-16 09:53:37 +01:00
|
|
|
pTrustee->ptstrName = pSid;
|
2003-08-11 20:41:28 +02:00
|
|
|
}
|
2003-08-12 20:53:14 +02:00
|
|
|
|
2004-08-19 21:01:12 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithNameA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildTrusteeWithNameA(PTRUSTEEA pTrustee, LPSTR name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", pTrustee, debugstr_a(name) );
|
|
|
|
|
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_NAME;
|
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
|
|
|
pTrustee->ptstrName = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BuildTrusteeWithNameW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
VOID WINAPI BuildTrusteeWithNameW(PTRUSTEEW pTrustee, LPWSTR name)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", pTrustee, debugstr_w(name) );
|
|
|
|
|
|
|
|
pTrustee->pMultipleTrustee = NULL;
|
|
|
|
pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
|
|
|
|
pTrustee->TrusteeForm = TRUSTEE_IS_NAME;
|
|
|
|
pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
|
|
|
|
pTrustee->ptstrName = name;
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:20:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetTrusteeFormA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
TRUSTEE_FORM WINAPI GetTrusteeFormA(PTRUSTEEA pTrustee)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pTrustee);
|
|
|
|
|
|
|
|
if (!pTrustee)
|
|
|
|
return TRUSTEE_BAD_FORM;
|
|
|
|
|
|
|
|
return pTrustee->TrusteeForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetTrusteeFormW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
TRUSTEE_FORM WINAPI GetTrusteeFormW(PTRUSTEEW pTrustee)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pTrustee);
|
|
|
|
|
|
|
|
if (!pTrustee)
|
|
|
|
return TRUSTEE_BAD_FORM;
|
|
|
|
|
|
|
|
return pTrustee->TrusteeForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetTrusteeNameA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI GetTrusteeNameA(PTRUSTEEA pTrustee)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pTrustee);
|
|
|
|
|
|
|
|
if (!pTrustee)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pTrustee->ptstrName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetTrusteeNameW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI GetTrusteeNameW(PTRUSTEEW pTrustee)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pTrustee);
|
|
|
|
|
|
|
|
if (!pTrustee)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pTrustee->ptstrName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetTrusteeTypeA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
TRUSTEE_TYPE WINAPI GetTrusteeTypeA(PTRUSTEEA pTrustee)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pTrustee);
|
|
|
|
|
|
|
|
if (!pTrustee)
|
|
|
|
return TRUSTEE_IS_UNKNOWN;
|
|
|
|
|
|
|
|
return pTrustee->TrusteeType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetTrusteeTypeW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
TRUSTEE_TYPE WINAPI GetTrusteeTypeW(PTRUSTEEW pTrustee)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pTrustee);
|
|
|
|
|
|
|
|
if (!pTrustee)
|
|
|
|
return TRUSTEE_IS_UNKNOWN;
|
|
|
|
|
|
|
|
return pTrustee->TrusteeType;
|
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI SetAclInformation( PACL pAcl, LPVOID pAclInformation,
|
|
|
|
DWORD nAclInformationLength,
|
|
|
|
ACL_INFORMATION_CLASS dwAclInformationClass )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("%p %p 0x%08x 0x%08x - stub\n", pAcl, pAclInformation,
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
nAclInformationLength, dwAclInformationClass);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-16 08:25:36 +01:00
|
|
|
static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR **ptrustee_nameW)
|
2011-01-12 06:37:51 +01:00
|
|
|
{
|
|
|
|
switch (form)
|
|
|
|
{
|
|
|
|
case TRUSTEE_IS_NAME:
|
|
|
|
{
|
2012-09-13 22:54:37 +02:00
|
|
|
*ptrustee_nameW = SERV_dup(trustee_nameA);
|
2011-01-12 06:37:51 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
case TRUSTEE_IS_OBJECTS_AND_NAME:
|
|
|
|
{
|
|
|
|
OBJECTS_AND_NAME_A *objA = (OBJECTS_AND_NAME_A *)trustee_nameA;
|
|
|
|
OBJECTS_AND_NAME_W *objW = NULL;
|
|
|
|
|
|
|
|
if (objA)
|
|
|
|
{
|
2014-08-27 13:48:17 +02:00
|
|
|
if (!(objW = heap_alloc( sizeof(OBJECTS_AND_NAME_W) )))
|
2011-01-12 06:37:51 +01:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
objW->ObjectsPresent = objA->ObjectsPresent;
|
|
|
|
objW->ObjectType = objA->ObjectType;
|
2012-09-13 22:54:37 +02:00
|
|
|
objW->ObjectTypeName = SERV_dup(objA->ObjectTypeName);
|
|
|
|
objW->InheritedObjectTypeName = SERV_dup(objA->InheritedObjectTypeName);
|
|
|
|
objW->ptstrName = SERV_dup(objA->ptstrName);
|
2011-01-12 06:37:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*ptrustee_nameW = (WCHAR *)objW;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
/* These forms do not require conversion. */
|
|
|
|
case TRUSTEE_IS_SID:
|
|
|
|
case TRUSTEE_IS_OBJECTS_AND_SID:
|
|
|
|
*ptrustee_nameW = (WCHAR *)trustee_nameA;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
default:
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-16 08:25:36 +01:00
|
|
|
static void free_trustee_name(TRUSTEE_FORM form, WCHAR *trustee_nameW)
|
2011-01-12 06:37:51 +01:00
|
|
|
{
|
|
|
|
switch (form)
|
|
|
|
{
|
|
|
|
case TRUSTEE_IS_NAME:
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( trustee_nameW );
|
2011-01-12 06:37:51 +01:00
|
|
|
break;
|
|
|
|
case TRUSTEE_IS_OBJECTS_AND_NAME:
|
|
|
|
{
|
|
|
|
OBJECTS_AND_NAME_W *objW = (OBJECTS_AND_NAME_W *)trustee_nameW;
|
|
|
|
|
|
|
|
if (objW)
|
|
|
|
{
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( objW->ptstrName );
|
|
|
|
heap_free( objW->InheritedObjectTypeName );
|
|
|
|
heap_free( objW->ObjectTypeName );
|
|
|
|
heap_free( objW );
|
2011-01-12 06:37:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Other forms did not require allocation, so no freeing is necessary. */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-12 20:53:14 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* SetEntriesInAclA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
|
|
|
|
PACL OldAcl, PACL* NewAcl )
|
|
|
|
{
|
2011-01-01 21:19:55 +01:00
|
|
|
DWORD err = ERROR_SUCCESS;
|
2011-01-12 06:37:51 +01:00
|
|
|
EXPLICIT_ACCESSW *pEntriesW;
|
2011-10-05 17:01:24 +02:00
|
|
|
UINT alloc_index, free_index;
|
2011-01-01 21:19:55 +01:00
|
|
|
|
|
|
|
TRACE("%d %p %p %p\n", count, pEntries, OldAcl, NewAcl);
|
|
|
|
|
2008-10-04 10:35:32 +02:00
|
|
|
if (NewAcl)
|
2011-01-01 21:19:55 +01:00
|
|
|
*NewAcl = NULL;
|
|
|
|
|
|
|
|
if (!count && !OldAcl)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
pEntriesW = heap_alloc( count * sizeof(EXPLICIT_ACCESSW) );
|
2011-01-12 06:37:51 +01:00
|
|
|
if (!pEntriesW)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2011-01-01 21:19:55 +01:00
|
|
|
|
2011-01-12 06:37:51 +01:00
|
|
|
for (alloc_index = 0; alloc_index < count; ++alloc_index)
|
|
|
|
{
|
|
|
|
pEntriesW[alloc_index].grfAccessPermissions = pEntries[alloc_index].grfAccessPermissions;
|
|
|
|
pEntriesW[alloc_index].grfAccessMode = pEntries[alloc_index].grfAccessMode;
|
|
|
|
pEntriesW[alloc_index].grfInheritance = pEntries[alloc_index].grfInheritance;
|
|
|
|
pEntriesW[alloc_index].Trustee.pMultipleTrustee = NULL; /* currently not supported */
|
|
|
|
pEntriesW[alloc_index].Trustee.MultipleTrusteeOperation = pEntries[alloc_index].Trustee.MultipleTrusteeOperation;
|
|
|
|
pEntriesW[alloc_index].Trustee.TrusteeForm = pEntries[alloc_index].Trustee.TrusteeForm;
|
|
|
|
pEntriesW[alloc_index].Trustee.TrusteeType = pEntries[alloc_index].Trustee.TrusteeType;
|
|
|
|
|
|
|
|
err = trustee_name_A_to_W( pEntries[alloc_index].Trustee.TrusteeForm,
|
|
|
|
pEntries[alloc_index].Trustee.ptstrName,
|
|
|
|
&pEntriesW[alloc_index].Trustee.ptstrName );
|
|
|
|
if (err != ERROR_SUCCESS)
|
2011-01-01 21:19:55 +01:00
|
|
|
{
|
2011-01-12 06:37:51 +01:00
|
|
|
if (err == ERROR_INVALID_PARAMETER)
|
|
|
|
WARN("bad trustee form %d for trustee %d\n",
|
|
|
|
pEntries[alloc_index].Trustee.TrusteeForm, alloc_index);
|
2011-01-01 21:19:55 +01:00
|
|
|
|
2011-01-12 06:37:51 +01:00
|
|
|
goto cleanup;
|
2011-01-01 21:19:55 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-12 06:37:51 +01:00
|
|
|
|
|
|
|
err = SetEntriesInAclW( count, pEntriesW, OldAcl, NewAcl );
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
/* Free any previously allocated trustee name buffers, taking into account
|
|
|
|
* a possible out-of-memory condition while building the EXPLICIT_ACCESSW
|
|
|
|
* list. */
|
|
|
|
for (free_index = 0; free_index < alloc_index; ++free_index)
|
|
|
|
free_trustee_name( pEntriesW[free_index].Trustee.TrusteeForm, pEntriesW[free_index].Trustee.ptstrName );
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( pEntriesW );
|
2011-01-01 21:19:55 +01:00
|
|
|
return err;
|
2003-08-12 20:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetEntriesInAclW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
|
|
|
|
PACL OldAcl, PACL* NewAcl )
|
|
|
|
{
|
2008-01-22 16:36:36 +01:00
|
|
|
ULONG i;
|
|
|
|
PSID *ppsid;
|
|
|
|
DWORD ret = ERROR_SUCCESS;
|
|
|
|
DWORD acl_size = sizeof(ACL);
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
TRACE("%d %p %p %p\n", count, pEntries, OldAcl, NewAcl);
|
|
|
|
|
2011-01-01 21:19:55 +01:00
|
|
|
if (NewAcl)
|
|
|
|
*NewAcl = NULL;
|
2008-01-22 16:36:36 +01:00
|
|
|
|
|
|
|
if (!count && !OldAcl)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
/* allocate array of maximum sized sids allowed */
|
2014-08-27 13:48:17 +02:00
|
|
|
ppsid = heap_alloc(count * (sizeof(SID *) + FIELD_OFFSET(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES])));
|
2008-01-22 16:36:36 +01:00
|
|
|
if (!ppsid)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
ppsid[i] = (char *)&ppsid[count] + i * FIELD_OFFSET(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES]);
|
|
|
|
|
|
|
|
TRACE("[%d]:\n\tgrfAccessPermissions = 0x%x\n\tgrfAccessMode = %d\n\tgrfInheritance = 0x%x\n\t"
|
|
|
|
"Trustee.pMultipleTrustee = %p\n\tMultipleTrusteeOperation = %d\n\tTrusteeForm = %d\n\t"
|
|
|
|
"Trustee.TrusteeType = %d\n\tptstrName = %p\n", i,
|
|
|
|
pEntries[i].grfAccessPermissions, pEntries[i].grfAccessMode, pEntries[i].grfInheritance,
|
|
|
|
pEntries[i].Trustee.pMultipleTrustee, pEntries[i].Trustee.MultipleTrusteeOperation,
|
|
|
|
pEntries[i].Trustee.TrusteeForm, pEntries[i].Trustee.TrusteeType,
|
|
|
|
pEntries[i].Trustee.ptstrName);
|
|
|
|
|
2009-10-10 15:52:09 +02:00
|
|
|
if (pEntries[i].Trustee.MultipleTrusteeOperation == TRUSTEE_IS_IMPERSONATE)
|
2008-01-22 16:36:36 +01:00
|
|
|
{
|
|
|
|
WARN("bad multiple trustee operation %d for trustee %d\n", pEntries[i].Trustee.MultipleTrusteeOperation, i);
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pEntries[i].Trustee.TrusteeForm)
|
|
|
|
{
|
|
|
|
case TRUSTEE_IS_SID:
|
|
|
|
if (!CopySid(FIELD_OFFSET(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES]),
|
|
|
|
ppsid[i], pEntries[i].Trustee.ptstrName))
|
|
|
|
{
|
|
|
|
WARN("bad sid %p for trustee %d\n", pEntries[i].Trustee.ptstrName, i);
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TRUSTEE_IS_NAME:
|
|
|
|
{
|
|
|
|
DWORD sid_size = FIELD_OFFSET(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES]);
|
2008-10-18 21:56:08 +02:00
|
|
|
DWORD domain_size = MAX_COMPUTERNAME_LENGTH + 1;
|
2008-01-22 16:36:36 +01:00
|
|
|
SID_NAME_USE use;
|
2009-10-22 13:19:31 +02:00
|
|
|
if (!strcmpW( pEntries[i].Trustee.ptstrName, CURRENT_USER ))
|
|
|
|
{
|
|
|
|
if (!lookup_user_account_name( ppsid[i], &sid_size, NULL, &domain_size, &use ))
|
|
|
|
{
|
|
|
|
ret = GetLastError();
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!LookupAccountNameW(NULL, pEntries[i].Trustee.ptstrName, ppsid[i], &sid_size, NULL, &domain_size, &use))
|
2008-01-22 16:36:36 +01:00
|
|
|
{
|
|
|
|
WARN("bad user name %s for trustee %d\n", debugstr_w(pEntries[i].Trustee.ptstrName), i);
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TRUSTEE_IS_OBJECTS_AND_SID:
|
|
|
|
FIXME("TRUSTEE_IS_OBJECTS_AND_SID unimplemented\n");
|
|
|
|
break;
|
|
|
|
case TRUSTEE_IS_OBJECTS_AND_NAME:
|
|
|
|
FIXME("TRUSTEE_IS_OBJECTS_AND_NAME unimplemented\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("bad trustee form %d for trustee %d\n", pEntries[i].Trustee.TrusteeForm, i);
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: we overestimate the ACL size here as a tradeoff between
|
|
|
|
* instructions (simplicity) and memory */
|
|
|
|
switch (pEntries[i].grfAccessMode)
|
|
|
|
{
|
|
|
|
case GRANT_ACCESS:
|
|
|
|
case SET_ACCESS:
|
|
|
|
acl_size += FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + GetLengthSid(ppsid[i]);
|
|
|
|
break;
|
|
|
|
case DENY_ACCESS:
|
|
|
|
acl_size += FIELD_OFFSET(ACCESS_DENIED_ACE, SidStart) + GetLengthSid(ppsid[i]);
|
|
|
|
break;
|
|
|
|
case SET_AUDIT_SUCCESS:
|
|
|
|
case SET_AUDIT_FAILURE:
|
|
|
|
acl_size += FIELD_OFFSET(SYSTEM_AUDIT_ACE, SidStart) + GetLengthSid(ppsid[i]);
|
|
|
|
break;
|
|
|
|
case REVOKE_ACCESS:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("bad access mode %d for trustee %d\n", pEntries[i].grfAccessMode, i);
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OldAcl)
|
|
|
|
{
|
|
|
|
ACL_SIZE_INFORMATION size_info;
|
|
|
|
|
|
|
|
status = RtlQueryInformationAcl(OldAcl, &size_info, sizeof(size_info), AclSizeInformation);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
ret = RtlNtStatusToDosError(status);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
acl_size += size_info.AclBytesInUse - sizeof(ACL);
|
|
|
|
}
|
|
|
|
|
|
|
|
*NewAcl = LocalAlloc(0, acl_size);
|
|
|
|
if (!*NewAcl)
|
|
|
|
{
|
|
|
|
ret = ERROR_OUTOFMEMORY;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = RtlCreateAcl( *NewAcl, acl_size, ACL_REVISION );
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
ret = RtlNtStatusToDosError(status);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
switch (pEntries[i].grfAccessMode)
|
|
|
|
{
|
|
|
|
case GRANT_ACCESS:
|
|
|
|
status = RtlAddAccessAllowedAceEx(*NewAcl, ACL_REVISION,
|
|
|
|
pEntries[i].grfInheritance,
|
|
|
|
pEntries[i].grfAccessPermissions,
|
|
|
|
ppsid[i]);
|
|
|
|
break;
|
|
|
|
case SET_ACCESS:
|
|
|
|
{
|
|
|
|
ULONG j;
|
|
|
|
BOOL add = TRUE;
|
|
|
|
if (OldAcl)
|
|
|
|
{
|
|
|
|
for (j = 0; ; j++)
|
|
|
|
{
|
|
|
|
const ACE_HEADER *existing_ace_header;
|
|
|
|
status = RtlGetAce(OldAcl, j, (LPVOID *)&existing_ace_header);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
break;
|
|
|
|
if (pEntries[i].grfAccessMode == SET_ACCESS &&
|
|
|
|
existing_ace_header->AceType == ACCESS_ALLOWED_ACE_TYPE &&
|
|
|
|
EqualSid(ppsid[i], &((ACCESS_ALLOWED_ACE *)existing_ace_header)->SidStart))
|
|
|
|
{
|
|
|
|
add = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (add)
|
|
|
|
status = RtlAddAccessAllowedAceEx(*NewAcl, ACL_REVISION,
|
|
|
|
pEntries[i].grfInheritance,
|
|
|
|
pEntries[i].grfAccessPermissions,
|
|
|
|
ppsid[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DENY_ACCESS:
|
|
|
|
status = RtlAddAccessDeniedAceEx(*NewAcl, ACL_REVISION,
|
|
|
|
pEntries[i].grfInheritance,
|
|
|
|
pEntries[i].grfAccessPermissions,
|
|
|
|
ppsid[i]);
|
|
|
|
break;
|
|
|
|
case SET_AUDIT_SUCCESS:
|
|
|
|
status = RtlAddAuditAccessAceEx(*NewAcl, ACL_REVISION,
|
|
|
|
pEntries[i].grfInheritance,
|
|
|
|
pEntries[i].grfAccessPermissions,
|
|
|
|
ppsid[i], TRUE, FALSE);
|
|
|
|
break;
|
|
|
|
case SET_AUDIT_FAILURE:
|
|
|
|
status = RtlAddAuditAccessAceEx(*NewAcl, ACL_REVISION,
|
|
|
|
pEntries[i].grfInheritance,
|
|
|
|
pEntries[i].grfAccessPermissions,
|
|
|
|
ppsid[i], FALSE, TRUE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled access mode %d\n", pEntries[i].grfAccessMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OldAcl)
|
|
|
|
{
|
|
|
|
for (i = 0; ; i++)
|
|
|
|
{
|
|
|
|
BOOL add = TRUE;
|
|
|
|
ULONG j;
|
|
|
|
const ACE_HEADER *old_ace_header;
|
|
|
|
status = RtlGetAce(OldAcl, i, (LPVOID *)&old_ace_header);
|
|
|
|
if (status != STATUS_SUCCESS) break;
|
|
|
|
for (j = 0; j < count; j++)
|
|
|
|
{
|
|
|
|
if (pEntries[j].grfAccessMode == SET_ACCESS &&
|
|
|
|
old_ace_header->AceType == ACCESS_ALLOWED_ACE_TYPE &&
|
|
|
|
EqualSid(ppsid[j], &((ACCESS_ALLOWED_ACE *)old_ace_header)->SidStart))
|
|
|
|
{
|
|
|
|
status = RtlAddAccessAllowedAceEx(*NewAcl, ACL_REVISION, pEntries[j].grfInheritance, pEntries[j].grfAccessPermissions, ppsid[j]);
|
|
|
|
add = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (pEntries[j].grfAccessMode == REVOKE_ACCESS)
|
|
|
|
{
|
|
|
|
switch (old_ace_header->AceType)
|
|
|
|
{
|
|
|
|
case ACCESS_ALLOWED_ACE_TYPE:
|
|
|
|
if (EqualSid(ppsid[j], &((ACCESS_ALLOWED_ACE *)old_ace_header)->SidStart))
|
|
|
|
add = FALSE;
|
|
|
|
break;
|
|
|
|
case ACCESS_DENIED_ACE_TYPE:
|
|
|
|
if (EqualSid(ppsid[j], &((ACCESS_DENIED_ACE *)old_ace_header)->SidStart))
|
|
|
|
add = FALSE;
|
|
|
|
break;
|
|
|
|
case SYSTEM_AUDIT_ACE_TYPE:
|
|
|
|
if (EqualSid(ppsid[j], &((SYSTEM_AUDIT_ACE *)old_ace_header)->SidStart))
|
|
|
|
add = FALSE;
|
|
|
|
break;
|
|
|
|
case SYSTEM_ALARM_ACE_TYPE:
|
|
|
|
if (EqualSid(ppsid[j], &((SYSTEM_ALARM_ACE *)old_ace_header)->SidStart))
|
|
|
|
add = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled ace type %d\n", old_ace_header->AceType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!add)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (add)
|
|
|
|
status = RtlAddAce(*NewAcl, ACL_REVISION, 1, (PACE_HEADER)old_ace_header, old_ace_header->AceSize);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("RtlAddAce failed with error 0x%08x\n", status);
|
|
|
|
ret = RtlNtStatusToDosError(status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(ppsid);
|
2008-01-22 16:36:36 +01:00
|
|
|
return ret;
|
2003-08-12 20:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetNamedSecurityInfoA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
|
|
|
|
{
|
2012-09-13 22:54:37 +02:00
|
|
|
LPWSTR wstr;
|
2004-08-10 00:55:47 +02:00
|
|
|
DWORD r;
|
|
|
|
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("%s %d %d %p %p %p %p\n", debugstr_a(pObjectName), ObjectType,
|
2003-08-12 20:53:14 +02:00
|
|
|
SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
|
2004-08-10 00:55:47 +02:00
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
wstr = SERV_dup(pObjectName);
|
2004-08-10 00:55:47 +02:00
|
|
|
r = SetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, psidOwner,
|
|
|
|
psidGroup, pDacl, pSacl );
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( wstr );
|
2004-08-10 00:55:47 +02:00
|
|
|
|
|
|
|
return r;
|
2003-08-12 20:53:14 +02:00
|
|
|
}
|
|
|
|
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
BOOL WINAPI SetPrivateObjectSecurity( SECURITY_INFORMATION SecurityInformation,
|
|
|
|
PSECURITY_DESCRIPTOR ModificationDescriptor,
|
|
|
|
PSECURITY_DESCRIPTOR* ObjectsSecurityDescriptor,
|
|
|
|
PGENERIC_MAPPING GenericMapping,
|
|
|
|
HANDLE Token )
|
|
|
|
{
|
2006-10-03 15:48:41 +02:00
|
|
|
FIXME("0x%08x %p %p %p %p - stub\n", SecurityInformation, ModificationDescriptor,
|
Stub implementations for GetKernelObjectSecurity,
GetPrivateObjectSecurity, GetServiceKeyName{A,W},
ImpersonateNamedPipeClient, InitiateSystemShutdown{A,W},
IsTokenRestricted, LogonUser{A,W}, LookupAccountNameW,
LookupPrivilegeDisplayName{A,W}, MapGenericMask,
ObjectCloseAuditAlarm{A,W}, ObjectOpenAuditAlarm{A,W},
ObjectPrivilegeAuditAlarm{A,W}, PrivilegedServiceAuditAlarm{A,W},
QueryServiceLockStatus{A,W}, SetAclInformation,
SetPrivateObjectSecurity, SetSecurityDescriptorControl,
SetServiceBits, LsaSetInformationPolicy, LsaLookupNames,
LsaEnumerateTrustedDomains.
2005-01-03 18:12:51 +01:00
|
|
|
ObjectsSecurityDescriptor, GenericMapping, Token);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOL WINAPI AreAllAccessesGranted( DWORD GrantedAccess, DWORD DesiredAccess )
|
|
|
|
{
|
|
|
|
return RtlAreAllAccessesGranted( GrantedAccess, DesiredAccess );
|
|
|
|
}
|
|
|
|
|
2004-05-25 02:22:42 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AreAnyAccessesGranted [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Determines whether or not any of a set of specified access permissions have
|
|
|
|
* been granted or not.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* GrantedAccess [I] The permissions that have been granted.
|
|
|
|
* DesiredAccess [I] The permissions that you want to have.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nonzero if any of the permissions have been granted, zero if none of the
|
|
|
|
* permissions have been granted.
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI AreAnyAccessesGranted( DWORD GrantedAccess, DWORD DesiredAccess )
|
|
|
|
{
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
return RtlAreAnyAccessesGranted( GrantedAccess, DesiredAccess );
|
2004-05-25 02:22:42 +02:00
|
|
|
}
|
|
|
|
|
2003-08-12 20:53:14 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* SetNamedSecurityInfoW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
|
|
|
|
{
|
2012-11-26 20:08:57 +01:00
|
|
|
DWORD access = 0;
|
2013-01-18 18:59:01 +01:00
|
|
|
HANDLE handle;
|
|
|
|
DWORD err;
|
2012-11-26 20:08:57 +01:00
|
|
|
|
|
|
|
TRACE( "%s %d %d %p %p %p %p\n", debugstr_w(pObjectName), ObjectType,
|
2003-08-12 20:53:14 +02:00
|
|
|
SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
|
2012-11-26 20:08:57 +01:00
|
|
|
|
|
|
|
if (!pObjectName) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (SecurityInfo & (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION))
|
|
|
|
access |= WRITE_OWNER;
|
|
|
|
if (SecurityInfo & DACL_SECURITY_INFORMATION)
|
|
|
|
access |= WRITE_DAC;
|
|
|
|
if (SecurityInfo & SACL_SECURITY_INFORMATION)
|
|
|
|
access |= ACCESS_SYSTEM_SECURITY;
|
|
|
|
|
2013-01-30 20:59:15 +01:00
|
|
|
switch (ObjectType)
|
|
|
|
{
|
|
|
|
case SE_SERVICE:
|
|
|
|
if (!(err = get_security_service( pObjectName, access, &handle )))
|
|
|
|
{
|
|
|
|
err = SetSecurityInfo( handle, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl );
|
|
|
|
CloseServiceHandle( handle );
|
|
|
|
}
|
|
|
|
break;
|
2013-02-02 16:53:17 +01:00
|
|
|
case SE_REGISTRY_KEY:
|
|
|
|
if (!(err = get_security_regkey( pObjectName, access, &handle )))
|
|
|
|
{
|
|
|
|
err = SetSecurityInfo( handle, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl );
|
|
|
|
RegCloseKey( handle );
|
|
|
|
}
|
|
|
|
break;
|
2013-01-30 20:59:15 +01:00
|
|
|
case SE_FILE_OBJECT:
|
2015-03-27 11:12:04 +01:00
|
|
|
if (SecurityInfo & DACL_SECURITY_INFORMATION)
|
|
|
|
access |= READ_CONTROL;
|
2013-01-30 20:59:15 +01:00
|
|
|
if (!(err = get_security_file( pObjectName, access, &handle )))
|
|
|
|
{
|
|
|
|
err = SetSecurityInfo( handle, ObjectType, SecurityInfo, psidOwner, psidGroup, pDacl, pSacl );
|
|
|
|
CloseHandle( handle );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME( "Object type %d is not currently supported.\n", ObjectType );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2013-01-18 18:59:01 +01:00
|
|
|
return err;
|
2003-08-12 20:53:14 +02:00
|
|
|
}
|
2003-09-17 22:04:45 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetExplicitEntriesFromAclA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetExplicitEntriesFromAclA( PACL pacl, PULONG pcCountOfExplicitEntries,
|
|
|
|
PEXPLICIT_ACCESSA* pListOfExplicitEntries)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetExplicitEntriesFromAclW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetExplicitEntriesFromAclW( PACL pacl, PULONG pcCountOfExplicitEntries,
|
|
|
|
PEXPLICIT_ACCESSW* pListOfExplicitEntries)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2008-06-19 15:50:02 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetAuditedPermissionsFromAclA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetAuditedPermissionsFromAclA( PACL pacl, PTRUSTEEA pTrustee, PACCESS_MASK pSuccessfulAuditedRights,
|
|
|
|
PACCESS_MASK pFailedAuditRights)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p %p\n",pacl, pTrustee, pSuccessfulAuditedRights, pFailedAuditRights);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetAuditedPermissionsFromAclW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetAuditedPermissionsFromAclW( PACL pacl, PTRUSTEEW pTrustee, PACCESS_MASK pSuccessfulAuditedRights,
|
|
|
|
PACCESS_MASK pFailedAuditRights)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p %p\n",pacl, pTrustee, pSuccessfulAuditedRights, pFailedAuditRights);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ParseAclStringFlags
|
|
|
|
*/
|
|
|
|
static DWORD ParseAclStringFlags(LPCWSTR* StringAcl)
|
|
|
|
{
|
|
|
|
DWORD flags = 0;
|
|
|
|
LPCWSTR szAcl = *StringAcl;
|
|
|
|
|
|
|
|
while (*szAcl != '(')
|
|
|
|
{
|
|
|
|
if (*szAcl == 'P')
|
|
|
|
{
|
|
|
|
flags |= SE_DACL_PROTECTED;
|
|
|
|
}
|
|
|
|
else if (*szAcl == 'A')
|
|
|
|
{
|
|
|
|
szAcl++;
|
|
|
|
if (*szAcl == 'R')
|
|
|
|
flags |= SE_DACL_AUTO_INHERIT_REQ;
|
|
|
|
else if (*szAcl == 'I')
|
|
|
|
flags |= SE_DACL_AUTO_INHERITED;
|
|
|
|
}
|
|
|
|
szAcl++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*StringAcl = szAcl;
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ParseAceStringType
|
|
|
|
*/
|
2006-06-12 13:41:15 +02:00
|
|
|
static const ACEFLAG AceType[] =
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
|
|
|
{ SDDL_ALARM, SYSTEM_ALARM_ACE_TYPE },
|
|
|
|
{ SDDL_AUDIT, SYSTEM_AUDIT_ACE_TYPE },
|
2007-09-27 20:55:11 +02:00
|
|
|
{ SDDL_ACCESS_ALLOWED, ACCESS_ALLOWED_ACE_TYPE },
|
2003-11-11 23:03:24 +01:00
|
|
|
{ SDDL_ACCESS_DENIED, ACCESS_DENIED_ACE_TYPE },
|
2015-04-16 17:02:29 +02:00
|
|
|
{ SDDL_MANDATORY_LABEL,SYSTEM_MANDATORY_LABEL_ACE_TYPE },
|
2003-11-11 23:03:24 +01:00
|
|
|
/*
|
|
|
|
{ SDDL_OBJECT_ACCESS_ALLOWED, ACCESS_ALLOWED_OBJECT_ACE_TYPE },
|
|
|
|
{ SDDL_OBJECT_ACCESS_DENIED, ACCESS_DENIED_OBJECT_ACE_TYPE },
|
|
|
|
{ SDDL_OBJECT_ALARM, SYSTEM_ALARM_OBJECT_ACE_TYPE },
|
|
|
|
{ SDDL_OBJECT_AUDIT, SYSTEM_AUDIT_OBJECT_ACE_TYPE },
|
|
|
|
*/
|
|
|
|
{ NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static BYTE ParseAceStringType(LPCWSTR* StringAcl)
|
|
|
|
{
|
|
|
|
UINT len = 0;
|
|
|
|
LPCWSTR szAcl = *StringAcl;
|
2006-06-12 13:41:15 +02:00
|
|
|
const ACEFLAG *lpaf = AceType;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*szAcl == ' ')
|
|
|
|
szAcl++;
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
while (lpaf->wstr &&
|
|
|
|
(len = strlenW(lpaf->wstr)) &&
|
|
|
|
strncmpW(lpaf->wstr, szAcl, len))
|
|
|
|
lpaf++;
|
|
|
|
|
|
|
|
if (!lpaf->wstr)
|
|
|
|
return 0;
|
|
|
|
|
2009-10-13 15:39:47 +02:00
|
|
|
*StringAcl = szAcl + len;
|
2003-11-11 23:03:24 +01:00
|
|
|
return lpaf->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ParseAceStringFlags
|
|
|
|
*/
|
2006-06-12 13:41:15 +02:00
|
|
|
static const ACEFLAG AceFlags[] =
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
|
|
|
{ SDDL_CONTAINER_INHERIT, CONTAINER_INHERIT_ACE },
|
|
|
|
{ SDDL_AUDIT_FAILURE, FAILED_ACCESS_ACE_FLAG },
|
|
|
|
{ SDDL_INHERITED, INHERITED_ACE },
|
|
|
|
{ SDDL_INHERIT_ONLY, INHERIT_ONLY_ACE },
|
|
|
|
{ SDDL_NO_PROPAGATE, NO_PROPAGATE_INHERIT_ACE },
|
|
|
|
{ SDDL_OBJECT_INHERIT, OBJECT_INHERIT_ACE },
|
|
|
|
{ SDDL_AUDIT_SUCCESS, SUCCESSFUL_ACCESS_ACE_FLAG },
|
|
|
|
{ NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static BYTE ParseAceStringFlags(LPCWSTR* StringAcl)
|
|
|
|
{
|
|
|
|
UINT len = 0;
|
|
|
|
BYTE flags = 0;
|
|
|
|
LPCWSTR szAcl = *StringAcl;
|
|
|
|
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*szAcl == ' ')
|
|
|
|
szAcl++;
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
while (*szAcl != ';')
|
|
|
|
{
|
2006-06-12 13:41:15 +02:00
|
|
|
const ACEFLAG *lpaf = AceFlags;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
while (lpaf->wstr &&
|
|
|
|
(len = strlenW(lpaf->wstr)) &&
|
|
|
|
strncmpW(lpaf->wstr, szAcl, len))
|
|
|
|
lpaf++;
|
|
|
|
|
|
|
|
if (!lpaf->wstr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
flags |= lpaf->value;
|
|
|
|
szAcl += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
*StringAcl = szAcl;
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ParseAceStringRights
|
|
|
|
*/
|
2006-06-12 13:41:15 +02:00
|
|
|
static const ACEFLAG AceRights[] =
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
|
|
|
{ SDDL_GENERIC_ALL, GENERIC_ALL },
|
|
|
|
{ SDDL_GENERIC_READ, GENERIC_READ },
|
|
|
|
{ SDDL_GENERIC_WRITE, GENERIC_WRITE },
|
|
|
|
{ SDDL_GENERIC_EXECUTE, GENERIC_EXECUTE },
|
2007-09-23 06:26:05 +02:00
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
{ SDDL_READ_CONTROL, READ_CONTROL },
|
|
|
|
{ SDDL_STANDARD_DELETE, DELETE },
|
|
|
|
{ SDDL_WRITE_DAC, WRITE_DAC },
|
|
|
|
{ SDDL_WRITE_OWNER, WRITE_OWNER },
|
2007-09-23 06:26:05 +02:00
|
|
|
|
|
|
|
{ SDDL_READ_PROPERTY, ADS_RIGHT_DS_READ_PROP},
|
|
|
|
{ SDDL_WRITE_PROPERTY, ADS_RIGHT_DS_WRITE_PROP},
|
|
|
|
{ SDDL_CREATE_CHILD, ADS_RIGHT_DS_CREATE_CHILD},
|
|
|
|
{ SDDL_DELETE_CHILD, ADS_RIGHT_DS_DELETE_CHILD},
|
|
|
|
{ SDDL_LIST_CHILDREN, ADS_RIGHT_ACTRL_DS_LIST},
|
|
|
|
{ SDDL_SELF_WRITE, ADS_RIGHT_DS_SELF},
|
|
|
|
{ SDDL_LIST_OBJECT, ADS_RIGHT_DS_LIST_OBJECT},
|
|
|
|
{ SDDL_DELETE_TREE, ADS_RIGHT_DS_DELETE_TREE},
|
|
|
|
{ SDDL_CONTROL_ACCESS, ADS_RIGHT_DS_CONTROL_ACCESS},
|
|
|
|
|
|
|
|
{ SDDL_FILE_ALL, FILE_ALL_ACCESS },
|
|
|
|
{ SDDL_FILE_READ, FILE_GENERIC_READ },
|
|
|
|
{ SDDL_FILE_WRITE, FILE_GENERIC_WRITE },
|
|
|
|
{ SDDL_FILE_EXECUTE, FILE_GENERIC_EXECUTE },
|
|
|
|
|
|
|
|
{ SDDL_KEY_ALL, KEY_ALL_ACCESS },
|
|
|
|
{ SDDL_KEY_READ, KEY_READ },
|
|
|
|
{ SDDL_KEY_WRITE, KEY_WRITE },
|
|
|
|
{ SDDL_KEY_EXECUTE, KEY_EXECUTE },
|
2015-04-16 17:02:29 +02:00
|
|
|
|
|
|
|
{ SDDL_NO_READ_UP, SYSTEM_MANDATORY_LABEL_NO_READ_UP },
|
|
|
|
{ SDDL_NO_WRITE_UP, SYSTEM_MANDATORY_LABEL_NO_WRITE_UP },
|
|
|
|
{ SDDL_NO_EXECUTE_UP, SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP },
|
2003-11-11 23:03:24 +01:00
|
|
|
{ NULL, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
|
|
|
|
{
|
|
|
|
UINT len = 0;
|
|
|
|
DWORD rights = 0;
|
|
|
|
LPCWSTR szAcl = *StringAcl;
|
|
|
|
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*szAcl == ' ')
|
|
|
|
szAcl++;
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
if ((*szAcl == '0') && (*(szAcl + 1) == 'x'))
|
|
|
|
{
|
|
|
|
LPCWSTR p = szAcl;
|
|
|
|
|
|
|
|
while (*p && *p != ';')
|
|
|
|
p++;
|
|
|
|
|
2007-07-18 19:12:43 +02:00
|
|
|
if (p - szAcl <= 10 /* 8 hex digits + "0x" */ )
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
|
|
|
rights = strtoulW(szAcl, NULL, 16);
|
2007-07-18 19:12:43 +02:00
|
|
|
szAcl = p;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl, p - szAcl));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (*szAcl != ';')
|
|
|
|
{
|
2006-06-12 13:41:15 +02:00
|
|
|
const ACEFLAG *lpaf = AceRights;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
while (lpaf->wstr &&
|
|
|
|
(len = strlenW(lpaf->wstr)) &&
|
|
|
|
strncmpW(lpaf->wstr, szAcl, len))
|
|
|
|
{
|
|
|
|
lpaf++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lpaf->wstr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rights |= lpaf->value;
|
|
|
|
szAcl += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*StringAcl = szAcl;
|
|
|
|
return rights;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ParseStringAclToAcl
|
|
|
|
*
|
|
|
|
* dacl_flags(string_ace1)(string_ace2)... (string_acen)
|
|
|
|
*/
|
|
|
|
static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
|
|
|
|
PACL pAcl, LPDWORD cBytes)
|
|
|
|
{
|
|
|
|
DWORD val;
|
|
|
|
DWORD sidlen;
|
|
|
|
DWORD length = sizeof(ACL);
|
2007-09-27 20:44:51 +02:00
|
|
|
DWORD acesize = 0;
|
|
|
|
DWORD acecount = 0;
|
2003-11-11 23:03:24 +01:00
|
|
|
PACCESS_ALLOWED_ACE pAce = NULL; /* pointer to current ACE */
|
2009-10-13 15:39:47 +02:00
|
|
|
DWORD error = ERROR_INVALID_ACL;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(StringAcl));
|
|
|
|
|
|
|
|
if (!StringAcl)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (pAcl) /* pAce is only useful if we're setting values */
|
2007-07-18 19:07:29 +02:00
|
|
|
pAce = (PACCESS_ALLOWED_ACE) (pAcl + 1);
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
/* Parse ACL flags */
|
|
|
|
*lpdwFlags = ParseAclStringFlags(&StringAcl);
|
|
|
|
|
|
|
|
/* Parse ACE */
|
|
|
|
while (*StringAcl == '(')
|
|
|
|
{
|
|
|
|
StringAcl++;
|
|
|
|
|
|
|
|
/* Parse ACE type */
|
|
|
|
val = ParseAceStringType(&StringAcl);
|
|
|
|
if (pAce)
|
|
|
|
pAce->Header.AceType = (BYTE) val;
|
|
|
|
if (*StringAcl != ';')
|
2009-10-13 15:39:47 +02:00
|
|
|
{
|
|
|
|
error = RPC_S_INVALID_STRING_UUID;
|
2003-11-11 23:03:24 +01:00
|
|
|
goto lerr;
|
2009-10-13 15:39:47 +02:00
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
StringAcl++;
|
|
|
|
|
|
|
|
/* Parse ACE flags */
|
|
|
|
val = ParseAceStringFlags(&StringAcl);
|
|
|
|
if (pAce)
|
|
|
|
pAce->Header.AceFlags = (BYTE) val;
|
|
|
|
if (*StringAcl != ';')
|
|
|
|
goto lerr;
|
|
|
|
StringAcl++;
|
|
|
|
|
|
|
|
/* Parse ACE rights */
|
|
|
|
val = ParseAceStringRights(&StringAcl);
|
|
|
|
if (pAce)
|
|
|
|
pAce->Mask = val;
|
|
|
|
if (*StringAcl != ';')
|
|
|
|
goto lerr;
|
|
|
|
StringAcl++;
|
|
|
|
|
|
|
|
/* Parse ACE object guid */
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*StringAcl == ' ')
|
|
|
|
StringAcl++;
|
2003-11-11 23:03:24 +01:00
|
|
|
if (*StringAcl != ';')
|
|
|
|
{
|
2004-01-27 01:01:43 +01:00
|
|
|
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
|
2003-11-11 23:03:24 +01:00
|
|
|
goto lerr;
|
|
|
|
}
|
|
|
|
StringAcl++;
|
|
|
|
|
|
|
|
/* Parse ACE inherit object guid */
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*StringAcl == ' ')
|
|
|
|
StringAcl++;
|
2003-11-11 23:03:24 +01:00
|
|
|
if (*StringAcl != ';')
|
|
|
|
{
|
2004-01-27 01:01:43 +01:00
|
|
|
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
|
2003-11-11 23:03:24 +01:00
|
|
|
goto lerr;
|
|
|
|
}
|
|
|
|
StringAcl++;
|
|
|
|
|
|
|
|
/* Parse ACE account sid */
|
2009-02-16 09:53:37 +01:00
|
|
|
if (ParseStringSidToSid(StringAcl, pAce ? &pAce->SidStart : NULL, &sidlen))
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
|
|
|
while (*StringAcl && *StringAcl != ')')
|
|
|
|
StringAcl++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*StringAcl != ')')
|
|
|
|
goto lerr;
|
|
|
|
StringAcl++;
|
|
|
|
|
2007-09-27 20:44:51 +02:00
|
|
|
acesize = sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + sidlen;
|
|
|
|
length += acesize;
|
|
|
|
if (pAce)
|
|
|
|
{
|
|
|
|
pAce->Header.AceSize = acesize;
|
|
|
|
pAce = (PACCESS_ALLOWED_ACE)((LPBYTE)pAce + acesize);
|
|
|
|
}
|
|
|
|
acecount++;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*cBytes = length;
|
2007-09-27 20:44:51 +02:00
|
|
|
|
|
|
|
if (length > 0xffff)
|
|
|
|
{
|
|
|
|
ERR("ACL too large\n");
|
|
|
|
goto lerr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pAcl)
|
|
|
|
{
|
|
|
|
pAcl->AclRevision = ACL_REVISION;
|
|
|
|
pAcl->Sbz1 = 0;
|
|
|
|
pAcl->AclSize = length;
|
|
|
|
pAcl->AceCount = acecount++;
|
|
|
|
pAcl->Sbz2 = 0;
|
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
lerr:
|
2009-10-13 15:39:47 +02:00
|
|
|
SetLastError(error);
|
2003-11-11 23:03:24 +01:00
|
|
|
WARN("Invalid ACE string format\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ParseStringSecurityDescriptorToSecurityDescriptor
|
|
|
|
*/
|
|
|
|
static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
|
|
|
|
LPCWSTR StringSecurityDescriptor,
|
2009-06-16 13:28:00 +02:00
|
|
|
SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
|
2003-11-11 23:03:24 +01:00
|
|
|
LPDWORD cBytes)
|
|
|
|
{
|
|
|
|
BOOL bret = FALSE;
|
|
|
|
WCHAR toktype;
|
2015-08-19 04:18:11 +02:00
|
|
|
WCHAR *tok;
|
2003-11-11 23:03:24 +01:00
|
|
|
LPCWSTR lptoken;
|
|
|
|
LPBYTE lpNext = NULL;
|
2005-04-21 19:18:50 +02:00
|
|
|
DWORD len;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2007-07-18 19:09:16 +02:00
|
|
|
*cBytes = sizeof(SECURITY_DESCRIPTOR);
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2015-08-19 04:18:11 +02:00
|
|
|
tok = heap_alloc( (lstrlenW(StringSecurityDescriptor) + 1) * sizeof(WCHAR));
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
if (SecurityDescriptor)
|
2009-06-16 13:28:00 +02:00
|
|
|
lpNext = (LPBYTE)(SecurityDescriptor + 1);
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*StringSecurityDescriptor == ' ')
|
|
|
|
StringSecurityDescriptor++;
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
while (*StringSecurityDescriptor)
|
|
|
|
{
|
|
|
|
toktype = *StringSecurityDescriptor;
|
|
|
|
|
|
|
|
/* Expect char identifier followed by ':' */
|
|
|
|
StringSecurityDescriptor++;
|
|
|
|
if (*StringSecurityDescriptor != ':')
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
goto lend;
|
|
|
|
}
|
|
|
|
StringSecurityDescriptor++;
|
|
|
|
|
|
|
|
/* Extract token */
|
|
|
|
lptoken = StringSecurityDescriptor;
|
|
|
|
while (*lptoken && *lptoken != ':')
|
|
|
|
lptoken++;
|
|
|
|
|
|
|
|
if (*lptoken)
|
|
|
|
lptoken--;
|
|
|
|
|
2005-04-21 19:18:50 +02:00
|
|
|
len = lptoken - StringSecurityDescriptor;
|
|
|
|
memcpy( tok, StringSecurityDescriptor, len * sizeof(WCHAR) );
|
|
|
|
tok[len] = 0;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
switch (toktype)
|
|
|
|
{
|
|
|
|
case 'O':
|
|
|
|
{
|
|
|
|
DWORD bytes;
|
|
|
|
|
2009-02-16 09:53:37 +01:00
|
|
|
if (!ParseStringSidToSid(tok, lpNext, &bytes))
|
2003-11-11 23:03:24 +01:00
|
|
|
goto lend;
|
|
|
|
|
|
|
|
if (SecurityDescriptor)
|
|
|
|
{
|
2009-06-16 13:28:00 +02:00
|
|
|
SecurityDescriptor->Owner = lpNext - (LPBYTE)SecurityDescriptor;
|
2003-11-11 23:03:24 +01:00
|
|
|
lpNext += bytes; /* Advance to next token */
|
|
|
|
}
|
|
|
|
|
|
|
|
*cBytes += bytes;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'G':
|
|
|
|
{
|
|
|
|
DWORD bytes;
|
|
|
|
|
2009-02-16 09:53:37 +01:00
|
|
|
if (!ParseStringSidToSid(tok, lpNext, &bytes))
|
2003-11-11 23:03:24 +01:00
|
|
|
goto lend;
|
|
|
|
|
|
|
|
if (SecurityDescriptor)
|
|
|
|
{
|
2009-06-16 13:28:00 +02:00
|
|
|
SecurityDescriptor->Group = lpNext - (LPBYTE)SecurityDescriptor;
|
2003-11-11 23:03:24 +01:00
|
|
|
lpNext += bytes; /* Advance to next token */
|
|
|
|
}
|
|
|
|
|
|
|
|
*cBytes += bytes;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'D':
|
|
|
|
{
|
|
|
|
DWORD flags;
|
|
|
|
DWORD bytes;
|
|
|
|
|
|
|
|
if (!ParseStringAclToAcl(tok, &flags, (PACL)lpNext, &bytes))
|
|
|
|
goto lend;
|
|
|
|
|
|
|
|
if (SecurityDescriptor)
|
|
|
|
{
|
|
|
|
SecurityDescriptor->Control |= SE_DACL_PRESENT | flags;
|
2009-06-16 13:28:00 +02:00
|
|
|
SecurityDescriptor->Dacl = lpNext - (LPBYTE)SecurityDescriptor;
|
2003-11-11 23:03:24 +01:00
|
|
|
lpNext += bytes; /* Advance to next token */
|
|
|
|
}
|
|
|
|
|
|
|
|
*cBytes += bytes;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'S':
|
|
|
|
{
|
|
|
|
DWORD flags;
|
|
|
|
DWORD bytes;
|
|
|
|
|
|
|
|
if (!ParseStringAclToAcl(tok, &flags, (PACL)lpNext, &bytes))
|
|
|
|
goto lend;
|
|
|
|
|
|
|
|
if (SecurityDescriptor)
|
|
|
|
{
|
|
|
|
SecurityDescriptor->Control |= SE_SACL_PRESENT | flags;
|
2009-06-16 13:28:00 +02:00
|
|
|
SecurityDescriptor->Sacl = lpNext - (LPBYTE)SecurityDescriptor;
|
2003-11-11 23:03:24 +01:00
|
|
|
lpNext += bytes; /* Advance to next token */
|
|
|
|
}
|
|
|
|
|
|
|
|
*cBytes += bytes;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unknown token\n");
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
goto lend;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringSecurityDescriptor = lptoken;
|
|
|
|
}
|
|
|
|
|
|
|
|
bret = TRUE;
|
|
|
|
|
|
|
|
lend:
|
2015-08-19 04:18:11 +02:00
|
|
|
heap_free(tok);
|
2003-11-11 23:03:24 +01:00
|
|
|
return bret;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ConvertStringSecurityDescriptorToSecurityDescriptorA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(
|
|
|
|
LPCSTR StringSecurityDescriptor,
|
|
|
|
DWORD StringSDRevision,
|
|
|
|
PSECURITY_DESCRIPTOR* SecurityDescriptor,
|
|
|
|
PULONG SecurityDescriptorSize)
|
|
|
|
{
|
2012-09-13 22:54:37 +02:00
|
|
|
BOOL ret;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
LPWSTR StringSecurityDescriptorW;
|
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
if(!StringSecurityDescriptor)
|
|
|
|
return FALSE;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
StringSecurityDescriptorW = SERV_dup(StringSecurityDescriptor);
|
|
|
|
ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW,
|
|
|
|
StringSDRevision, SecurityDescriptor,
|
|
|
|
SecurityDescriptorSize);
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(StringSecurityDescriptorW);
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
|
|
|
LPCWSTR StringSecurityDescriptor,
|
|
|
|
DWORD StringSDRevision,
|
|
|
|
PSECURITY_DESCRIPTOR* SecurityDescriptor,
|
|
|
|
PULONG SecurityDescriptorSize)
|
|
|
|
{
|
|
|
|
DWORD cBytes;
|
2004-08-14 01:55:43 +02:00
|
|
|
SECURITY_DESCRIPTOR* psd;
|
2003-11-11 23:03:24 +01:00
|
|
|
BOOL bret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(StringSecurityDescriptor));
|
|
|
|
|
|
|
|
if (GetVersion() & 0x80000000)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
goto lend;
|
|
|
|
}
|
2008-10-13 23:02:06 +02:00
|
|
|
else if (!StringSecurityDescriptor || !SecurityDescriptor)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
goto lend;
|
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
else if (StringSDRevision != SID_REVISION)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_UNKNOWN_REVISION);
|
|
|
|
goto lend;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute security descriptor length */
|
|
|
|
if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor,
|
|
|
|
NULL, &cBytes))
|
|
|
|
goto lend;
|
|
|
|
|
2009-02-16 09:53:37 +01:00
|
|
|
psd = *SecurityDescriptor = LocalAlloc(GMEM_ZEROINIT, cBytes);
|
2007-07-18 19:11:37 +02:00
|
|
|
if (!psd) goto lend;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
psd->Revision = SID_REVISION;
|
|
|
|
psd->Control |= SE_SELF_RELATIVE;
|
|
|
|
|
|
|
|
if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor,
|
2009-06-16 13:28:00 +02:00
|
|
|
(SECURITY_DESCRIPTOR_RELATIVE *)psd, &cBytes))
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
|
|
|
LocalFree(psd);
|
|
|
|
goto lend;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecurityDescriptorSize)
|
|
|
|
*SecurityDescriptorSize = cBytes;
|
|
|
|
|
|
|
|
bret = TRUE;
|
|
|
|
|
|
|
|
lend:
|
|
|
|
TRACE(" ret=%d\n", bret);
|
|
|
|
return bret;
|
|
|
|
}
|
|
|
|
|
2007-09-25 22:12:50 +02:00
|
|
|
static void DumpString(LPCWSTR string, int cch, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
|
|
|
if (cch == -1)
|
|
|
|
cch = strlenW(string);
|
|
|
|
|
|
|
|
if (plen)
|
|
|
|
*plen += cch;
|
|
|
|
|
|
|
|
if (pwptr)
|
|
|
|
{
|
|
|
|
memcpy(*pwptr, string, sizeof(WCHAR)*cch);
|
|
|
|
*pwptr += cch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpSidNumeric(PSID psid, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
WCHAR fmt[] = { 'S','-','%','u','-','%','d',0 };
|
|
|
|
WCHAR subauthfmt[] = { '-','%','u',0 };
|
|
|
|
WCHAR buf[26];
|
|
|
|
SID *pisid = psid;
|
|
|
|
|
|
|
|
if( !IsValidSid( psid ) || pisid->Revision != SDDL_REVISION)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_SID);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pisid->IdentifierAuthority.Value[0] ||
|
|
|
|
pisid->IdentifierAuthority.Value[1])
|
|
|
|
{
|
|
|
|
FIXME("not matching MS' bugs\n");
|
|
|
|
SetLastError(ERROR_INVALID_SID);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintfW( buf, fmt, pisid->Revision,
|
|
|
|
MAKELONG(
|
|
|
|
MAKEWORD( pisid->IdentifierAuthority.Value[5],
|
|
|
|
pisid->IdentifierAuthority.Value[4] ),
|
|
|
|
MAKEWORD( pisid->IdentifierAuthority.Value[3],
|
|
|
|
pisid->IdentifierAuthority.Value[2] )
|
|
|
|
) );
|
|
|
|
DumpString(buf, -1, pwptr, plen);
|
|
|
|
|
|
|
|
for( i=0; i<pisid->SubAuthorityCount; i++ )
|
|
|
|
{
|
|
|
|
sprintfW( buf, subauthfmt, pisid->SubAuthority[i] );
|
|
|
|
DumpString(buf, -1, pwptr, plen);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpSid(PSID psid, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
2008-07-21 23:12:04 +02:00
|
|
|
size_t i;
|
2007-09-25 22:12:50 +02:00
|
|
|
for (i = 0; i < sizeof(WellKnownSids) / sizeof(WellKnownSids[0]); i++)
|
|
|
|
{
|
|
|
|
if (WellKnownSids[i].wstr[0] && EqualSid(psid, (PSID)&(WellKnownSids[i].Sid.Revision)))
|
|
|
|
{
|
|
|
|
DumpString(WellKnownSids[i].wstr, 2, pwptr, plen);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DumpSidNumeric(psid, pwptr, plen);
|
|
|
|
}
|
|
|
|
|
2007-09-26 18:57:07 +02:00
|
|
|
static const LPCWSTR AceRightBitNames[32] = {
|
2007-09-25 22:12:50 +02:00
|
|
|
SDDL_CREATE_CHILD, /* 0 */
|
|
|
|
SDDL_DELETE_CHILD,
|
|
|
|
SDDL_LIST_CHILDREN,
|
|
|
|
SDDL_SELF_WRITE,
|
|
|
|
SDDL_READ_PROPERTY, /* 4 */
|
|
|
|
SDDL_WRITE_PROPERTY,
|
|
|
|
SDDL_DELETE_TREE,
|
|
|
|
SDDL_LIST_OBJECT,
|
|
|
|
SDDL_CONTROL_ACCESS, /* 8 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL, /* 12 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SDDL_STANDARD_DELETE, /* 16 */
|
|
|
|
SDDL_READ_CONTROL,
|
|
|
|
SDDL_WRITE_DAC,
|
|
|
|
SDDL_WRITE_OWNER,
|
|
|
|
NULL, /* 20 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL, /* 24 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SDDL_GENERIC_ALL, /* 28 */
|
|
|
|
SDDL_GENERIC_EXECUTE,
|
|
|
|
SDDL_GENERIC_WRITE,
|
|
|
|
SDDL_GENERIC_READ
|
|
|
|
};
|
|
|
|
|
|
|
|
static void DumpRights(DWORD mask, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
2007-09-26 18:57:07 +02:00
|
|
|
static const WCHAR fmtW[] = {'0','x','%','x',0};
|
2007-09-25 22:12:50 +02:00
|
|
|
WCHAR buf[15];
|
2008-07-21 23:12:04 +02:00
|
|
|
size_t i;
|
2007-09-25 22:12:50 +02:00
|
|
|
|
|
|
|
if (mask == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* first check if the right have name */
|
|
|
|
for (i = 0; i < sizeof(AceRights)/sizeof(AceRights[0]); i++)
|
|
|
|
{
|
|
|
|
if (AceRights[i].wstr == NULL)
|
|
|
|
break;
|
|
|
|
if (mask == AceRights[i].value)
|
|
|
|
{
|
|
|
|
DumpString(AceRights[i].wstr, -1, pwptr, plen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then check if it can be built from bit names */
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
if ((mask & (1 << i)) && (AceRightBitNames[i] == NULL))
|
|
|
|
{
|
|
|
|
/* can't be built from bit names */
|
|
|
|
sprintfW(buf, fmtW, mask);
|
|
|
|
DumpString(buf, -1, pwptr, plen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* build from bit names */
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
if (mask & (1 << i))
|
|
|
|
DumpString(AceRightBitNames[i], -1, pwptr, plen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpAce(LPVOID pace, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
|
|
|
ACCESS_ALLOWED_ACE *piace; /* all the supported ACEs have the same memory layout */
|
2007-09-26 18:57:07 +02:00
|
|
|
static const WCHAR openbr = '(';
|
|
|
|
static const WCHAR closebr = ')';
|
|
|
|
static const WCHAR semicolon = ';';
|
2007-09-25 22:12:50 +02:00
|
|
|
|
|
|
|
if (((PACE_HEADER)pace)->AceType > SYSTEM_ALARM_ACE_TYPE || ((PACE_HEADER)pace)->AceSize < sizeof(ACCESS_ALLOWED_ACE))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_ACL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-02-16 09:53:37 +01:00
|
|
|
piace = pace;
|
2007-09-25 22:12:50 +02:00
|
|
|
DumpString(&openbr, 1, pwptr, plen);
|
|
|
|
switch (piace->Header.AceType)
|
|
|
|
{
|
|
|
|
case ACCESS_ALLOWED_ACE_TYPE:
|
|
|
|
DumpString(SDDL_ACCESS_ALLOWED, -1, pwptr, plen);
|
|
|
|
break;
|
|
|
|
case ACCESS_DENIED_ACE_TYPE:
|
|
|
|
DumpString(SDDL_ACCESS_DENIED, -1, pwptr, plen);
|
|
|
|
break;
|
|
|
|
case SYSTEM_AUDIT_ACE_TYPE:
|
|
|
|
DumpString(SDDL_AUDIT, -1, pwptr, plen);
|
|
|
|
break;
|
|
|
|
case SYSTEM_ALARM_ACE_TYPE:
|
|
|
|
DumpString(SDDL_ALARM, -1, pwptr, plen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DumpString(&semicolon, 1, pwptr, plen);
|
|
|
|
|
|
|
|
if (piace->Header.AceFlags & OBJECT_INHERIT_ACE)
|
|
|
|
DumpString(SDDL_OBJECT_INHERIT, -1, pwptr, plen);
|
|
|
|
if (piace->Header.AceFlags & CONTAINER_INHERIT_ACE)
|
|
|
|
DumpString(SDDL_CONTAINER_INHERIT, -1, pwptr, plen);
|
|
|
|
if (piace->Header.AceFlags & NO_PROPAGATE_INHERIT_ACE)
|
|
|
|
DumpString(SDDL_NO_PROPAGATE, -1, pwptr, plen);
|
|
|
|
if (piace->Header.AceFlags & INHERIT_ONLY_ACE)
|
|
|
|
DumpString(SDDL_INHERIT_ONLY, -1, pwptr, plen);
|
|
|
|
if (piace->Header.AceFlags & INHERITED_ACE)
|
|
|
|
DumpString(SDDL_INHERITED, -1, pwptr, plen);
|
|
|
|
if (piace->Header.AceFlags & SUCCESSFUL_ACCESS_ACE_FLAG)
|
|
|
|
DumpString(SDDL_AUDIT_SUCCESS, -1, pwptr, plen);
|
|
|
|
if (piace->Header.AceFlags & FAILED_ACCESS_ACE_FLAG)
|
|
|
|
DumpString(SDDL_AUDIT_FAILURE, -1, pwptr, plen);
|
|
|
|
DumpString(&semicolon, 1, pwptr, plen);
|
|
|
|
DumpRights(piace->Mask, pwptr, plen);
|
|
|
|
DumpString(&semicolon, 1, pwptr, plen);
|
|
|
|
/* objects not supported */
|
|
|
|
DumpString(&semicolon, 1, pwptr, plen);
|
|
|
|
/* objects not supported */
|
|
|
|
DumpString(&semicolon, 1, pwptr, plen);
|
2009-02-16 09:53:37 +01:00
|
|
|
if (!DumpSid(&piace->SidStart, pwptr, plen))
|
2007-09-25 22:12:50 +02:00
|
|
|
return FALSE;
|
|
|
|
DumpString(&closebr, 1, pwptr, plen);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpAcl(PACL pacl, WCHAR **pwptr, ULONG *plen, BOOL protected, BOOL autoInheritReq, BOOL autoInherited)
|
|
|
|
{
|
|
|
|
WORD count;
|
2012-12-28 23:05:26 +01:00
|
|
|
UINT i;
|
2007-09-25 22:12:50 +02:00
|
|
|
|
|
|
|
if (protected)
|
|
|
|
DumpString(SDDL_PROTECTED, -1, pwptr, plen);
|
|
|
|
if (autoInheritReq)
|
|
|
|
DumpString(SDDL_AUTO_INHERIT_REQ, -1, pwptr, plen);
|
|
|
|
if (autoInherited)
|
|
|
|
DumpString(SDDL_AUTO_INHERITED, -1, pwptr, plen);
|
|
|
|
|
|
|
|
if (pacl == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (!IsValidAcl(pacl))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
count = pacl->AceCount;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
LPVOID ace;
|
|
|
|
if (!GetAce(pacl, i, &ace))
|
|
|
|
return FALSE;
|
|
|
|
if (!DumpAce(ace, pwptr, plen))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpOwner(PSECURITY_DESCRIPTOR SecurityDescriptor, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
2007-09-26 18:57:07 +02:00
|
|
|
static const WCHAR prefix[] = {'O',':',0};
|
2007-09-25 22:12:50 +02:00
|
|
|
BOOL bDefaulted;
|
|
|
|
PSID psid;
|
|
|
|
|
|
|
|
if (!GetSecurityDescriptorOwner(SecurityDescriptor, &psid, &bDefaulted))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (psid == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
DumpString(prefix, -1, pwptr, plen);
|
|
|
|
if (!DumpSid(psid, pwptr, plen))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpGroup(PSECURITY_DESCRIPTOR SecurityDescriptor, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
2007-09-26 18:57:07 +02:00
|
|
|
static const WCHAR prefix[] = {'G',':',0};
|
2007-09-25 22:12:50 +02:00
|
|
|
BOOL bDefaulted;
|
|
|
|
PSID psid;
|
|
|
|
|
|
|
|
if (!GetSecurityDescriptorGroup(SecurityDescriptor, &psid, &bDefaulted))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (psid == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
DumpString(prefix, -1, pwptr, plen);
|
|
|
|
if (!DumpSid(psid, pwptr, plen))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpDacl(PSECURITY_DESCRIPTOR SecurityDescriptor, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
|
|
|
static const WCHAR dacl[] = {'D',':',0};
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL control;
|
|
|
|
BOOL present, defaulted;
|
|
|
|
DWORD revision;
|
|
|
|
PACL pacl;
|
|
|
|
|
|
|
|
if (!GetSecurityDescriptorDacl(SecurityDescriptor, &present, &pacl, &defaulted))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!GetSecurityDescriptorControl(SecurityDescriptor, &control, &revision))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!present)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
DumpString(dacl, 2, pwptr, plen);
|
|
|
|
if (!DumpAcl(pacl, pwptr, plen, control & SE_DACL_PROTECTED, control & SE_DACL_AUTO_INHERIT_REQ, control & SE_DACL_AUTO_INHERITED))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL DumpSacl(PSECURITY_DESCRIPTOR SecurityDescriptor, WCHAR **pwptr, ULONG *plen)
|
|
|
|
{
|
|
|
|
static const WCHAR sacl[] = {'S',':',0};
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL control;
|
|
|
|
BOOL present, defaulted;
|
|
|
|
DWORD revision;
|
|
|
|
PACL pacl;
|
|
|
|
|
|
|
|
if (!GetSecurityDescriptorSacl(SecurityDescriptor, &present, &pacl, &defaulted))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!GetSecurityDescriptorControl(SecurityDescriptor, &control, &revision))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!present)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
DumpString(sacl, 2, pwptr, plen);
|
|
|
|
if (!DumpAcl(pacl, pwptr, plen, control & SE_SACL_PROTECTED, control & SE_SACL_AUTO_INHERIT_REQ, control & SE_SACL_AUTO_INHERITED))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ConvertSecurityDescriptorToStringSecurityDescriptorA [ADVAPI32.@]
|
|
|
|
*/
|
2007-10-14 14:36:21 +02:00
|
|
|
BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorW(PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD SDRevision, SECURITY_INFORMATION RequestedInformation, LPWSTR *OutputString, PULONG OutputLen)
|
2007-09-25 22:12:50 +02:00
|
|
|
{
|
|
|
|
ULONG len;
|
|
|
|
WCHAR *wptr, *wstr;
|
|
|
|
|
|
|
|
if (SDRevision != SDDL_REVISION_1)
|
|
|
|
{
|
2014-01-09 15:02:45 +01:00
|
|
|
ERR("Program requested unknown SDDL revision %d\n", SDRevision);
|
2007-09-25 22:12:50 +02:00
|
|
|
SetLastError(ERROR_UNKNOWN_REVISION);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
if (RequestedInformation & OWNER_SECURITY_INFORMATION)
|
|
|
|
if (!DumpOwner(SecurityDescriptor, NULL, &len))
|
|
|
|
return FALSE;
|
|
|
|
if (RequestedInformation & GROUP_SECURITY_INFORMATION)
|
|
|
|
if (!DumpGroup(SecurityDescriptor, NULL, &len))
|
|
|
|
return FALSE;
|
|
|
|
if (RequestedInformation & DACL_SECURITY_INFORMATION)
|
|
|
|
if (!DumpDacl(SecurityDescriptor, NULL, &len))
|
|
|
|
return FALSE;
|
|
|
|
if (RequestedInformation & SACL_SECURITY_INFORMATION)
|
|
|
|
if (!DumpSacl(SecurityDescriptor, NULL, &len))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
wstr = wptr = LocalAlloc(0, (len + 1)*sizeof(WCHAR));
|
|
|
|
if (RequestedInformation & OWNER_SECURITY_INFORMATION)
|
2012-10-03 16:21:35 +02:00
|
|
|
if (!DumpOwner(SecurityDescriptor, &wptr, NULL)) {
|
|
|
|
LocalFree (wstr);
|
2007-09-25 22:12:50 +02:00
|
|
|
return FALSE;
|
2012-10-03 16:21:35 +02:00
|
|
|
}
|
2007-09-25 22:12:50 +02:00
|
|
|
if (RequestedInformation & GROUP_SECURITY_INFORMATION)
|
2012-10-03 16:21:35 +02:00
|
|
|
if (!DumpGroup(SecurityDescriptor, &wptr, NULL)) {
|
|
|
|
LocalFree (wstr);
|
2007-09-25 22:12:50 +02:00
|
|
|
return FALSE;
|
2012-10-03 16:21:35 +02:00
|
|
|
}
|
2007-09-25 22:12:50 +02:00
|
|
|
if (RequestedInformation & DACL_SECURITY_INFORMATION)
|
2012-10-03 16:21:35 +02:00
|
|
|
if (!DumpDacl(SecurityDescriptor, &wptr, NULL)) {
|
|
|
|
LocalFree (wstr);
|
2007-09-25 22:12:50 +02:00
|
|
|
return FALSE;
|
2012-10-03 16:21:35 +02:00
|
|
|
}
|
2007-09-25 22:12:50 +02:00
|
|
|
if (RequestedInformation & SACL_SECURITY_INFORMATION)
|
2012-10-03 16:21:35 +02:00
|
|
|
if (!DumpSacl(SecurityDescriptor, &wptr, NULL)) {
|
|
|
|
LocalFree (wstr);
|
2007-09-25 22:12:50 +02:00
|
|
|
return FALSE;
|
2012-10-03 16:21:35 +02:00
|
|
|
}
|
2007-09-25 22:12:50 +02:00
|
|
|
*wptr = 0;
|
|
|
|
|
|
|
|
TRACE("ret: %s, %d\n", wine_dbgstr_w(wstr), len);
|
|
|
|
*OutputString = wstr;
|
|
|
|
if (OutputLen)
|
|
|
|
*OutputLen = strlenW(*OutputString)+1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ConvertSecurityDescriptorToStringSecurityDescriptorA [ADVAPI32.@]
|
|
|
|
*/
|
2007-10-14 14:36:21 +02:00
|
|
|
BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD SDRevision, SECURITY_INFORMATION Information, LPSTR *OutputString, PULONG OutputLen)
|
2007-09-25 22:12:50 +02:00
|
|
|
{
|
|
|
|
LPWSTR wstr;
|
|
|
|
ULONG len;
|
|
|
|
if (ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor, SDRevision, Information, &wstr, &len))
|
|
|
|
{
|
|
|
|
int lenA;
|
|
|
|
|
|
|
|
lenA = WideCharToMultiByte(CP_ACP, 0, wstr, len, NULL, 0, NULL, NULL);
|
2014-08-27 13:48:17 +02:00
|
|
|
*OutputString = heap_alloc(lenA);
|
2007-09-25 22:12:50 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, wstr, len, *OutputString, lenA, NULL, NULL);
|
|
|
|
LocalFree(wstr);
|
|
|
|
|
|
|
|
if (OutputLen != NULL)
|
|
|
|
*OutputLen = lenA;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*OutputString = NULL;
|
|
|
|
if (OutputLen)
|
|
|
|
*OutputLen = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ConvertStringSidToSidW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConvertStringSidToSidW(LPCWSTR StringSid, PSID* Sid)
|
|
|
|
{
|
|
|
|
BOOL bret = FALSE;
|
|
|
|
DWORD cBytes;
|
|
|
|
|
2004-09-16 22:27:52 +02:00
|
|
|
TRACE("%s, %p\n", debugstr_w(StringSid), Sid);
|
2003-11-11 23:03:24 +01:00
|
|
|
if (GetVersion() & 0x80000000)
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
2004-09-16 22:27:52 +02:00
|
|
|
else if (!StringSid || !Sid)
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2003-11-11 23:03:24 +01:00
|
|
|
else if (ParseStringSidToSid(StringSid, NULL, &cBytes))
|
|
|
|
{
|
2007-12-01 17:14:25 +01:00
|
|
|
PSID pSid = *Sid = LocalAlloc(0, cBytes);
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
bret = ParseStringSidToSid(StringSid, pSid, &cBytes);
|
|
|
|
if (!bret)
|
|
|
|
LocalFree(*Sid);
|
|
|
|
}
|
2004-09-16 22:27:52 +02:00
|
|
|
return bret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ConvertStringSidToSidA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
|
|
|
|
{
|
|
|
|
BOOL bret = FALSE;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2004-09-16 22:27:52 +02:00
|
|
|
TRACE("%s, %p\n", debugstr_a(StringSid), Sid);
|
|
|
|
if (GetVersion() & 0x80000000)
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
else if (!StringSid || !Sid)
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
else
|
|
|
|
{
|
2012-09-13 22:54:37 +02:00
|
|
|
WCHAR *wStringSid = SERV_dup(StringSid);
|
2004-09-16 22:27:52 +02:00
|
|
|
bret = ConvertStringSidToSidW(wStringSid, Sid);
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(wStringSid);
|
2004-09-16 22:27:52 +02:00
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
return bret;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:47:06 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* ConvertSidToStringSidW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* format of SID string is:
|
|
|
|
* S-<count>-<auth>-<subauth1>-<subauth2>-<subauth3>...
|
|
|
|
* where
|
|
|
|
* <rev> is the revision of the SID encoded as decimal
|
|
|
|
* <auth> is the identifier authority encoded as hex
|
|
|
|
* <subauthN> is the subauthority id encoded as decimal
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConvertSidToStringSidW( PSID pSid, LPWSTR *pstr )
|
|
|
|
{
|
2007-09-25 22:13:38 +02:00
|
|
|
DWORD len = 0;
|
|
|
|
LPWSTR wstr, wptr;
|
2004-08-09 20:47:06 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", pSid, pstr );
|
|
|
|
|
2007-09-25 22:13:38 +02:00
|
|
|
len = 0;
|
|
|
|
if (!DumpSidNumeric(pSid, NULL, &len))
|
2004-09-16 22:27:52 +02:00
|
|
|
return FALSE;
|
2007-09-25 22:13:38 +02:00
|
|
|
wstr = wptr = LocalAlloc(0, (len+1) * sizeof(WCHAR));
|
|
|
|
DumpSidNumeric(pSid, &wptr, NULL);
|
|
|
|
*wptr = 0;
|
2004-08-09 20:47:06 +02:00
|
|
|
|
2007-09-25 22:13:38 +02:00
|
|
|
*pstr = wstr;
|
2004-08-09 20:47:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ConvertSidToStringSidA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConvertSidToStringSidA(PSID pSid, LPSTR *pstr)
|
|
|
|
{
|
|
|
|
LPWSTR wstr = NULL;
|
|
|
|
LPSTR str;
|
|
|
|
UINT len;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", pSid, pstr );
|
|
|
|
|
|
|
|
if( !ConvertSidToStringSidW( pSid, &wstr ) )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL );
|
|
|
|
str = LocalAlloc( 0, len );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, len, NULL, NULL );
|
|
|
|
LocalFree( wstr );
|
|
|
|
|
|
|
|
*pstr = str;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-27 16:40:37 +02:00
|
|
|
BOOL WINAPI ConvertToAutoInheritPrivateObjectSecurity(
|
|
|
|
PSECURITY_DESCRIPTOR pdesc,
|
|
|
|
PSECURITY_DESCRIPTOR cdesc,
|
|
|
|
PSECURITY_DESCRIPTOR* ndesc,
|
|
|
|
GUID* objtype,
|
|
|
|
BOOL isdir,
|
|
|
|
PGENERIC_MAPPING genmap )
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p %p %d %p - stub\n", pdesc, cdesc, ndesc, objtype, isdir, genmap);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOL WINAPI CreatePrivateObjectSecurity(
|
|
|
|
PSECURITY_DESCRIPTOR ParentDescriptor,
|
|
|
|
PSECURITY_DESCRIPTOR CreatorDescriptor,
|
|
|
|
PSECURITY_DESCRIPTOR* NewDescriptor,
|
|
|
|
BOOL IsDirectoryObject,
|
|
|
|
HANDLE Token,
|
|
|
|
PGENERIC_MAPPING GenericMapping )
|
|
|
|
{
|
2012-03-30 12:19:23 +02:00
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *relative;
|
|
|
|
DWORD needed, offset;
|
|
|
|
BYTE *buffer;
|
|
|
|
|
|
|
|
FIXME("%p %p %p %d %p %p - returns fake SECURITY_DESCRIPTOR\n", ParentDescriptor,
|
|
|
|
CreatorDescriptor, NewDescriptor, IsDirectoryObject, Token, GenericMapping);
|
|
|
|
|
|
|
|
needed = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
|
|
|
|
needed += sizeof(sidWorld);
|
|
|
|
needed += sizeof(sidWorld);
|
|
|
|
needed += WINE_SIZE_OF_WORLD_ACCESS_ACL;
|
|
|
|
needed += WINE_SIZE_OF_WORLD_ACCESS_ACL;
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
if (!(buffer = heap_alloc( needed ))) return FALSE;
|
2012-03-30 12:19:23 +02:00
|
|
|
relative = (SECURITY_DESCRIPTOR_RELATIVE *)buffer;
|
|
|
|
if (!InitializeSecurityDescriptor( relative, SECURITY_DESCRIPTOR_REVISION ))
|
|
|
|
{
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( buffer );
|
2012-03-30 12:19:23 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
relative->Control |= SE_SELF_RELATIVE;
|
|
|
|
offset = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
|
2012-03-30 12:19:23 +02:00
|
|
|
memcpy( buffer + offset, &sidWorld, sizeof(sidWorld) );
|
|
|
|
relative->Owner = offset;
|
|
|
|
offset += sizeof(sidWorld);
|
|
|
|
|
|
|
|
memcpy( buffer + offset, &sidWorld, sizeof(sidWorld) );
|
|
|
|
relative->Group = offset;
|
|
|
|
offset += sizeof(sidWorld);
|
|
|
|
|
|
|
|
GetWorldAccessACL( (ACL *)(buffer + offset) );
|
|
|
|
relative->Dacl = offset;
|
|
|
|
offset += WINE_SIZE_OF_WORLD_ACCESS_ACL;
|
|
|
|
|
|
|
|
GetWorldAccessACL( (ACL *)(buffer + offset) );
|
|
|
|
relative->Sacl = offset;
|
|
|
|
|
|
|
|
*NewDescriptor = relative;
|
|
|
|
return TRUE;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
2015-10-09 12:21:21 +02:00
|
|
|
BOOL WINAPI CreatePrivateObjectSecurityWithMultipleInheritance(
|
|
|
|
PSECURITY_DESCRIPTOR parent, PSECURITY_DESCRIPTOR creator, PSECURITY_DESCRIPTOR *out,
|
|
|
|
GUID **types, ULONG count, BOOL is_container, ULONG flags, HANDLE token, PGENERIC_MAPPING mapping)
|
|
|
|
{
|
|
|
|
FIXME(": semi-stub\n");
|
|
|
|
return CreatePrivateObjectSecurity(parent, creator, out, is_container, token, mapping);
|
|
|
|
}
|
|
|
|
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOL WINAPI DestroyPrivateObjectSecurity( PSECURITY_DESCRIPTOR* ObjectDescriptor )
|
|
|
|
{
|
|
|
|
FIXME("%p - stub\n", ObjectDescriptor);
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( *ObjectDescriptor );
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CreateProcessAsUserA(
|
|
|
|
HANDLE hToken,
|
|
|
|
LPCSTR lpApplicationName,
|
|
|
|
LPSTR lpCommandLine,
|
|
|
|
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
|
|
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
|
|
|
BOOL bInheritHandles,
|
|
|
|
DWORD dwCreationFlags,
|
|
|
|
LPVOID lpEnvironment,
|
|
|
|
LPCSTR lpCurrentDirectory,
|
|
|
|
LPSTARTUPINFOA lpStartupInfo,
|
|
|
|
LPPROCESS_INFORMATION lpProcessInformation )
|
|
|
|
{
|
2012-09-13 22:54:41 +02:00
|
|
|
BOOL ret;
|
|
|
|
WCHAR *appW, *cmdlnW, *cwdW;
|
|
|
|
STARTUPINFOW sinfo;
|
|
|
|
|
|
|
|
TRACE("%p %s %s %p %p %d 0x%08x %p %s %p %p\n", hToken, debugstr_a(lpApplicationName),
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
debugstr_a(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles,
|
|
|
|
dwCreationFlags, lpEnvironment, debugstr_a(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
|
|
|
|
|
2012-09-13 22:54:41 +02:00
|
|
|
appW = SERV_dup(lpApplicationName);
|
|
|
|
cmdlnW = SERV_dup(lpCommandLine);
|
|
|
|
cwdW = SERV_dup(lpCurrentDirectory);
|
|
|
|
sinfo.cb = sizeof(sinfo);
|
|
|
|
sinfo.lpReserved = SERV_dup(lpStartupInfo->lpReserved);
|
|
|
|
sinfo.lpDesktop = SERV_dup(lpStartupInfo->lpDesktop);
|
|
|
|
sinfo.lpTitle = SERV_dup(lpStartupInfo->lpTitle);
|
|
|
|
sinfo.dwX = lpStartupInfo->dwX;
|
|
|
|
sinfo.dwY = lpStartupInfo->dwY;
|
|
|
|
sinfo.dwXSize = lpStartupInfo->dwXSize;
|
|
|
|
sinfo.dwYSize = lpStartupInfo->dwYSize;
|
|
|
|
sinfo.dwXCountChars = lpStartupInfo->dwXCountChars;
|
|
|
|
sinfo.dwYCountChars = lpStartupInfo->dwYCountChars;
|
|
|
|
sinfo.dwFillAttribute = lpStartupInfo->dwFillAttribute;
|
|
|
|
sinfo.dwFlags = lpStartupInfo->dwFlags;
|
|
|
|
sinfo.wShowWindow = lpStartupInfo->wShowWindow;
|
|
|
|
sinfo.cbReserved2 = lpStartupInfo->cbReserved2;
|
|
|
|
sinfo.lpReserved2 = lpStartupInfo->lpReserved2;
|
|
|
|
sinfo.hStdInput = lpStartupInfo->hStdInput;
|
|
|
|
sinfo.hStdOutput = lpStartupInfo->hStdOutput;
|
|
|
|
sinfo.hStdError = lpStartupInfo->hStdError;
|
|
|
|
ret = CreateProcessAsUserW(hToken, appW, cmdlnW, lpProcessAttributes,
|
|
|
|
lpThreadAttributes, bInheritHandles, dwCreationFlags,
|
|
|
|
lpEnvironment, cwdW, &sinfo, lpProcessInformation);
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free(appW);
|
|
|
|
heap_free(cmdlnW);
|
|
|
|
heap_free(cwdW);
|
|
|
|
heap_free(sinfo.lpReserved);
|
|
|
|
heap_free(sinfo.lpDesktop);
|
|
|
|
heap_free(sinfo.lpTitle);
|
2012-09-13 22:54:41 +02:00
|
|
|
|
|
|
|
return ret;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI CreateProcessAsUserW(
|
|
|
|
HANDLE hToken,
|
|
|
|
LPCWSTR lpApplicationName,
|
|
|
|
LPWSTR lpCommandLine,
|
|
|
|
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
|
|
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
|
|
|
BOOL bInheritHandles,
|
|
|
|
DWORD dwCreationFlags,
|
|
|
|
LPVOID lpEnvironment,
|
|
|
|
LPCWSTR lpCurrentDirectory,
|
|
|
|
LPSTARTUPINFOW lpStartupInfo,
|
|
|
|
LPPROCESS_INFORMATION lpProcessInformation )
|
|
|
|
{
|
2014-01-11 16:02:02 +01:00
|
|
|
FIXME("%p %s %s %p %p %d 0x%08x %p %s %p %p - semi-stub\n", hToken,
|
2005-04-13 13:02:59 +02:00
|
|
|
debugstr_w(lpApplicationName), debugstr_w(lpCommandLine), lpProcessAttributes,
|
|
|
|
lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
|
|
|
|
debugstr_w(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
|
|
|
|
|
|
|
|
/* We should create the process with a suspended main thread */
|
|
|
|
if (!CreateProcessW (lpApplicationName,
|
|
|
|
lpCommandLine,
|
|
|
|
lpProcessAttributes,
|
|
|
|
lpThreadAttributes,
|
|
|
|
bInheritHandles,
|
|
|
|
dwCreationFlags, /* CREATE_SUSPENDED */
|
|
|
|
lpEnvironment,
|
|
|
|
lpCurrentDirectory,
|
|
|
|
lpStartupInfo,
|
|
|
|
lpProcessInformation))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
|
2005-04-13 13:02:59 +02:00
|
|
|
return TRUE;
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
2007-11-27 21:48:53 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CreateProcessWithLogonW
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CreateProcessWithLogonW( LPCWSTR lpUsername, LPCWSTR lpDomain, LPCWSTR lpPassword, DWORD dwLogonFlags,
|
|
|
|
LPCWSTR lpApplicationName, LPWSTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment,
|
|
|
|
LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation )
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s 0x%08x %s %s 0x%08x %p %s %p %p stub\n", debugstr_w(lpUsername), debugstr_w(lpDomain),
|
|
|
|
debugstr_w(lpPassword), dwLogonFlags, debugstr_w(lpApplicationName),
|
|
|
|
debugstr_w(lpCommandLine), dwCreationFlags, lpEnvironment, debugstr_w(lpCurrentDirectory),
|
|
|
|
lpStartupInfo, lpProcessInformation);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-22 22:53:55 +01:00
|
|
|
BOOL WINAPI CreateProcessWithTokenW(HANDLE token, DWORD logon_flags, LPCWSTR application_name, LPWSTR command_line,
|
|
|
|
DWORD creation_flags, void *environment, LPCWSTR current_directory, STARTUPINFOW *startup_info,
|
|
|
|
PROCESS_INFORMATION *process_information )
|
|
|
|
{
|
|
|
|
FIXME("%p 0x%08x %s %s 0x%08x %p %s %p %p - semi-stub\n", token,
|
|
|
|
logon_flags, debugstr_w(application_name), debugstr_w(command_line),
|
|
|
|
creation_flags, environment, debugstr_w(current_directory),
|
|
|
|
startup_info, process_information);
|
|
|
|
|
|
|
|
/* FIXME: check if handles should be inherited */
|
|
|
|
return CreateProcessW( application_name, command_line, NULL, NULL, FALSE, creation_flags, environment,
|
|
|
|
current_directory, startup_info, process_information );
|
|
|
|
}
|
|
|
|
|
2006-11-12 20:23:28 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* DuplicateTokenEx [ADVAPI32.@]
|
|
|
|
*/
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
BOOL WINAPI DuplicateTokenEx(
|
|
|
|
HANDLE ExistingTokenHandle, DWORD dwDesiredAccess,
|
|
|
|
LPSECURITY_ATTRIBUTES lpTokenAttributes,
|
|
|
|
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
|
|
|
TOKEN_TYPE TokenType,
|
|
|
|
PHANDLE DuplicateTokenHandle )
|
|
|
|
{
|
2005-02-11 12:52:06 +01:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("%p 0x%08x 0x%08x 0x%08x %p\n", ExistingTokenHandle, dwDesiredAccess,
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
ImpersonationLevel, TokenType, DuplicateTokenHandle);
|
|
|
|
|
2005-02-11 12:52:06 +01:00
|
|
|
InitializeObjectAttributes(
|
|
|
|
&ObjectAttributes,
|
|
|
|
NULL,
|
|
|
|
(lpTokenAttributes && lpTokenAttributes->bInheritHandle) ? OBJ_INHERIT : 0,
|
|
|
|
NULL,
|
|
|
|
lpTokenAttributes ? lpTokenAttributes->lpSecurityDescriptor : NULL );
|
|
|
|
|
|
|
|
return set_ntstatus( NtDuplicateToken( ExistingTokenHandle,
|
|
|
|
dwDesiredAccess,
|
|
|
|
&ObjectAttributes,
|
|
|
|
ImpersonationLevel,
|
|
|
|
TokenType,
|
|
|
|
DuplicateTokenHandle ) );
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DuplicateToken(
|
|
|
|
HANDLE ExistingTokenHandle,
|
|
|
|
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
|
|
|
PHANDLE DuplicateTokenHandle )
|
|
|
|
{
|
2005-06-15 12:20:17 +02:00
|
|
|
return DuplicateTokenEx( ExistingTokenHandle, TOKEN_IMPERSONATE | TOKEN_QUERY,
|
|
|
|
NULL, ImpersonationLevel, TokenImpersonation,
|
|
|
|
DuplicateTokenHandle );
|
Stub implementations for AdjustTokenGroups, AreAllAccessesGranted,
CreatePrivateObjectSecurity, CreateProcessAsUser{A,W},
DestroyPrivateObjectSecurity, DuplicateToken{,Ex},
EnumDependentServices{A,W}, GetEffectiveRightsFromAcl{A,W},
ConvertStringSecurityDescriptorToSecurityDescriptorA. Implementations
for BuildExplicitAccessWithName{A,W},
BuildTrusteeWithObjectsAndName{A,W},
BuildTrusteeWithObjectsAndSid{A,W}.
Correct prototype for InitializeAcl, RtlCopySid and RtlGetAce.
Use the CallWin32ToNt macro only with functions that return an
NTSTATUS.
2004-12-21 17:16:10 +01:00
|
|
|
}
|
|
|
|
|
2006-06-12 17:37:07 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* ComputeStringSidSize
|
|
|
|
*/
|
|
|
|
static DWORD ComputeStringSidSize(LPCWSTR StringSid)
|
|
|
|
{
|
2007-07-18 19:06:36 +02:00
|
|
|
if (StringSid[0] == 'S' && StringSid[1] == '-') /* S-R-I(-S)+ */
|
2006-06-12 17:37:07 +02:00
|
|
|
{
|
|
|
|
int ctok = 0;
|
|
|
|
while (*StringSid)
|
|
|
|
{
|
|
|
|
if (*StringSid == '-')
|
|
|
|
ctok++;
|
|
|
|
StringSid++;
|
|
|
|
}
|
|
|
|
|
2007-07-18 19:06:36 +02:00
|
|
|
if (ctok >= 3)
|
|
|
|
return GetSidLengthRequired(ctok - 2);
|
2006-06-12 17:37:07 +02:00
|
|
|
}
|
|
|
|
else /* String constant format - Only available in winxp and above */
|
|
|
|
{
|
2007-09-21 22:17:23 +02:00
|
|
|
unsigned int i;
|
2006-06-12 17:37:07 +02:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
|
|
|
|
if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
|
2007-07-18 19:06:36 +02:00
|
|
|
return GetSidLengthRequired(WellKnownSids[i].Sid.SubAuthorityCount);
|
2012-11-13 05:31:24 +01:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
|
|
|
|
if (!strncmpW(WellKnownRids[i].wstr, StringSid, 2))
|
|
|
|
{
|
|
|
|
MAX_SID local;
|
|
|
|
ADVAPI_GetComputerSid(&local);
|
|
|
|
return GetSidLengthRequired(*GetSidSubAuthorityCount(&local) + 1);
|
|
|
|
}
|
|
|
|
|
2006-06-12 17:37:07 +02:00
|
|
|
}
|
|
|
|
|
2007-07-18 19:06:36 +02:00
|
|
|
return GetSidLengthRequired(0);
|
2006-06-12 17:37:07 +02:00
|
|
|
}
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ParseStringSidToSid
|
|
|
|
*/
|
|
|
|
static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
|
|
|
|
{
|
|
|
|
BOOL bret = FALSE;
|
2004-08-14 01:55:43 +02:00
|
|
|
SID* pisid=pSid;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2004-09-16 22:27:52 +02:00
|
|
|
TRACE("%s, %p, %p\n", debugstr_w(StringSid), pSid, cBytes);
|
2003-11-11 23:03:24 +01:00
|
|
|
if (!StringSid)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2004-09-16 22:27:52 +02:00
|
|
|
TRACE("StringSid is NULL, returning FALSE\n");
|
2006-06-12 17:37:49 +02:00
|
|
|
return FALSE;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
2009-10-13 15:39:47 +02:00
|
|
|
while (*StringSid == ' ')
|
|
|
|
StringSid++;
|
|
|
|
|
2003-11-11 23:03:24 +01:00
|
|
|
*cBytes = ComputeStringSidSize(StringSid);
|
2004-08-14 01:55:43 +02:00
|
|
|
if (!pisid) /* Simply compute the size */
|
2004-09-16 22:27:52 +02:00
|
|
|
{
|
2012-11-13 05:31:24 +01:00
|
|
|
TRACE("only size requested, returning TRUE with %d\n", *cBytes);
|
2003-11-11 23:03:24 +01:00
|
|
|
return TRUE;
|
2004-09-16 22:27:52 +02:00
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2005-09-16 20:44:17 +02:00
|
|
|
if (StringSid[0] == 'S' && StringSid[1] == '-') /* S-R-I-S-S */
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
2004-09-16 22:27:52 +02:00
|
|
|
DWORD i = 0, identAuth;
|
2007-07-18 19:06:36 +02:00
|
|
|
DWORD csubauth = ((*cBytes - GetSidLengthRequired(0)) / sizeof(DWORD));
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
StringSid += 2; /* Advance to Revision */
|
2004-08-14 01:55:43 +02:00
|
|
|
pisid->Revision = atoiW(StringSid);
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2004-08-14 01:55:43 +02:00
|
|
|
if (pisid->Revision != SDDL_REVISION)
|
2004-09-16 22:27:52 +02:00
|
|
|
{
|
|
|
|
TRACE("Revision %d is unknown\n", pisid->Revision);
|
|
|
|
goto lend; /* ERROR_INVALID_SID */
|
|
|
|
}
|
|
|
|
if (csubauth == 0)
|
|
|
|
{
|
|
|
|
TRACE("SubAuthorityCount is 0\n");
|
|
|
|
goto lend; /* ERROR_INVALID_SID */
|
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2006-06-12 17:37:49 +02:00
|
|
|
pisid->SubAuthorityCount = csubauth;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2004-09-16 22:27:52 +02:00
|
|
|
/* Advance to identifier authority */
|
2006-06-12 17:37:49 +02:00
|
|
|
while (*StringSid && *StringSid != '-')
|
2004-09-16 22:27:52 +02:00
|
|
|
StringSid++;
|
|
|
|
if (*StringSid == '-')
|
|
|
|
StringSid++;
|
|
|
|
|
|
|
|
/* MS' implementation can't handle values greater than 2^32 - 1, so
|
|
|
|
* we don't either; assume most significant bytes are always 0
|
|
|
|
*/
|
|
|
|
pisid->IdentifierAuthority.Value[0] = 0;
|
|
|
|
pisid->IdentifierAuthority.Value[1] = 0;
|
|
|
|
identAuth = atoiW(StringSid);
|
|
|
|
pisid->IdentifierAuthority.Value[5] = identAuth & 0xff;
|
|
|
|
pisid->IdentifierAuthority.Value[4] = (identAuth & 0xff00) >> 8;
|
|
|
|
pisid->IdentifierAuthority.Value[3] = (identAuth & 0xff0000) >> 16;
|
|
|
|
pisid->IdentifierAuthority.Value[2] = (identAuth & 0xff000000) >> 24;
|
|
|
|
|
|
|
|
/* Advance to first sub authority */
|
|
|
|
while (*StringSid && *StringSid != '-')
|
|
|
|
StringSid++;
|
|
|
|
if (*StringSid == '-')
|
|
|
|
StringSid++;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
|
|
|
while (*StringSid)
|
2006-06-12 17:37:49 +02:00
|
|
|
{
|
2007-09-25 04:04:11 +02:00
|
|
|
pisid->SubAuthority[i++] = atoiW(StringSid);
|
|
|
|
|
2006-06-12 17:37:49 +02:00
|
|
|
while (*StringSid && *StringSid != '-')
|
2003-11-11 23:03:24 +01:00
|
|
|
StringSid++;
|
2006-06-12 17:45:24 +02:00
|
|
|
if (*StringSid == '-')
|
|
|
|
StringSid++;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
2006-06-12 17:37:49 +02:00
|
|
|
if (i != pisid->SubAuthorityCount)
|
2003-11-11 23:03:24 +01:00
|
|
|
goto lend; /* ERROR_INVALID_SID */
|
|
|
|
|
|
|
|
bret = TRUE;
|
|
|
|
}
|
|
|
|
else /* String constant format - Only available in winxp and above */
|
|
|
|
{
|
2007-09-21 22:17:23 +02:00
|
|
|
unsigned int i;
|
2004-08-14 01:55:43 +02:00
|
|
|
pisid->Revision = SDDL_REVISION;
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2006-06-12 17:37:07 +02:00
|
|
|
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
|
|
|
|
if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
|
|
|
|
{
|
|
|
|
DWORD j;
|
2006-07-29 02:21:49 +02:00
|
|
|
pisid->SubAuthorityCount = WellKnownSids[i].Sid.SubAuthorityCount;
|
|
|
|
pisid->IdentifierAuthority = WellKnownSids[i].Sid.IdentifierAuthority;
|
|
|
|
for (j = 0; j < WellKnownSids[i].Sid.SubAuthorityCount; j++)
|
|
|
|
pisid->SubAuthority[j] = WellKnownSids[i].Sid.SubAuthority[j];
|
2006-06-12 17:37:07 +02:00
|
|
|
bret = TRUE;
|
|
|
|
}
|
2003-11-11 23:03:24 +01:00
|
|
|
|
2012-11-13 05:31:24 +01:00
|
|
|
for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
|
|
|
|
if (!strncmpW(WellKnownRids[i].wstr, StringSid, 2))
|
|
|
|
{
|
|
|
|
ADVAPI_GetComputerSid(pisid);
|
|
|
|
pisid->SubAuthority[pisid->SubAuthorityCount] = WellKnownRids[i].Rid;
|
|
|
|
pisid->SubAuthorityCount++;
|
|
|
|
bret = TRUE;
|
|
|
|
}
|
|
|
|
|
2006-06-12 17:37:07 +02:00
|
|
|
if (!bret)
|
|
|
|
FIXME("String constant not supported: %s\n", debugstr_wn(StringSid, 2));
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lend:
|
|
|
|
if (!bret)
|
|
|
|
SetLastError(ERROR_INVALID_SID);
|
|
|
|
|
2004-09-16 22:27:52 +02:00
|
|
|
TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
|
2003-11-11 23:03:24 +01:00
|
|
|
return bret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetNamedSecurityInfoA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID* ppsidOwner, PSID* ppsidGroup, PACL* ppDacl, PACL* ppSacl,
|
|
|
|
PSECURITY_DESCRIPTOR* ppSecurityDescriptor)
|
|
|
|
{
|
2012-09-13 22:54:37 +02:00
|
|
|
LPWSTR wstr;
|
2004-08-06 19:31:17 +02:00
|
|
|
DWORD r;
|
|
|
|
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE("%s %d %d %p %p %p %p %p\n", pObjectName, ObjectType, SecurityInfo,
|
2003-11-11 23:03:24 +01:00
|
|
|
ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor);
|
2004-08-06 19:31:17 +02:00
|
|
|
|
2012-09-13 22:54:37 +02:00
|
|
|
wstr = SERV_dup(pObjectName);
|
2004-08-06 19:31:17 +02:00
|
|
|
r = GetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, ppsidOwner,
|
|
|
|
ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor );
|
|
|
|
|
2014-08-27 13:48:17 +02:00
|
|
|
heap_free( wstr );
|
2004-08-06 19:31:17 +02:00
|
|
|
|
|
|
|
return r;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetNamedSecurityInfoW [ADVAPI32.@]
|
|
|
|
*/
|
2005-04-11 16:25:41 +02:00
|
|
|
DWORD WINAPI GetNamedSecurityInfoW( LPWSTR name, SE_OBJECT_TYPE type,
|
|
|
|
SECURITY_INFORMATION info, PSID* owner, PSID* group, PACL* dacl,
|
|
|
|
PACL* sacl, PSECURITY_DESCRIPTOR* descriptor )
|
2003-11-11 23:03:24 +01:00
|
|
|
{
|
2012-11-26 20:13:47 +01:00
|
|
|
DWORD access = 0;
|
2013-01-18 18:59:01 +01:00
|
|
|
HANDLE handle;
|
|
|
|
DWORD err;
|
2005-04-11 16:25:41 +02:00
|
|
|
|
2006-10-03 15:48:41 +02:00
|
|
|
TRACE( "%s %d %d %p %p %p %p %p\n", debugstr_w(name), type, info, owner,
|
2005-04-11 16:25:41 +02:00
|
|
|
group, dacl, sacl, descriptor );
|
|
|
|
|
2010-08-24 11:04:35 +02:00
|
|
|
/* A NULL descriptor is allowed if any one of the other pointers is not NULL */
|
|
|
|
if (!name || !(owner||group||dacl||sacl||descriptor) ) return ERROR_INVALID_PARAMETER;
|
2005-04-11 16:25:41 +02:00
|
|
|
|
2010-08-24 11:04:35 +02:00
|
|
|
/* If no descriptor, we have to check that there's a pointer for the requested information */
|
|
|
|
if( !descriptor && (
|
|
|
|
((info & OWNER_SECURITY_INFORMATION) && !owner)
|
|
|
|
|| ((info & GROUP_SECURITY_INFORMATION) && !group)
|
|
|
|
|| ((info & DACL_SECURITY_INFORMATION) && !dacl)
|
|
|
|
|| ((info & SACL_SECURITY_INFORMATION) && !sacl) ))
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2012-11-26 20:13:47 +01:00
|
|
|
if (info & (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION))
|
|
|
|
access |= READ_CONTROL;
|
2007-06-25 16:00:38 +02:00
|
|
|
if (info & SACL_SECURITY_INFORMATION)
|
2012-11-26 20:13:47 +01:00
|
|
|
access |= ACCESS_SYSTEM_SECURITY;
|
2010-08-24 11:04:35 +02:00
|
|
|
|
2013-01-30 20:59:12 +01:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SE_SERVICE:
|
2013-02-02 16:52:04 +01:00
|
|
|
if (!(err = get_security_service( name, access, &handle )))
|
2013-01-30 20:59:12 +01:00
|
|
|
{
|
|
|
|
err = GetSecurityInfo( handle, type, info, owner, group, dacl, sacl, descriptor );
|
|
|
|
CloseServiceHandle( handle );
|
|
|
|
}
|
|
|
|
break;
|
2013-02-02 16:52:04 +01:00
|
|
|
case SE_REGISTRY_KEY:
|
|
|
|
if (!(err = get_security_regkey( name, access, &handle )))
|
|
|
|
{
|
|
|
|
err = GetSecurityInfo( handle, type, info, owner, group, dacl, sacl, descriptor );
|
|
|
|
RegCloseKey( handle );
|
|
|
|
}
|
|
|
|
break;
|
2013-01-30 20:59:12 +01:00
|
|
|
case SE_FILE_OBJECT:
|
2013-02-02 16:52:04 +01:00
|
|
|
if (!(err = get_security_file( name, access, &handle )))
|
2013-01-30 20:59:12 +01:00
|
|
|
{
|
|
|
|
err = GetSecurityInfo( handle, type, info, owner, group, dacl, sacl, descriptor );
|
|
|
|
CloseHandle( handle );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME( "Object type %d is not currently supported.\n", type );
|
|
|
|
if (owner) *owner = NULL;
|
|
|
|
if (group) *group = NULL;
|
|
|
|
if (dacl) *dacl = NULL;
|
|
|
|
if (sacl) *sacl = NULL;
|
|
|
|
if (descriptor) *descriptor = NULL;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2013-01-18 18:59:01 +01:00
|
|
|
return err;
|
2003-11-11 23:03:24 +01:00
|
|
|
}
|
2004-12-06 17:17:08 +01:00
|
|
|
|
2011-05-18 14:15:19 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetNamedSecurityInfoExW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetNamedSecurityInfoExW( LPCWSTR object, SE_OBJECT_TYPE type,
|
|
|
|
SECURITY_INFORMATION info, LPCWSTR provider, LPCWSTR property,
|
|
|
|
PACTRL_ACCESSW* access_list, PACTRL_AUDITW* audit_list, LPWSTR* owner, LPWSTR* group )
|
|
|
|
{
|
|
|
|
FIXME("(%s, %d, %d, %s, %s, %p, %p, %p, %p) stub\n", debugstr_w(object), type, info,
|
|
|
|
debugstr_w(provider), debugstr_w(property), access_list, audit_list, owner, group);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetNamedSecurityInfoExA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetNamedSecurityInfoExA( LPCSTR object, SE_OBJECT_TYPE type,
|
|
|
|
SECURITY_INFORMATION info, LPCSTR provider, LPCSTR property,
|
|
|
|
PACTRL_ACCESSA* access_list, PACTRL_AUDITA* audit_list, LPSTR* owner, LPSTR* group )
|
|
|
|
{
|
|
|
|
FIXME("(%s, %d, %d, %s, %s, %p, %p, %p, %p) stub\n", debugstr_a(object), type, info,
|
|
|
|
debugstr_a(provider), debugstr_a(property), access_list, audit_list, owner, group);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-12-06 17:17:08 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* DecryptFileW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DecryptFileW(LPCWSTR lpFileName, DWORD dwReserved)
|
|
|
|
{
|
2013-04-17 23:40:46 +02:00
|
|
|
FIXME("(%s, %08x): stub\n", debugstr_w(lpFileName), dwReserved);
|
2004-12-06 17:17:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DecryptFileA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DecryptFileA(LPCSTR lpFileName, DWORD dwReserved)
|
|
|
|
{
|
2013-04-17 23:40:46 +02:00
|
|
|
FIXME("(%s, %08x): stub\n", debugstr_a(lpFileName), dwReserved);
|
2004-12-06 17:17:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EncryptFileW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EncryptFileW(LPCWSTR lpFileName)
|
|
|
|
{
|
2013-04-17 23:40:46 +02:00
|
|
|
FIXME("(%s): stub\n", debugstr_w(lpFileName));
|
2004-12-06 17:17:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EncryptFileA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EncryptFileA(LPCSTR lpFileName)
|
|
|
|
{
|
2013-04-17 23:40:46 +02:00
|
|
|
FIXME("(%s): stub\n", debugstr_a(lpFileName));
|
2004-12-06 17:17:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2005-03-07 12:00:24 +01:00
|
|
|
|
2006-05-19 15:19:18 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* FileEncryptionStatusW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileEncryptionStatusW(LPCWSTR lpFileName, LPDWORD lpStatus)
|
|
|
|
{
|
|
|
|
FIXME("(%s %p): stub\n", debugstr_w(lpFileName), lpStatus);
|
|
|
|
if (!lpStatus)
|
|
|
|
return FALSE;
|
|
|
|
*lpStatus = FILE_SYSTEM_NOT_SUPPORT;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* FileEncryptionStatusA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileEncryptionStatusA(LPCSTR lpFileName, LPDWORD lpStatus)
|
|
|
|
{
|
|
|
|
FIXME("(%s %p): stub\n", debugstr_a(lpFileName), lpStatus);
|
|
|
|
if (!lpStatus)
|
|
|
|
return FALSE;
|
|
|
|
*lpStatus = FILE_SYSTEM_NOT_SUPPORT;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-07 12:00:24 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* SetSecurityInfo [ADVAPI32.@]
|
|
|
|
*/
|
2005-03-21 11:32:45 +01:00
|
|
|
DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
|
2005-03-07 12:00:24 +01:00
|
|
|
SECURITY_INFORMATION SecurityInfo, PSID psidOwner,
|
2012-11-15 18:16:23 +01:00
|
|
|
PSID psidGroup, PACL pDacl, PACL pSacl)
|
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR sd;
|
2015-03-27 11:12:04 +01:00
|
|
|
PACL dacl = pDacl;
|
2012-11-15 18:16:23 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
|
|
|
|
return ERROR_INVALID_SECURITY_DESCR;
|
|
|
|
|
|
|
|
if (SecurityInfo & OWNER_SECURITY_INFORMATION)
|
|
|
|
SetSecurityDescriptorOwner(&sd, psidOwner, FALSE);
|
|
|
|
if (SecurityInfo & GROUP_SECURITY_INFORMATION)
|
|
|
|
SetSecurityDescriptorGroup(&sd, psidGroup, FALSE);
|
|
|
|
if (SecurityInfo & DACL_SECURITY_INFORMATION)
|
2015-03-27 11:12:04 +01:00
|
|
|
{
|
2015-04-03 10:04:03 +02:00
|
|
|
if (ObjectType == SE_FILE_OBJECT && pDacl)
|
2015-03-27 11:12:04 +01:00
|
|
|
{
|
|
|
|
SECURITY_DESCRIPTOR_CONTROL control;
|
|
|
|
PSECURITY_DESCRIPTOR psd;
|
|
|
|
OBJECT_NAME_INFORMATION *name_info;
|
|
|
|
DWORD size, rev;
|
|
|
|
|
|
|
|
status = NtQuerySecurityObject(handle, SecurityInfo, NULL, 0, &size);
|
|
|
|
if (status != STATUS_BUFFER_TOO_SMALL)
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
|
|
|
|
psd = heap_alloc(size);
|
|
|
|
if (!psd)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
status = NtQuerySecurityObject(handle, SecurityInfo, psd, size, &size);
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
heap_free(psd);
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
status = RtlGetControlSecurityDescriptor(psd, &control, &rev);
|
|
|
|
heap_free(psd);
|
|
|
|
if (status)
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
/* TODO: copy some control flags to new sd */
|
|
|
|
|
|
|
|
/* inherit parent directory DACL */
|
|
|
|
if (!(control & SE_DACL_PROTECTED))
|
|
|
|
{
|
|
|
|
status = NtQueryObject(handle, ObjectNameInformation, NULL, 0, &size);
|
|
|
|
if (status != STATUS_INFO_LENGTH_MISMATCH)
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
|
|
|
|
name_info = heap_alloc(size);
|
|
|
|
if (!name_info)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
status = NtQueryObject(handle, ObjectNameInformation, name_info, size, NULL);
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
heap_free(name_info);
|
|
|
|
return RtlNtStatusToDosError(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (name_info->Name.Length-=2; name_info->Name.Length>0; name_info->Name.Length-=2)
|
|
|
|
if (name_info->Name.Buffer[name_info->Name.Length/2-1]=='\\' ||
|
|
|
|
name_info->Name.Buffer[name_info->Name.Length/2-1]=='/')
|
|
|
|
break;
|
|
|
|
if (name_info->Name.Length)
|
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
IO_STATUS_BLOCK io;
|
|
|
|
HANDLE parent;
|
|
|
|
PSECURITY_DESCRIPTOR parent_sd;
|
|
|
|
ACL *parent_dacl;
|
|
|
|
DWORD err = ERROR_ACCESS_DENIED;
|
|
|
|
|
|
|
|
name_info->Name.Buffer[name_info->Name.Length/2] = 0;
|
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.Attributes = 0;
|
|
|
|
attr.ObjectName = &name_info->Name;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
2015-10-30 12:53:59 +01:00
|
|
|
status = NtOpenFile(&parent, READ_CONTROL|SYNCHRONIZE, &attr, &io,
|
2015-03-27 11:12:04 +01:00
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
|
|
|
|
FILE_OPEN_FOR_BACKUP_INTENT);
|
|
|
|
heap_free(name_info);
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
err = GetSecurityInfo(parent, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,
|
|
|
|
NULL, NULL, &parent_dacl, NULL, &parent_sd);
|
|
|
|
CloseHandle(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!err)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dacl = heap_alloc_zero(pDacl->AclSize+parent_dacl->AclSize);
|
|
|
|
if (!dacl)
|
|
|
|
{
|
|
|
|
LocalFree(parent_sd);
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
|
|
|
memcpy(dacl, pDacl, pDacl->AclSize);
|
|
|
|
dacl->AclSize = pDacl->AclSize+parent_dacl->AclSize;
|
|
|
|
|
|
|
|
for (i=0; i<parent_dacl->AceCount; i++)
|
|
|
|
{
|
|
|
|
ACE_HEADER *ace;
|
|
|
|
|
|
|
|
if (!GetAce(parent_dacl, i, (void*)&ace))
|
|
|
|
continue;
|
|
|
|
if (!(ace->AceFlags & (OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE)))
|
|
|
|
continue;
|
|
|
|
if ((ace->AceFlags & (OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE)) !=
|
|
|
|
(OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE))
|
|
|
|
{
|
|
|
|
FIXME("unsupported flags: %x\n", ace->AceFlags);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ace->AceFlags & NO_PROPAGATE_INHERIT_ACE)
|
|
|
|
ace->AceFlags &= ~(OBJECT_INHERIT_ACE|CONTAINER_INHERIT_ACE|NO_PROPAGATE_INHERIT_ACE);
|
|
|
|
ace->AceFlags &= ~INHERIT_ONLY_ACE;
|
|
|
|
ace->AceFlags |= INHERITED_ACE;
|
|
|
|
|
|
|
|
if(!AddAce(dacl, ACL_REVISION, MAXDWORD, ace, ace->AceSize))
|
|
|
|
WARN("error adding inherited ACE\n");
|
|
|
|
}
|
|
|
|
LocalFree(parent_sd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
heap_free(name_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetSecurityDescriptorDacl(&sd, TRUE, dacl, FALSE);
|
|
|
|
}
|
2012-11-15 18:16:23 +01:00
|
|
|
if (SecurityInfo & SACL_SECURITY_INFORMATION)
|
|
|
|
SetSecurityDescriptorSacl(&sd, TRUE, pSacl, FALSE);
|
|
|
|
|
2013-01-18 18:58:48 +01:00
|
|
|
switch (ObjectType)
|
|
|
|
{
|
|
|
|
case SE_SERVICE:
|
|
|
|
FIXME("stub: Service objects are not supported at this time.\n");
|
|
|
|
status = STATUS_SUCCESS; /* Implement SetServiceObjectSecurity */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = NtSetSecurityObject(handle, SecurityInfo, &sd);
|
|
|
|
break;
|
|
|
|
}
|
2015-03-27 11:12:04 +01:00
|
|
|
if (dacl != pDacl)
|
|
|
|
heap_free(dacl);
|
2012-11-15 18:16:23 +01:00
|
|
|
return RtlNtStatusToDosError(status);
|
2005-03-07 12:00:24 +01:00
|
|
|
}
|
2009-01-15 07:30:11 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SaferCreateLevel [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SaferCreateLevel(DWORD ScopeId, DWORD LevelId, DWORD OpenFlags,
|
|
|
|
SAFER_LEVEL_HANDLE* LevelHandle, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
FIXME("(%u, %x, %u, %p, %p) stub\n", ScopeId, LevelId, OpenFlags, LevelHandle, lpReserved);
|
2010-07-20 14:50:37 +02:00
|
|
|
|
|
|
|
*LevelHandle = (SAFER_LEVEL_HANDLE)0xdeadbeef;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SaferComputeTokenFromLevel [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SaferComputeTokenFromLevel(SAFER_LEVEL_HANDLE handle, HANDLE token, PHANDLE access_token,
|
|
|
|
DWORD flags, LPVOID reserved)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %x, %p) stub\n", handle, token, access_token, flags, reserved);
|
|
|
|
|
|
|
|
*access_token = (HANDLE)0xdeadbeef;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SaferCloseLevel [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SaferCloseLevel(SAFER_LEVEL_HANDLE handle)
|
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", handle);
|
|
|
|
return TRUE;
|
2009-01-15 07:30:11 +01:00
|
|
|
}
|
2009-03-25 13:24:13 +01:00
|
|
|
|
|
|
|
DWORD WINAPI TreeResetNamedSecurityInfoW( LPWSTR pObjectName,
|
|
|
|
SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
|
|
|
|
PSID pOwner, PSID pGroup, PACL pDacl, PACL pSacl,
|
|
|
|
BOOL KeepExplicit, FN_PROGRESS fnProgress,
|
|
|
|
PROG_INVOKE_SETTING ProgressInvokeSetting, PVOID Args)
|
|
|
|
{
|
2014-01-11 16:02:02 +01:00
|
|
|
FIXME("(%s, %i, %i, %p, %p, %p, %p, %i, %p, %i, %p) stub\n",
|
2009-03-25 13:24:13 +01:00
|
|
|
debugstr_w(pObjectName), ObjectType, SecurityInfo, pOwner, pGroup,
|
|
|
|
pDacl, pSacl, KeepExplicit, fnProgress, ProgressInvokeSetting, Args);
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2009-08-11 20:09:58 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SaferGetPolicyInformation [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SaferGetPolicyInformation(DWORD scope, SAFER_POLICY_INFO_CLASS class, DWORD size,
|
|
|
|
PVOID buffer, PDWORD required, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
FIXME("(%u %u %u %p %p %p) stub\n", scope, class, size, buffer, required, lpReserved);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-04-01 18:29:24 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SaferSetLevelInformation [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SaferSetLevelInformation(SAFER_LEVEL_HANDLE handle, SAFER_OBJECT_INFO_CLASS infotype,
|
|
|
|
LPVOID buffer, DWORD size)
|
|
|
|
{
|
|
|
|
FIXME("(%p %u %p %u) stub\n", handle, infotype, buffer, size);
|
|
|
|
return FALSE;
|
|
|
|
}
|