Author: jelmer Date: 2006-03-21 01:30:22 +0000 (Tue, 21 Mar 2006) New Revision: 14599
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14599 Log: Pass ACLs down the registry layer. Modified: branches/SAMBA_4_0/source/gtk/tools/gregedit.c branches/SAMBA_4_0/source/lib/ldb/common/ldb.c branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c branches/SAMBA_4_0/source/lib/registry/reg_samba.c branches/SAMBA_4_0/source/lib/registry/regf.idl branches/SAMBA_4_0/source/lib/registry/registry.h branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c branches/SAMBA_4_0/source/lib/registry/tools/regshell.c branches/SAMBA_4_0/source/lib/registry/tools/regtree.c branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c branches/SAMBA_4_0/source/torture/local/registry.c Changeset: Modified: branches/SAMBA_4_0/source/gtk/tools/gregedit.c =================================================================== --- branches/SAMBA_4_0/source/gtk/tools/gregedit.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/gtk/tools/gregedit.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -349,7 +349,7 @@ switch(result) { case GTK_RESPONSE_OK: filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(openfilewin))); - error = reg_open_hive(NULL, user_data, filename, NULL, &root); + error = reg_open_hive(NULL, user_data, filename, NULL, NULL, &root); if(!W_ERROR_IS_OK(error)) { gtk_show_werror(mainwin, "Error while opening hive", error); break; @@ -371,7 +371,7 @@ static void on_open_gconf_activate(GtkMenuItem *menuitem, gpointer user_data) { struct registry_key *root; - WERROR error = reg_open_hive(NULL, "gconf", NULL, NULL, &root); + WERROR error = reg_open_hive(NULL, "gconf", NULL, NULL, NULL, &root); if(!W_ERROR_IS_OK(error)) { gtk_show_werror(mainwin, "Error while opening GConf", error); return; @@ -385,7 +385,7 @@ static void on_open_local_activate(GtkMenuItem *menuitem, gpointer user_data) { - WERROR error = reg_open_local(®istry); + WERROR error = reg_open_local(®istry, NULL, NULL); if(!W_ERROR_IS_OK(error)) { gtk_show_werror(mainwin, "Error while opening local registry", error); return; @@ -412,6 +412,7 @@ cli_credentials_set_gtk_callbacks(creds); error = reg_open_remote(®istry, + NULL, creds, gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx), NULL); @@ -952,7 +953,7 @@ static int gregedit_load_defaults(void) { - WERROR error = reg_open_local(®istry); + WERROR error = reg_open_local(®istry, NULL, NULL); if(!W_ERROR_IS_OK(error)) { gtk_show_werror(mainwin, "Error while loading local registry", error); return -1; Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/common/ldb.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/ldb/common/ldb.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -106,7 +106,7 @@ ldb_connect_fn fn; if (strchr(url, ':') != NULL) { - backend = talloc_strndup(ldb, url, strchr(url, ':')-url-1); + backend = talloc_strndup(ldb, url, strchr(url, ':')-url); } else { /* Default to tdb */ backend = talloc_strdup(ldb, "tdb"); Modified: branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -161,7 +161,7 @@ } /** Open a registry file/host/etc */ -_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *backend, const char *location, const char *credentials, struct registry_key **root) +_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *backend, const char *location, struct auth_session_info *session_info, struct cli_credentials *credentials, struct registry_key **root) { struct registry_hive *rethive; struct registry_key *retkey = NULL; @@ -181,6 +181,8 @@ rethive = talloc(parent_ctx, struct registry_hive); rethive->location = location?talloc_strdup(rethive, location):NULL; + rethive->session_info = talloc_reference(rethive, session_info); + rethive->credentials = talloc_reference(rethive, credentials); rethive->functions = entry->hive_functions; rethive->backend_data = NULL; Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -262,9 +262,9 @@ struct ldb_context *wrap; if (!hive->location) return WERR_INVALID_PARAM; - /* TODO: Support remoting with credentials and ACLs with session tokens */ - wrap = ldb_wrap_connect(hive, hive->location, NULL, NULL, 0, NULL); + wrap = ldb_wrap_connect(hive, hive->location, hive->session_info, hive->credentials, 0, NULL); + if(!wrap) { DEBUG(1, ("ldb_open_hive: unable to connect\n")); return WERR_FOOBAR; Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/reg_backend_rpc.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -356,7 +356,7 @@ .num_values = rpc_num_values, }; -_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx, struct cli_credentials *credentials, +_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx, struct auth_session_info *session_info, struct cli_credentials *credentials, const char *location, struct event_context *ev) { NTSTATUS status; Modified: branches/SAMBA_4_0/source/lib/registry/reg_samba.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/reg_samba.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/reg_samba.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -61,16 +61,18 @@ /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */ - error = reg_open_hive(ctx, backend, location, NULL, k); + error = reg_open_hive(ctx, backend, location, ctx->session_info, ctx->credentials, k); talloc_free(backend); return error; } -_PUBLIC_ WERROR reg_open_local (struct registry_context **ctx) +_PUBLIC_ WERROR reg_open_local (struct registry_context **ctx, struct auth_session_info *session_info, struct cli_credentials *credentials) { *ctx = talloc(NULL, struct registry_context); + (*ctx)->credentials = talloc_reference(*ctx, credentials); + (*ctx)->session_info = talloc_reference(*ctx, session_info); (*ctx)->get_predefined_key = reg_samba_get_predef; return WERR_OK; Modified: branches/SAMBA_4_0/source/lib/registry/regf.idl =================================================================== --- branches/SAMBA_4_0/source/lib/registry/regf.idl 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/regf.idl 2006-03-21 01:30:22 UTC (rev 14599) @@ -17,6 +17,7 @@ /* * Registry version number + * 1.2.0.1 for WinNT 3.51 * 1.3.0.1 for WinNT 4 * 1.5.0.1 for WinXP */ Modified: branches/SAMBA_4_0/source/lib/registry/registry.h =================================================================== --- branches/SAMBA_4_0/source/lib/registry/registry.h 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/registry.h 2006-03-21 01:30:22 UTC (rev 14599) @@ -125,6 +125,8 @@ { const struct hive_operations *functions; struct registry_key *root; + struct auth_session_info *session_info; + struct cli_credentials *credentials; void *backend_data; const char *location; }; @@ -133,6 +135,8 @@ * contains zero or more hives */ struct registry_context { void *backend_data; + struct cli_credentials *credentials; + struct auth_session_info *session_info; WERROR (*get_predefined_key) (struct registry_context *, uint32_t hkey, struct registry_key **); }; @@ -164,6 +168,8 @@ struct reg_diff_key *keys; }; +struct auth_session_info; + #include "lib/registry/registry_proto.h" #endif /* _REGISTRY_H */ Modified: branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -54,14 +54,14 @@ error = WERR_OK; switch(opt) { case 'L': - if (!h1 && !from_null) error = reg_open_local(&h1); - else if (!h2) error = reg_open_local(&h2); + if (!h1 && !from_null) error = reg_open_local(&h1, NULL, cmdline_credentials); + else if (!h2) error = reg_open_local(&h2, NULL, cmdline_credentials); break; case 'R': if (!h1 && !from_null) - error = reg_open_remote(&h1, cmdline_credentials, + error = reg_open_remote(&h1, NULL, cmdline_credentials, poptGetOptArg(pc), NULL); - else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, + else if (!h2) error = reg_open_remote(&h2, NULL, cmdline_credentials, poptGetOptArg(pc), NULL); break; } Modified: branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -50,9 +50,9 @@ } if (remote) { - error = reg_open_remote (&h, cmdline_credentials, remote, NULL); + error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else { - error = reg_open_local (&h); + error = reg_open_local (&h, NULL, cmdline_credentials); } if (W_ERROR_IS_OK(error)) { Modified: branches/SAMBA_4_0/source/lib/registry/tools/regshell.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/tools/regshell.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/tools/regshell.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -426,11 +426,11 @@ } if (remote) { - error = reg_open_remote (&h, cmdline_credentials, remote, NULL); + error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else if (backend) { - error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey); + error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &curkey); } else { - error = reg_open_local(&h); + error = reg_open_local(&h, NULL, cmdline_credentials); } if(!W_ERROR_IS_OK(error)) { Modified: branches/SAMBA_4_0/source/lib/registry/tools/regtree.c =================================================================== --- branches/SAMBA_4_0/source/lib/registry/tools/regtree.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/lib/registry/tools/regtree.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -107,11 +107,11 @@ } if (remote) { - error = reg_open_remote(&h, cmdline_credentials, remote, NULL); + error = reg_open_remote(&h, NULL, cmdline_credentials, remote, NULL); } else if (backend) { - error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &root); + error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &root); } else { - error = reg_open_local (&h); + error = reg_open_local (&h, NULL, cmdline_credentials); } if(!W_ERROR_IS_OK(error)) { Modified: branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c =================================================================== --- branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -32,7 +32,7 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface) { struct registry_context *ctx; - reg_open_local(&ctx); + reg_open_local(&ctx, dce_call->conn->auth_state.session_info, NULL); dce_call->context->private = ctx; Modified: branches/SAMBA_4_0/source/torture/local/registry.c =================================================================== --- branches/SAMBA_4_0/source/torture/local/registry.c 2006-03-21 00:04:41 UTC (rev 14598) +++ branches/SAMBA_4_0/source/torture/local/registry.c 2006-03-21 01:30:22 UTC (rev 14599) @@ -22,6 +22,7 @@ #include "includes.h" #include "lib/registry/registry.h" +#include "lib/cmdline/popt_common.h" static BOOL test_hive(TALLOC_CTX *mem_ctx, const char *backend, const char *location) { @@ -34,7 +35,7 @@ return True; } - error = reg_open_hive(mem_ctx, backend, location, NULL, &root); + error = reg_open_hive(mem_ctx, backend, location, NULL, cmdline_credentials, &root); if (!W_ERROR_IS_OK(error)) { printf("reg_open_hive() failed\n"); return False;
