WERROR registry_init_basic(void) { WERROR werr; DEBUG(10, ("registry_init_basic called\n")); werr = registry_init_common(); regdb_close(); return werr; }
static int smbconf_reg_close(struct smbconf_ctx *ctx) { int ret; if (!rpd(ctx)->open) { return 0; } ret = regdb_close(); if (ret == 0) { rpd(ctx)->open = false; } return ret; }
WERROR registry_init_full(void) { int i; WERROR werr; werr = registry_init_common(); if (!W_ERROR_IS_OK(werr)) { goto fail; } /* setup the necessary keys and values */ werr = init_registry_data(); if (!W_ERROR_IS_OK(werr)) { DEBUG(0, ("Failed to initialize data in registry!\n")); goto fail; } /* build the cache tree of registry hooks */ for ( i=0; reg_hooks[i].keyname; i++ ) { werr = reghook_cache_add(reg_hooks[i].keyname, reg_hooks[i].ops); if (!W_ERROR_IS_OK(werr)) { goto fail; } } if ( DEBUGLEVEL >= 20 ) reghook_dump_cache(20); /* add any keys for other services */ svcctl_init_keys(); eventlog_init_keys(); perfcount_init_keys(); fail: /* close and let each smbd open up as necessary */ regdb_close(); return werr; }
bool svcctl_init_winreg(struct messaging_context *msg_ctx) { struct dcerpc_binding_handle *h = NULL; uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED; struct policy_handle hive_hnd, key_hnd; const char **service_list = lp_svcctl_list(); const char **subkeys = NULL; uint32_t num_subkeys = 0; char *key = NULL; uint32_t i; NTSTATUS status; WERROR result = WERR_OK; bool ok = false; TALLOC_CTX *tmp_ctx; tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { return false; } DEBUG(3, ("Initialise the svcctl registry keys if needed.\n")); ZERO_STRUCT(hive_hnd); ZERO_STRUCT(key_hnd); key = talloc_strdup(tmp_ctx, TOP_LEVEL_SERVICES_KEY); if (key == NULL) { goto done; } result = regdb_open(); if (!W_ERROR_IS_OK(result)) { DEBUG(10, ("regdb_open failed: %s\n", win_errstr(result))); goto done; } result = regdb_transaction_start(); if (!W_ERROR_IS_OK(result)) { DEBUG(10, ("regdb_transaction_start failed: %s\n", win_errstr(result))); goto done; } status = dcerpc_winreg_int_hklm_openkey(tmp_ctx, get_session_info_system(), msg_ctx, &h, key, false, access_mask, &hive_hnd, &key_hnd, &result); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("svcctl_init_winreg: Could not open %s - %s\n", key, nt_errstr(status))); goto done; } if (!W_ERROR_IS_OK(result)) { DEBUG(0, ("svcctl_init_winreg: Could not open %s - %s\n", key, win_errstr(result))); goto done; } /* get all subkeys */ status = dcerpc_winreg_enum_keys(tmp_ctx, h, &key_hnd, &num_subkeys, &subkeys, &result); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("svcctl_init_winreg: Could enum keys at %s - %s\n", key, nt_errstr(status))); goto done; } if (!W_ERROR_IS_OK(result)) { DEBUG(0, ("svcctl_init_winreg: Could enum keys at %s - %s\n", key, win_errstr(result))); goto done; } for (i = 0; builtin_svcs[i].servicename != NULL; i++) { uint32_t j; bool skip = false; for (j = 0; j < num_subkeys; j++) { if (strequal(subkeys[i], builtin_svcs[i].servicename)) { skip = true; } } if (skip) { continue; } ok = svcctl_add_service(tmp_ctx, h, &hive_hnd, key, access_mask, builtin_svcs[i].servicename); if (!ok) { goto done; } } for (i = 0; service_list && service_list[i]; i++) { uint32_t j; bool skip = false; for (j = 0; j < num_subkeys; j++) { if (strequal(subkeys[i], service_list[i])) { skip = true; } } if (skip) { continue; } ok = svcctl_add_service(tmp_ctx, h, &hive_hnd, key, access_mask, service_list[i]); if (is_valid_policy_hnd(&key_hnd)) { dcerpc_winreg_CloseKey(h, tmp_ctx, &key_hnd, &result); } ZERO_STRUCT(key_hnd); if (!ok) { goto done; } } done: if (is_valid_policy_hnd(&key_hnd)) { dcerpc_winreg_CloseKey(h, tmp_ctx, &key_hnd, &result); } if (ok) { result = regdb_transaction_commit(); if (!W_ERROR_IS_OK(result)) { DEBUG(10, ("regdb_transaction_commit failed: %s\n", win_errstr(result))); } } else { result = regdb_transaction_cancel(); if (!W_ERROR_IS_OK(result)) { DEBUG(10, ("regdb_transaction_cancel failed: %s\n", win_errstr(result))); } } regdb_close(); talloc_free(tmp_ctx); return ok; }