summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-08-30 16:30:01 +0200
committerMichael Adam <obnox@samba.org>2011-09-02 00:51:40 +0200
commite579c84b4fc28ccf95cc8e6cc53c6001f5494ec1 (patch)
tree14d411be63503150143d0fd6be5013c65631417a /source3/registry
parent861f04bec0172b80d20773f9be882ce08f5e3784 (diff)
downloadsamba-e579c84b4fc28ccf95cc8e6cc53c6001f5494ec1.tar.gz
samba-e579c84b4fc28ccf95cc8e6cc53c6001f5494ec1.tar.bz2
samba-e579c84b4fc28ccf95cc8e6cc53c6001f5494ec1.zip
s3:registry: implement regdb_set_secdesc() with regdb_trans_do()
Autobuild-User: Michael Adam <obnox@samba.org> Autobuild-Date: Fri Sep 2 00:51:40 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_backend_db.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 43fa766d08..0218f05337 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -1892,47 +1892,68 @@ done:
return err;
}
-static WERROR regdb_set_secdesc(const char *key,
- struct security_descriptor *secdesc)
+struct regdb_set_secdesc_ctx {
+ const char *key;
+ struct security_descriptor *secdesc;
+};
+
+static NTSTATUS regdb_set_secdesc_action(struct db_context *db,
+ void *private_data)
{
- TALLOC_CTX *mem_ctx = talloc_stackframe();
char *tdbkey;
- WERROR err = WERR_NOMEM;
+ NTSTATUS status;
TDB_DATA tdbdata;
+ struct regdb_set_secdesc_ctx *ctx =
+ (struct regdb_set_secdesc_ctx *)private_data;
+ TALLOC_CTX *frame = talloc_stackframe();
- if (!regdb_key_exists(regdb, key)) {
- err = WERR_BADFILE;
+ tdbkey = talloc_asprintf(frame, "%s\\%s", REG_SECDESC_PREFIX, ctx->key);
+ if (tdbkey == NULL) {
goto done;
}
- tdbkey = talloc_asprintf(mem_ctx, "%s\\%s", REG_SECDESC_PREFIX, key);
+ tdbkey = normalize_reg_path(frame, tdbkey);
if (tdbkey == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto done;
}
- tdbkey = normalize_reg_path(mem_ctx, tdbkey);
- if (tdbkey == NULL) {
- err = WERR_NOMEM;
+ if (ctx->secdesc == NULL) {
+ /* assuming a delete */
+ status = dbwrap_delete_bystring(db, tdbkey);
goto done;
}
- if (secdesc == NULL) {
- /* assuming a delete */
- err = ntstatus_to_werror(dbwrap_trans_delete_bystring(regdb,
- tdbkey));
+ status = marshall_sec_desc(frame, ctx->secdesc, &tdbdata.dptr,
+ &tdbdata.dsize);
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- err = ntstatus_to_werror(marshall_sec_desc(mem_ctx, secdesc,
- &tdbdata.dptr,
- &tdbdata.dsize));
- W_ERROR_NOT_OK_GOTO_DONE(err);
+ status = dbwrap_store_bystring(db, tdbkey, tdbdata, 0);
- err = ntstatus_to_werror(dbwrap_trans_store_bystring(regdb, tdbkey,
- tdbdata, 0));
+done:
+ TALLOC_FREE(frame);
+ return status;
+}
- done:
- TALLOC_FREE(mem_ctx);
+static WERROR regdb_set_secdesc(const char *key,
+ struct security_descriptor *secdesc)
+{
+ WERROR err;
+ struct regdb_set_secdesc_ctx ctx;
+
+ if (!regdb_key_exists(regdb, key)) {
+ err = WERR_BADFILE;
+ goto done;
+ }
+
+ ctx.key = key;
+ ctx.secdesc = secdesc;
+
+ err = regdb_trans_do(regdb, regdb_set_secdesc_action, &ctx);
+
+done:
return err;
}