Author: jelmer Date: 2007-08-27 22:01:58 +0000 (Mon, 27 Aug 2007) New Revision: 24726
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24726 Log: Add tests for getting/setting security descriptors (still failing at the moment) Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/lib/registry/interface.c branches/SAMBA_4_0/source/lib/registry/registry.h branches/SAMBA_4_0/source/lib/registry/tests/registry.c branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c branches/SAMBA_4_0/source/samba4-knownfail Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/SAMBA_4_0/source/lib/registry/interface.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/interface.c 2007-08-27 21:24:44 UTC (rev 24725) +++ branches/SAMBA_4_0/source/lib/registry/interface.c 2007-08-27 22:01:58 UTC (rev 24726) @@ -275,3 +275,28 @@ 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); +} Modified: branches/SAMBA_4_0/source/lib/registry/registry.h =================================================================== --- branches/SAMBA_4_0/source/lib/registry/registry.h 2007-08-27 21:24:44 UTC (rev 24725) +++ branches/SAMBA_4_0/source/lib/registry/registry.h 2007-08-27 22:01:58 UTC (rev 24726) @@ -269,6 +269,12 @@ 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 */ Modified: branches/SAMBA_4_0/source/lib/registry/tests/registry.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/tests/registry.c 2007-08-27 21:24:44 UTC (rev 24725) +++ branches/SAMBA_4_0/source/lib/registry/tests/registry.c 2007-08-27 22:01:58 UTC (rev 24726) @@ -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, @@ -366,6 +367,40 @@ } /** + * 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 */ static bool test_get_value(struct torture_context *tctx, const void *_data) @@ -524,6 +559,8 @@ 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); } Modified: branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c =================================================================== --- branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c 2007-08-27 21:24:44 UTC (rev 24725) +++ branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c 2007-08-27 22:01:58 UTC (rev 24726) @@ -490,11 +490,7 @@ 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; } Modified: branches/SAMBA_4_0/source/samba4-knownfail =================================================================== --- branches/SAMBA_4_0/source/samba4-knownfail 2007-08-27 21:24:44 UTC (rev 24725) +++ branches/SAMBA_4_0/source/samba4-knownfail 2007-08-27 22:01:58 UTC (rev 24726) @@ -5,5 +5,6 @@ BASE-DELETE/deltest20b RAW-OPLOCK/OPLOCK RPC-WINREG +LOCAL-REGISTRY/security # Not implemented yet RPC-WKSSVC.*NetWkstaGetInfo RPC-WKSSVC.*NetWkstaTransportEnum