diff options
author | Michael Adam <obnox@samba.org> | 2010-09-21 03:00:29 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2010-09-21 06:53:32 +0200 |
commit | f2a4d5536b68f344edab717c4e6dfbef15523499 (patch) | |
tree | e42827102d155ae9a75e565353bf26a5b36f3e86 /source3/services | |
parent | 8be007dbb0c10a0755a87639eccabd7f5cdd05b3 (diff) | |
download | samba-f2a4d5536b68f344edab717c4e6dfbef15523499.tar.gz samba-f2a4d5536b68f344edab717c4e6dfbef15523499.tar.bz2 samba-f2a4d5536b68f344edab717c4e6dfbef15523499.zip |
s3:services_db: create the "Security" subkey if it does not exist in svcctl_set_secdesc()
Windows behaves like this. - Tests will follow.
Diffstat (limited to 'source3/services')
-rw-r--r-- | source3/services/services_db.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 2807e7e05c..19fb1b5623 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -569,27 +569,35 @@ bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, struct security_token *token) { 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\\%s", KEY_SERVICES, name, - "Security"); + 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; } + wresult = reg_createkey(mem_ctx, key, "Security", REG_KEY_ALL, &key_security, &action); + if (!W_ERROR_IS_OK(wresult)) { + DEBUG(0, ("svcctl_set_secdesc: reg_createkey failed: " + "[%s\\Security] (%s)\n", key->key->name, + win_errstr(wresult))); + goto done; + } + status = marshall_sec_desc(mem_ctx, sec_desc, &value.data.data, &value.data.length); if (!NT_STATUS_IS_OK(status)) { @@ -599,7 +607,7 @@ bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc, value.type = REG_BINARY; - wresult = reg_setvalue(key, "Security", &value); + wresult = reg_setvalue(key_security, "Security", &value); if (!W_ERROR_IS_OK(wresult)) { DEBUG(0, ("svcctl_set_secdesc: reg_setvalue failed: %s\n", win_errstr(wresult))); |