summaryrefslogtreecommitdiff
path: root/source3/services
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-09-20 03:34:49 +0200
committerMichael Adam <obnox@samba.org>2010-09-21 06:53:30 +0200
commitd2794b05a6b8be40ebde4a47b9c03008242b1c46 (patch)
tree01184d5eb3e579c9d12a776e8cbca9624e0eee8b /source3/services
parent7cefb898729bc46e1ba9fd1c8b48e7aef0486339 (diff)
downloadsamba-d2794b05a6b8be40ebde4a47b9c03008242b1c46.tar.gz
samba-d2794b05a6b8be40ebde4a47b9c03008242b1c46.tar.bz2
samba-d2794b05a6b8be40ebde4a47b9c03008242b1c46.zip
s3:services_db: rewrite svcctl_set_secdesc to use tmp talloc ctx
and add a common exit point
Diffstat (limited to 'source3/services')
-rw-r--r--source3/services/services_db.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/source3/services/services_db.c b/source3/services/services_db.c
index f32b305505..cd05b0e586 100644
--- a/source3/services/services_db.c
+++ b/source3/services/services_db.c
@@ -581,31 +581,32 @@ bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_desc
char *path = NULL;
struct registry_value value;
NTSTATUS status;
- bool ret = False;
+ bool ret = false;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
/* now add the security descriptor */
- if (asprintf(&path, "%s\\%s\\%s", KEY_SERVICES, name, "Security") < 0) {
- return false;
+ path = talloc_asprintf(mem_ctx, "%s\\%s\\%s", KEY_SERVICES, name,
+ "Security");
+ if (path == NULL) {
+ goto done;
}
- wresult = reg_open_path(NULL, path, REG_KEY_ALL, token, &key);
+ wresult = reg_open_path(mem_ctx, path, REG_KEY_ALL, token, &key);
if ( !W_ERROR_IS_OK(wresult) ) {
DEBUG(0,("svcctl_get_secdesc: key lookup failed! [%s] (%s)\n",
path, win_errstr(wresult)));
- SAFE_FREE(path);
- return False;
+ goto done;
}
- SAFE_FREE(path);
/* stream the printer security descriptor */
- status = marshall_sec_desc(ctx, sec_desc, &value.data.data, &value.data.length);
+ 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"));
- TALLOC_FREE( key );
- return False;
+ goto done;
}
value.type = REG_BINARY;
@@ -614,14 +615,13 @@ bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_desc
if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0, ("svcctl_set_secdesc: reg_setvalue failed: %s\n",
win_errstr(wresult)));
- talloc_free(key);
- return false;
+ goto done;
}
- /* cleanup */
-
- TALLOC_FREE( key);
+ ret = true;
+done:
+ talloc_free(mem_ctx);
return ret;
}