*/
#include "includes.h"
+#include "services/services.h"
+#include "registry.h"
+#include "registry/reg_util_legacy.h"
+#include "registry/reg_dispatcher.h"
+#include "registry/reg_objects.h"
struct rcinit_file_information {
char *description;
/********************************************************************
********************************************************************/
-static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx )
+static struct security_descriptor* construct_service_sd( TALLOC_CTX *ctx )
{
- SEC_ACE ace[4];
+ struct security_ace ace[4];
size_t i = 0;
- SEC_DESC *sd = NULL;
- SEC_ACL *theacl = NULL;
+ struct security_descriptor *sd = NULL;
+ struct security_acl *theacl = NULL;
size_t sd_size;
/* basic access for Everyone */
/* create the security descriptor */
- if ( !(theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) )
+ theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace);
+ if (theacl == NULL) {
return NULL;
+ }
- if ( !(sd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1,
- SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL,
- theacl, &sd_size)) )
+ sd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1,
+ SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL,
+ theacl, &sd_size);
+ if (sd == NULL) {
return NULL;
+ }
return sd;
}
XFILE *f = NULL;
char *p = NULL;
- if ( !(info = TALLOC_ZERO_P( NULL, struct rcinit_file_information ) ) )
+ info = TALLOC_ZERO_P( NULL, struct rcinit_file_information );
+ if (info == NULL) {
return False;
+ }
/* attempt the file open */
TALLOC_FREE(info);
return false;
}
- if (!(f = x_fopen( filepath, O_RDONLY, 0 ))) {
+ f = x_fopen( filepath, O_RDONLY, 0 );
+ if (f == NULL) {
DEBUG(0,("read_init_file: failed to open [%s]\n", filepath));
TALLOC_FREE(info);
return false;
/* Look for a line like '^#.*Description:' */
- if ( (p = strstr( str, "Description:" )) != NULL ) {
+ p = strstr( str, "Description:" );
+ if (p != NULL) {
char *desc;
p += strlen( "Description:" ) + 1;
if ( !p )
break;
- if ( (desc = cleanup_string(p)) != NULL )
+ desc = cleanup_string(p);
+ if (desc != NULL)
info->description = talloc_strdup( info, desc );
}
}
I'm just storing them here for cosmetic purposes */
dword = SVCCTL_AUTO_START;
- regval_ctr_addvalue( values, "Start", REG_DWORD, (char*)&dword, sizeof(uint32));
+ regval_ctr_addvalue( values, "Start", REG_DWORD, (uint8 *)&dword, sizeof(uint32));
dword = SERVICE_TYPE_WIN32_OWN_PROCESS;
- regval_ctr_addvalue( values, "Type", REG_DWORD, (char*)&dword, sizeof(uint32));
+ regval_ctr_addvalue( values, "Type", REG_DWORD, (uint8 *)&dword, sizeof(uint32));
dword = SVCCTL_SVC_ERROR_NORMAL;
- regval_ctr_addvalue( values, "ErrorControl", REG_DWORD, (char*)&dword, sizeof(uint32));
+ regval_ctr_addvalue( values, "ErrorControl", REG_DWORD, (uint8 *)&dword, sizeof(uint32));
/* everything runs as LocalSystem */
char *path = NULL;
struct regval_ctr *values = NULL;
struct regsubkey_ctr *svc_subkeys = NULL;
- SEC_DESC *sd = NULL;
+ struct security_descriptor *sd = NULL;
DATA_BLOB sd_blob;
NTSTATUS status;
/* now for the service values */
- if ( !(values = TALLOC_ZERO_P( key_service, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(key_service, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("add_new_svc_name: talloc() failed!\n"));
TALLOC_FREE( key_service );
return;
}
SAFE_FREE(path);
- if ( !(values = TALLOC_ZERO_P( key_secdesc, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(key_secdesc, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("add_new_svc_name: talloc() failed!\n"));
TALLOC_FREE( key_secdesc );
return;
}
regval_ctr_addvalue(values, "Security", REG_BINARY,
- (const char *)sd_blob.data, sd_blob.length);
+ sd_blob.data, sd_blob.length);
store_reg_values( key_secdesc, values );
TALLOC_FREE( key_secdesc );
in case of any failure.
********************************************************************/
-SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token )
+struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, struct security_token *token )
{
struct registry_key_handle *key = NULL;
struct regval_ctr *values = NULL;
struct regval_blob *val = NULL;
- SEC_DESC *ret_sd = NULL;
+ struct security_descriptor *ret_sd = NULL;
char *path= NULL;
WERROR wresult;
NTSTATUS status;
goto done;
}
- if ( !(values = TALLOC_ZERO_P( key, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(key, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("svcctl_get_secdesc: talloc() failed!\n"));
goto done;
}
Wrapper to make storing a Service sd easier
********************************************************************/
-bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, NT_USER_TOKEN *token )
+bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_descriptor *sec_desc, struct security_token *token )
{
struct registry_key_handle *key = NULL;
WERROR wresult;
}
SAFE_FREE(path);
- if ( !(values = TALLOC_ZERO_P( key, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(key, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("svcctl_set_secdesc: talloc() failed!\n"));
TALLOC_FREE( key );
return False;
return False;
}
- regval_ctr_addvalue( values, "Security", REG_BINARY, (const char *)blob.data, blob.length);
+ regval_ctr_addvalue( values, "Security", REG_BINARY, blob.data, blob.length);
ret = store_reg_values( key, values );
/* cleanup */
/********************************************************************
********************************************************************/
-const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token )
+const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct security_token *token )
{
const char *display_name = NULL;
struct registry_key_handle *key = NULL;
}
SAFE_FREE(path);
- if ( !(values = TALLOC_ZERO_P( key, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(key, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("svcctl_lookup_dispname: talloc() failed!\n"));
TALLOC_FREE( key );
goto fail;
/********************************************************************
********************************************************************/
-const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token )
+const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token )
{
const char *description = NULL;
struct registry_key_handle *key = NULL;
}
SAFE_FREE(path);
- if ( !(values = TALLOC_ZERO_P( key, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(key, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("svcctl_lookup_description: talloc() failed!\n"));
TALLOC_FREE( key );
return NULL;
/********************************************************************
********************************************************************/
-struct regval_ctr *svcctl_fetch_regvalues(const char *name, NT_USER_TOKEN *token)
+struct regval_ctr *svcctl_fetch_regvalues(const char *name, struct security_token *token)
{
struct registry_key_handle *key = NULL;
struct regval_ctr *values = NULL;
}
SAFE_FREE(path);
- if ( !(values = TALLOC_ZERO_P( NULL, struct regval_ctr )) ) {
+ wresult = regval_ctr_init(NULL, &values);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("svcctl_fetch_regvalues: talloc() failed!\n"));
TALLOC_FREE( key );
return NULL;