r24726: Add tests for getting/setting security descriptors (still failing at the...
authorJelmer Vernooij <jelmer@samba.org>
Mon, 27 Aug 2007 22:01:58 +0000 (22:01 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:02:57 +0000 (15:02 -0500)
source/lib/registry/interface.c
source/lib/registry/registry.h
source/lib/registry/tests/registry.c
source/rpc_server/winreg/rpc_winreg.c
source/samba4-knownfail

index 4d75e99f005f4f8d9dcfa6d0cc07fcda815771ad..4950e1dacda7f05520d499094544b341f0f5818a 100644 (file)
@@ -275,3 +275,28 @@ _PUBLIC_ WERROR reg_key_flush(struct registry_key *key)
 
        return key->context->ops->flush_key(key);
 }
+
+_PUBLIC_ WERROR reg_get_security(TALLOC_CTX *mem_ctx, 
+                                                                const struct registry_key *key, 
+                                                                struct security_descriptor **security)
+{
+       if (key == NULL)
+               return WERR_INVALID_PARAM;
+       
+       if (key->context->ops->get_security == NULL)
+               return WERR_NOT_SUPPORTED;
+
+       return key->context->ops->get_security(mem_ctx, key, security);
+}
+
+_PUBLIC_ WERROR reg_set_security(struct registry_key *key, 
+                                                                struct security_descriptor *security)
+{
+       if (key == NULL)
+               return WERR_INVALID_PARAM;
+       
+       if (key->context->ops->set_security == NULL)
+               return WERR_NOT_SUPPORTED;
+
+       return key->context->ops->set_security(key, security);
+}
index 9839786e012a21bf57b039ba1489a8ab9ddce207..616bbb82dcdf426b6e8d6b7fbf750b3c401e3330 100644 (file)
@@ -269,6 +269,12 @@ struct registry_key *reg_import_hive_key(struct registry_context *ctx,
                                                                             struct hive_key *hive, 
                                                                             uint32_t predef_key,
                                                                                 const char **elements);
+WERROR reg_get_security(TALLOC_CTX *mem_ctx, 
+                                                                const struct registry_key *key, 
+                                                                struct security_descriptor **security);
+
+WERROR reg_set_security(struct registry_key *key, 
+                                                                struct security_descriptor *security);
 
 
 #endif /* _REGISTRY_H */
index dfc8e09d57640abb64189e7529334dd17176491a..fd2e98eac89b23fb15e823fb813ccfcca4e116d1 100644 (file)
@@ -25,6 +25,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "torture/torture.h"
 #include "librpc/gen_ndr/winreg.h"
+#include "libcli/security/security.h"
 #include "system/filesys.h"
 
 NTSTATUS torture_temp_dir(struct torture_context *tctx, const char *prefix, 
@@ -365,6 +366,40 @@ static bool test_set_value(struct torture_context *tctx, const void *_data)
        return true;
 }
 
+/**
+ * Test getting/setting security descriptors
+ */
+static bool test_security(struct torture_context *tctx, const void *_data)
+{
+       const struct registry_context *rctx = _data;
+       struct registry_key *subkey = NULL, *root;
+       WERROR error;
+       uint32_t data = 42;
+       struct security_descriptor *osd, *nsd;
+
+       if (!create_test_key(tctx, rctx, "Düsseldorf", &root, &subkey))
+               return false;
+
+       osd = security_descriptor_create(tctx,
+                                       NULL, NULL,
+                                       SID_NT_AUTHENTICATED_USERS,
+                                       SEC_ACE_TYPE_ACCESS_ALLOWED,
+                                       SEC_GENERIC_ALL,
+                                       SEC_ACE_FLAG_OBJECT_INHERIT,
+                                       NULL);
+
+       error = reg_set_security(subkey, osd);
+       torture_assert_werr_ok(tctx, error, "setting security");
+
+       error = reg_get_security(tctx, subkey, &nsd);
+       torture_assert_werr_ok (tctx, error, "setting security");
+
+       torture_assert(tctx, security_descriptor_equal(osd, nsd), 
+                                  "security descriptor changed!");
+
+       return true;
+}
+
 /**
  * Test getting a value
  */
@@ -524,6 +559,8 @@ static void tcase_add_tests(struct torture_tcase *tcase)
        torture_tcase_add_simple_test(tcase, "query_key_nums", test_query_key_nums);
        torture_tcase_add_simple_test(tcase, "test_predef_key_by_name", 
                                                                  test_predef_key_by_name);
+       torture_tcase_add_simple_test(tcase, "security", 
+                                                                 test_security);
        torture_tcase_add_simple_test(tcase, "test_predef_key_by_name_invalid", 
                                                                  test_predef_key_by_name_invalid);
 }
index 11c366fcb71ed392053e91f05bb02aaf7aae242f..05f47a4483e227d19e3b8de3f6a9cf5902cb9e4b 100644 (file)
@@ -490,11 +490,7 @@ static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
        data.length = r->in.size;
        result = reg_val_set(key, r->in.name.name, r->in.type, data);
 
-       if (!W_ERROR_IS_OK(result)) { 
-               return result;
-       }
-
-       return WERR_OK;
+       return result;
 }
 
 
index d968ae06892782481921d5a9d3598dbe8743b962..451428077a9c91c5db6c8a272a0f1d7d40e9ef6c 100644 (file)
@@ -5,5 +5,6 @@ BASE-DELETE/deltest20a
 BASE-DELETE/deltest20b
 RAW-OPLOCK/OPLOCK
 RPC-WINREG
+LOCAL-REGISTRY/security # Not implemented yet
 RPC-WKSSVC.*NetWkstaGetInfo
 RPC-WKSSVC.*NetWkstaTransportEnum