diff options
-rw-r--r-- | source3/services/services_db.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 19fb1b5623..dcfb018b41 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -88,6 +88,8 @@ struct service_display_info common_unix_svcs[] = { { NULL, NULL, NULL, NULL } }; +static WERROR svcctl_set_secdesc_internal(struct registry_key *key, + struct security_descriptor *sec_desc); /******************************************************************** ********************************************************************/ @@ -565,30 +567,15 @@ done: Wrapper to make storing a Service sd easier ********************************************************************/ -bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, - struct security_token *token) +static WERROR svcctl_set_secdesc_internal(struct registry_key *key, + struct security_descriptor *sec_desc) { - struct registry_key *key = NULL; struct registry_key *key_security = NULL; WERROR wresult; - char *path = NULL; struct registry_value value; NTSTATUS status; - bool ret = false; - TALLOC_CTX *mem_ctx = talloc_stackframe(); enum winreg_CreateAction action = REG_ACTION_NONE; - - path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, name); - if (path == NULL) { - goto done; - } - - wresult = reg_open_path(mem_ctx, path, REG_KEY_ALL, token, &key); - if ( !W_ERROR_IS_OK(wresult) ) { - DEBUG(0, ("svcctl_set_secdesc: key lookup failed! [%s] (%s)\n", - path, win_errstr(wresult))); - goto done; - } + TALLOC_CTX *mem_ctx = talloc_stackframe(); wresult = reg_createkey(mem_ctx, key, "Security", REG_KEY_ALL, &key_security, &action); if (!W_ERROR_IS_OK(wresult)) { @@ -601,7 +588,9 @@ bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, status = marshall_sec_desc(mem_ctx, sec_desc, &value.data.data, &value.data.length); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("svcctl_set_secdesc: ndr_push_struct_blob() failed!\n")); + DEBUG(0, ("svcctl_set_secdesc: marshall_sec_desc() failed: %s\n", + nt_errstr(status))); + wresult = ntstatus_to_werror(status); goto done; } @@ -611,10 +600,37 @@ bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, if (!W_ERROR_IS_OK(wresult)) { DEBUG(0, ("svcctl_set_secdesc: reg_setvalue failed: %s\n", win_errstr(wresult))); + } + +done: + talloc_free(mem_ctx); + return wresult; +} + +bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, + struct security_token *token) +{ + struct registry_key *key = NULL; + WERROR wresult; + char *path = NULL; + bool ret = false; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + + path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, name); + if (path == NULL) { goto done; } - ret = true; + wresult = reg_open_path(mem_ctx, path, REG_KEY_ALL, token, &key); + if ( !W_ERROR_IS_OK(wresult) ) { + DEBUG(0, ("svcctl_set_secdesc: key lookup failed! [%s] (%s)\n", + path, win_errstr(wresult))); + goto done; + } + + wresult = svcctl_set_secdesc_internal(key, sec_desc); + + ret = W_ERROR_IS_OK(wresult); done: talloc_free(mem_ctx); |