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;
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;
user = talloc_strdup(mem_ctx, h->credentials);
pass = strchr(user, '%');
if (pass) {
+ *pass = '\0';
pass = strdup(pass+1);
} else {
pass = strdup("");
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);
return 1;
}
- if(!backend1) backend1 = "dir";
+ if(!backend1) backend1 = "rpc";
error = reg_open(&h1, backend1, location1, credentials1);
if(!W_ERROR_IS_OK(error)) {
return 2;
}
- if(!backend2) backend2 = "dir";
+ if(!backend2) backend2 = "rpc";
error = reg_open(&h2, backend2, location2, credentials2);
if(!W_ERROR_IS_OK(error)) {
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[] = {
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;
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);
}
poptFreeContext(pc);
- setup_logging("regtree", True);
-
curkey = h->hives[0]->root;
while(True) {
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;