summaryrefslogtreecommitdiff
path: root/source3/services/services_db.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-09-21 03:11:43 +0200
committerMichael Adam <obnox@samba.org>2010-09-21 06:53:32 +0200
commita6f0f912cc461dcca2b34242327c6fc82d6ff849 (patch)
tree90e6bd67b8d0d24f315558302d3ecdb31eb817ee /source3/services/services_db.c
parentf2a4d5536b68f344edab717c4e6dfbef15523499 (diff)
downloadsamba-a6f0f912cc461dcca2b34242327c6fc82d6ff849.tar.gz
samba-a6f0f912cc461dcca2b34242327c6fc82d6ff849.tar.bz2
samba-a6f0f912cc461dcca2b34242327c6fc82d6ff849.zip
s3:services_db: extract core of svcctl_set_secdesc to _internal version
The internal version operates on an already opened key.
Diffstat (limited to 'source3/services/services_db.c')
-rw-r--r--source3/services/services_db.c56
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);