Commit 2f2074a5 authored by Micah N Gorrell's avatar Micah N Gorrell Committed by Alexandre Julliard

advapi32: Replace usage of internal SERV_ functions with exported functions.

parent 549183fa
...@@ -32,9 +32,6 @@ BOOL ADVAPI_GetComputerSid(PSID sid) DECLSPEC_HIDDEN; ...@@ -32,9 +32,6 @@ BOOL ADVAPI_GetComputerSid(PSID sid) DECLSPEC_HIDDEN;
BOOL lookup_local_wellknown_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN; BOOL lookup_local_wellknown_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN;
BOOL lookup_local_user_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN; BOOL lookup_local_user_name(const LSA_UNICODE_STRING*, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE, BOOL*) DECLSPEC_HIDDEN;
WCHAR *SERV_dup(const char *str) DECLSPEC_HIDDEN; WCHAR *SERV_dup(const char *str) DECLSPEC_HIDDEN;
DWORD SERV_OpenSCManagerW(LPCWSTR, LPCWSTR, DWORD, SC_HANDLE*) DECLSPEC_HIDDEN;
DWORD SERV_OpenServiceW(SC_HANDLE, LPCWSTR, DWORD, SC_HANDLE*) DECLSPEC_HIDDEN;
NTSTATUS SERV_QueryServiceObjectSecurity(SC_HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, LPDWORD) DECLSPEC_HIDDEN;
const WCHAR *get_wellknown_privilege_name(const LUID *) DECLSPEC_HIDDEN; const WCHAR *get_wellknown_privilege_name(const LUID *) DECLSPEC_HIDDEN;
/* memory allocation functions */ /* memory allocation functions */
......
...@@ -415,16 +415,15 @@ static inline DWORD get_security_file( LPCWSTR full_file_name, DWORD access, HAN ...@@ -415,16 +415,15 @@ static inline DWORD get_security_file( LPCWSTR full_file_name, DWORD access, HAN
/* helper function for SE_SERVICE objects in [Get|Set]NamedSecurityInfo */ /* helper function for SE_SERVICE objects in [Get|Set]NamedSecurityInfo */
static inline DWORD get_security_service( LPWSTR full_service_name, DWORD access, HANDLE *service ) static inline DWORD get_security_service( LPWSTR full_service_name, DWORD access, HANDLE *service )
{ {
SC_HANDLE manager = 0; SC_HANDLE manager = OpenSCManagerW( NULL, NULL, access );
DWORD err; if (manager)
err = SERV_OpenSCManagerW( NULL, NULL, access, (SC_HANDLE *)&manager );
if (err == ERROR_SUCCESS)
{ {
err = SERV_OpenServiceW( manager, full_service_name, access, (SC_HANDLE *)service ); *service = OpenServiceW( manager, full_service_name, access);
CloseServiceHandle( manager ); CloseServiceHandle( manager );
if (*service)
return ERROR_SUCCESS;
} }
return err; return GetLastError();
} }
/* helper function for SE_REGISTRY_KEY objects in [Get|Set]NamedSecurityInfo */ /* helper function for SE_REGISTRY_KEY objects in [Get|Set]NamedSecurityInfo */
...@@ -1779,16 +1778,13 @@ BOOL WINAPI PrivilegedServiceAuditAlarmA( LPCSTR SubsystemName, LPCSTR ServiceNa ...@@ -1779,16 +1778,13 @@ BOOL WINAPI PrivilegedServiceAuditAlarmA( LPCSTR SubsystemName, LPCSTR ServiceNa
* RETURNS * RETURNS
* ERROR_SUCCESS if all's well, and a WIN32 error code otherwise. * ERROR_SUCCESS if all's well, and a WIN32 error code otherwise.
*/ */
DWORD WINAPI GetSecurityInfo( DWORD WINAPI GetSecurityInfo( HANDLE handle, SE_OBJECT_TYPE type, SECURITY_INFORMATION SecurityInfo,
HANDLE hObject, SE_OBJECT_TYPE ObjectType, PSID *ppsidOwner, PSID *ppsidGroup, PACL *ppDacl, PACL *ppSacl,
SECURITY_INFORMATION SecurityInfo, PSID *ppsidOwner, PSECURITY_DESCRIPTOR *ppSecurityDescriptor )
PSID *ppsidGroup, PACL *ppDacl, PACL *ppSacl,
PSECURITY_DESCRIPTOR *ppSecurityDescriptor
)
{ {
PSECURITY_DESCRIPTOR sd; PSECURITY_DESCRIPTOR sd;
NTSTATUS status; NTSTATUS status;
ULONG n1, n2; ULONG size;
BOOL present, defaulted; BOOL present, defaulted;
/* A NULL descriptor is allowed if any one of the other pointers is not NULL */ /* A NULL descriptor is allowed if any one of the other pointers is not NULL */
...@@ -1802,35 +1798,33 @@ DWORD WINAPI GetSecurityInfo( ...@@ -1802,35 +1798,33 @@ DWORD WINAPI GetSecurityInfo(
|| ((SecurityInfo & SACL_SECURITY_INFORMATION) && !ppSacl) )) || ((SecurityInfo & SACL_SECURITY_INFORMATION) && !ppSacl) ))
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
switch (ObjectType) if (type == SE_SERVICE)
{ {
case SE_SERVICE: if (!QueryServiceObjectSecurity( handle, SecurityInfo, NULL, 0, &size )
status = SERV_QueryServiceObjectSecurity(hObject, SecurityInfo, NULL, 0, &n1); && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
break; return GetLastError();
default:
status = NtQuerySecurityObject(hObject, SecurityInfo, NULL, 0, &n1);
break;
}
if (status != STATUS_BUFFER_TOO_SMALL && status != STATUS_SUCCESS)
return RtlNtStatusToDosError(status);
sd = LocalAlloc(0, n1); if (!(sd = LocalAlloc( 0, size ))) return ERROR_NOT_ENOUGH_MEMORY;
if (!sd)
return ERROR_NOT_ENOUGH_MEMORY;
switch (ObjectType) if (!QueryServiceObjectSecurity( handle, SecurityInfo, sd, size, &size ))
{ {
case SE_SERVICE: LocalFree(sd);
status = SERV_QueryServiceObjectSecurity(hObject, SecurityInfo, sd, n1, &n2); return GetLastError();
break;
default:
status = NtQuerySecurityObject(hObject, SecurityInfo, sd, n1, &n2);
break;
} }
if (status != STATUS_SUCCESS) }
else
{
status = NtQuerySecurityObject( handle, SecurityInfo, NULL, 0, &size );
if (status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
return RtlNtStatusToDosError( status );
if (!(sd = LocalAlloc( 0, size ))) return ERROR_NOT_ENOUGH_MEMORY;
if ((status = NtQuerySecurityObject( handle, SecurityInfo, sd, size, &size )))
{ {
LocalFree(sd); LocalFree(sd);
return RtlNtStatusToDosError(status); return RtlNtStatusToDosError( status );
}
} }
if (ppsidOwner) if (ppsidOwner)
......
...@@ -897,7 +897,7 @@ SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName, ...@@ -897,7 +897,7 @@ SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName,
* *
* See OpenSCManagerA. * See OpenSCManagerA.
*/ */
DWORD SERV_OpenSCManagerW( LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, static DWORD SERV_OpenSCManagerW( LPCWSTR lpMachineName, LPCWSTR lpDatabaseName,
DWORD dwDesiredAccess, SC_HANDLE *handle ) DWORD dwDesiredAccess, SC_HANDLE *handle )
{ {
DWORD r; DWORD r;
...@@ -1049,7 +1049,7 @@ SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, ...@@ -1049,7 +1049,7 @@ SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
* *
* See OpenServiceA. * See OpenServiceA.
*/ */
DWORD SERV_OpenServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName, static DWORD SERV_OpenServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName,
DWORD dwDesiredAccess, SC_HANDLE *handle ) DWORD dwDesiredAccess, SC_HANDLE *handle )
{ {
DWORD err; DWORD err;
...@@ -2484,7 +2484,7 @@ BOOL WINAPI ChangeServiceConfig2W( SC_HANDLE hService, DWORD dwInfoLevel, ...@@ -2484,7 +2484,7 @@ BOOL WINAPI ChangeServiceConfig2W( SC_HANDLE hService, DWORD dwInfoLevel,
return err == ERROR_SUCCESS; return err == ERROR_SUCCESS;
} }
NTSTATUS SERV_QueryServiceObjectSecurity(SC_HANDLE hService, static NTSTATUS SERV_QueryServiceObjectSecurity(SC_HANDLE hService,
SECURITY_INFORMATION dwSecurityInformation, SECURITY_INFORMATION dwSecurityInformation,
PSECURITY_DESCRIPTOR lpSecurityDescriptor, PSECURITY_DESCRIPTOR lpSecurityDescriptor,
DWORD cbBufSize, LPDWORD pcbBytesNeeded) DWORD cbBufSize, LPDWORD pcbBytesNeeded)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment