mirror of
https://github.com/samba-team/samba.git
synced 2025-02-18 17:57:55 +03:00
r14599: Pass ACLs down the registry layer.
This commit is contained in:
parent
ace171f94c
commit
6cdefd8945
@ -349,7 +349,7 @@ static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
switch(result) {
|
switch(result) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(openfilewin)));
|
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)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
gtk_show_werror(mainwin, "Error while opening hive", error);
|
gtk_show_werror(mainwin, "Error while opening hive", error);
|
||||||
break;
|
break;
|
||||||
@ -371,7 +371,7 @@ static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
static void on_open_gconf_activate(GtkMenuItem *menuitem, gpointer user_data)
|
static void on_open_gconf_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct registry_key *root;
|
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)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
gtk_show_werror(mainwin, "Error while opening GConf", error);
|
gtk_show_werror(mainwin, "Error while opening GConf", error);
|
||||||
return;
|
return;
|
||||||
@ -385,7 +385,7 @@ static void on_open_gconf_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
|
|
||||||
static void on_open_local_activate(GtkMenuItem *menuitem, gpointer user_data)
|
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)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
gtk_show_werror(mainwin, "Error while opening local registry", error);
|
gtk_show_werror(mainwin, "Error while opening local registry", error);
|
||||||
return;
|
return;
|
||||||
@ -412,6 +412,7 @@ static void on_open_remote_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
cli_credentials_set_gtk_callbacks(creds);
|
cli_credentials_set_gtk_callbacks(creds);
|
||||||
|
|
||||||
error = reg_open_remote(®istry,
|
error = reg_open_remote(®istry,
|
||||||
|
NULL,
|
||||||
creds,
|
creds,
|
||||||
gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx),
|
gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx),
|
||||||
NULL);
|
NULL);
|
||||||
@ -952,7 +953,7 @@ static GtkWidget* create_savefilewin (void)
|
|||||||
|
|
||||||
static int gregedit_load_defaults(void)
|
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)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
gtk_show_werror(mainwin, "Error while loading local registry", error);
|
gtk_show_werror(mainwin, "Error while loading local registry", error);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -106,7 +106,7 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
|
|||||||
ldb_connect_fn fn;
|
ldb_connect_fn fn;
|
||||||
|
|
||||||
if (strchr(url, ':') != NULL) {
|
if (strchr(url, ':') != NULL) {
|
||||||
backend = talloc_strndup(ldb, url, strchr(url, ':')-url-1);
|
backend = talloc_strndup(ldb, url, strchr(url, ':')-url);
|
||||||
} else {
|
} else {
|
||||||
/* Default to tdb */
|
/* Default to tdb */
|
||||||
backend = talloc_strdup(ldb, "tdb");
|
backend = talloc_strdup(ldb, "tdb");
|
||||||
|
@ -161,7 +161,7 @@ _PUBLIC_ WERROR reg_get_predefined_key(struct registry_context *ctx, uint32_t hk
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Open a registry file/host/etc */
|
/** 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_hive *rethive;
|
||||||
struct registry_key *retkey = NULL;
|
struct registry_key *retkey = NULL;
|
||||||
@ -181,6 +181,8 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *backend, const
|
|||||||
|
|
||||||
rethive = talloc(parent_ctx, struct registry_hive);
|
rethive = talloc(parent_ctx, struct registry_hive);
|
||||||
rethive->location = location?talloc_strdup(rethive, location):NULL;
|
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->functions = entry->hive_functions;
|
||||||
rethive->backend_data = NULL;
|
rethive->backend_data = NULL;
|
||||||
|
|
||||||
|
@ -262,8 +262,8 @@ static WERROR ldb_open_hive(struct registry_hive *hive, struct registry_key **k)
|
|||||||
struct ldb_context *wrap;
|
struct ldb_context *wrap;
|
||||||
|
|
||||||
if (!hive->location) return WERR_INVALID_PARAM;
|
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) {
|
if(!wrap) {
|
||||||
DEBUG(1, ("ldb_open_hive: unable to connect\n"));
|
DEBUG(1, ("ldb_open_hive: unable to connect\n"));
|
||||||
|
@ -356,7 +356,7 @@ static struct hive_operations reg_backend_rpc = {
|
|||||||
.num_values = rpc_num_values,
|
.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)
|
const char *location, struct event_context *ev)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
@ -61,16 +61,18 @@ static WERROR reg_samba_get_predef (struct registry_context *ctx, uint32_t hkey,
|
|||||||
|
|
||||||
/* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
|
/* 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);
|
talloc_free(backend);
|
||||||
|
|
||||||
return error;
|
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 = 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;
|
(*ctx)->get_predefined_key = reg_samba_get_predef;
|
||||||
|
|
||||||
return WERR_OK;
|
return WERR_OK;
|
||||||
|
@ -17,6 +17,7 @@ interface regf
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Registry version number
|
* Registry version number
|
||||||
|
* 1.2.0.1 for WinNT 3.51
|
||||||
* 1.3.0.1 for WinNT 4
|
* 1.3.0.1 for WinNT 4
|
||||||
* 1.5.0.1 for WinXP
|
* 1.5.0.1 for WinXP
|
||||||
*/
|
*/
|
||||||
|
@ -125,6 +125,8 @@ struct registry_hive
|
|||||||
{
|
{
|
||||||
const struct hive_operations *functions;
|
const struct hive_operations *functions;
|
||||||
struct registry_key *root;
|
struct registry_key *root;
|
||||||
|
struct auth_session_info *session_info;
|
||||||
|
struct cli_credentials *credentials;
|
||||||
void *backend_data;
|
void *backend_data;
|
||||||
const char *location;
|
const char *location;
|
||||||
};
|
};
|
||||||
@ -133,6 +135,8 @@ struct registry_hive
|
|||||||
* contains zero or more hives */
|
* contains zero or more hives */
|
||||||
struct registry_context {
|
struct registry_context {
|
||||||
void *backend_data;
|
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 **);
|
WERROR (*get_predefined_key) (struct registry_context *, uint32_t hkey, struct registry_key **);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -164,6 +168,8 @@ struct reg_diff
|
|||||||
struct reg_diff_key *keys;
|
struct reg_diff_key *keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct auth_session_info;
|
||||||
|
|
||||||
#include "lib/registry/registry_proto.h"
|
#include "lib/registry/registry_proto.h"
|
||||||
|
|
||||||
#endif /* _REGISTRY_H */
|
#endif /* _REGISTRY_H */
|
||||||
|
@ -54,14 +54,14 @@ int main(int argc, char **argv)
|
|||||||
error = WERR_OK;
|
error = WERR_OK;
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'L':
|
case 'L':
|
||||||
if (!h1 && !from_null) error = reg_open_local(&h1);
|
if (!h1 && !from_null) error = reg_open_local(&h1, NULL, cmdline_credentials);
|
||||||
else if (!h2) error = reg_open_local(&h2);
|
else if (!h2) error = reg_open_local(&h2, NULL, cmdline_credentials);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
if (!h1 && !from_null)
|
if (!h1 && !from_null)
|
||||||
error = reg_open_remote(&h1, cmdline_credentials,
|
error = reg_open_remote(&h1, NULL, cmdline_credentials,
|
||||||
poptGetOptArg(pc), NULL);
|
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);
|
poptGetOptArg(pc), NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (remote) {
|
if (remote) {
|
||||||
error = reg_open_remote (&h, cmdline_credentials, remote, NULL);
|
error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL);
|
||||||
} else {
|
} else {
|
||||||
error = reg_open_local (&h);
|
error = reg_open_local (&h, NULL, cmdline_credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (W_ERROR_IS_OK(error)) {
|
if (W_ERROR_IS_OK(error)) {
|
||||||
|
@ -426,11 +426,11 @@ static char **reg_completion(const char *text, int start, int end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (remote) {
|
if (remote) {
|
||||||
error = reg_open_remote (&h, cmdline_credentials, remote, NULL);
|
error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL);
|
||||||
} else if (backend) {
|
} 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 {
|
} else {
|
||||||
error = reg_open_local(&h);
|
error = reg_open_local(&h, NULL, cmdline_credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!W_ERROR_IS_OK(error)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
|
@ -107,11 +107,11 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (remote) {
|
if (remote) {
|
||||||
error = reg_open_remote(&h, cmdline_credentials, remote, NULL);
|
error = reg_open_remote(&h, NULL, cmdline_credentials, remote, NULL);
|
||||||
} else if (backend) {
|
} 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 {
|
} else {
|
||||||
error = reg_open_local (&h);
|
error = reg_open_local (&h, NULL, cmdline_credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!W_ERROR_IS_OK(error)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
|
@ -32,7 +32,7 @@ enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
|
|||||||
static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
|
static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
|
||||||
{
|
{
|
||||||
struct registry_context *ctx;
|
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;
|
dce_call->context->private = ctx;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "lib/registry/registry.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)
|
static BOOL test_hive(TALLOC_CTX *mem_ctx, const char *backend, const char *location)
|
||||||
{
|
{
|
||||||
@ -34,7 +35,7 @@ static BOOL test_hive(TALLOC_CTX *mem_ctx, const char *backend, const char *loca
|
|||||||
return True;
|
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)) {
|
if (!W_ERROR_IS_OK(error)) {
|
||||||
printf("reg_open_hive() failed\n");
|
printf("reg_open_hive() failed\n");
|
||||||
return False;
|
return False;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user