summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-10-29 12:12:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:02 -0500
commit9ba6c3885acb79d9c35e600f9a67f8ed0200edfd (patch)
treef730ef7a01d9d42f43df21fca4b4bfb513739209 /source4/lib
parenta29c24f180cc21b358c51a86632eb1cc2cb17868 (diff)
downloadsamba-9ba6c3885acb79d9c35e600f9a67f8ed0200edfd.tar.gz
samba-9ba6c3885acb79d9c35e600f9a67f8ed0200edfd.tar.bz2
samba-9ba6c3885acb79d9c35e600f9a67f8ed0200edfd.zip
r3368: Default to rpc backend with binding "ncalrpc:" if no backend was specified in the various registry tools.
Allow opening a remote registry to partly fail (I.e. if not all hives could be opened) (This used to be commit 313034b10d7a70d079e2bec1af38cf2a7cd918c1)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/registry/common/reg_interface.c12
-rw-r--r--source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c11
-rw-r--r--source4/lib/registry/tools/regdiff.c4
-rw-r--r--source4/lib/registry/tools/regpatch.c2
-rw-r--r--source4/lib/registry/tools/regshell.c6
-rw-r--r--source4/lib/registry/tools/regtree.c2
6 files changed, 24 insertions, 13 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index 999203f4d1..044dc9a0ad 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -132,9 +132,9 @@ WERROR reg_list_available_hives(TALLOC_CTX *mem_ctx, const char *backend, const
WERROR reg_open(struct registry_context **ret, const char *backend, const char *location, const char *credentials)
{
- WERROR error = reg_create(ret);
+ WERROR error = reg_create(ret), reterror = WERR_NO_MORE_ITEMS;
char **hives;
- int i;
+ int i, j;
TALLOC_CTX *mem_ctx = talloc_init("reg_open");
if(!W_ERROR_IS_OK(error)) return error;
@@ -147,11 +147,15 @@ WERROR reg_open(struct registry_context **ret, const char *backend, const char *
if(!W_ERROR_IS_OK(error)) return error;
+ j = 0;
for(i = 0; hives[i]; i++)
{
error = reg_import_hive(*ret, backend, location, credentials, hives[i]);
- if(!W_ERROR_IS_OK(error)) return error;
- (*ret)->hives[i]->name = talloc_strdup((*ret)->mem_ctx, hives[i]);
+ if (W_ERROR_IS_OK(error)) {
+ reterror = WERR_OK;
+ (*ret)->hives[j]->name = talloc_strdup((*ret)->mem_ctx, hives[i]);
+ j++;
+ } else if (!W_ERROR_IS_OK(reterror)) reterror = error;
}
return WERR_OK;
diff --git a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
index 31e55bc9a3..27bd3ff957 100644
--- a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
+++ b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
@@ -122,6 +122,7 @@ static WERROR rpc_open_hive(TALLOC_CTX *mem_ctx, struct registry_hive *h, struct
user = talloc_strdup(mem_ctx, h->credentials);
pass = strchr(user, '%');
if (pass) {
+ *pass = '\0';
pass = strdup(pass+1);
} else {
pass = strdup("");
@@ -136,14 +137,20 @@ static WERROR rpc_open_hive(TALLOC_CTX *mem_ctx, struct registry_hive *h, struct
h->backend_data = p;
- if(NT_STATUS_IS_ERR(status)) return ntstatus_to_werror(status);
+ if(NT_STATUS_IS_ERR(status)) {
+ DEBUG(1, ("Unable to open '%s': %s\n", h->location, nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
for(n = 0; known_hives[n].name; n++)
{
if(!strcmp(known_hives[n].name, h->backend_hivename)) break;
}
- if(!known_hives[n].name) return WERR_NO_MORE_ITEMS;
+ if(!known_hives[n].name) {
+ DEBUG(1, ("No such hive %s\n", known_hives[n].name));
+ return WERR_NO_MORE_ITEMS;
+ }
*k = talloc_p(mem_ctx, struct registry_key);
(*k)->backend_data = mykeydata = talloc_p(mem_ctx, struct rpc_key_data);
diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c
index 524e538591..41a29e46d3 100644
--- a/source4/lib/registry/tools/regdiff.c
+++ b/source4/lib/registry/tools/regdiff.c
@@ -158,7 +158,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey,
return 1;
}
- if(!backend1) backend1 = "dir";
+ if(!backend1) backend1 = "rpc";
error = reg_open(&h1, backend1, location1, credentials1);
if(!W_ERROR_IS_OK(error)) {
@@ -173,7 +173,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey,
return 2;
}
- if(!backend2) backend2 = "dir";
+ if(!backend2) backend2 = "rpc";
error = reg_open(&h2, backend2, location2, credentials2);
if(!W_ERROR_IS_OK(error)) {
diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c
index 1b33628a71..eed249d353 100644
--- a/source4/lib/registry/tools/regpatch.c
+++ b/source4/lib/registry/tools/regpatch.c
@@ -760,7 +760,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd
const char *location;
const char *credentials = NULL;
const char *patch;
- const char *backend = "dir";
+ const char *backend = "rpc";
struct registry_context *h;
WERROR error;
struct poptOption long_options[] = {
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 78fe36f1a0..db7af9d5b6 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -337,7 +337,7 @@ static char **reg_completion(const char *text, int start, int end)
int main(int argc, char **argv)
{
int opt;
- const char *backend = "dir";
+ const char *backend = "rpc";
const char *credentials = NULL;
struct registry_key *curkey = NULL;
poptContext pc;
@@ -363,6 +363,8 @@ static char **reg_completion(const char *text, int start, int end)
while((opt = poptGetNextOpt(pc)) != -1) {
}
+ setup_logging("regtree", True);
+
error = reg_open(&h, backend, poptPeekArg(pc), credentials);
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open '%s' with backend '%s'\n", poptGetArg(pc), backend);
@@ -370,8 +372,6 @@ static char **reg_completion(const char *text, int start, int end)
}
poptFreeContext(pc);
- setup_logging("regtree", True);
-
curkey = h->hives[0]->root;
while(True) {
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index bc0055a891..66bce1e499 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -70,7 +70,7 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
int main(int argc, char **argv)
{
int opt, i;
- const char *backend = "dir";
+ const char *backend = "rpc";
const char *credentials = NULL;
poptContext pc;
struct registry_context *h;