#include "includes.h"
#include "lib/smbconf/smbconf_private.h"
+#include "registry.h"
+#include "registry/reg_api.h"
+#include "registry/reg_backend_db.h"
+#include "registry/reg_util_token.h"
+#include "registry/reg_api_util.h"
+#include "registry/reg_init_smbconf.h"
+#include "lib/smbconf/smbconf_init.h"
+#include "lib/smbconf/smbconf_reg.h"
+#include "../libcli/registry/util_reg.h"
#define INCLUDES_VALNAME "includes"
if (!strequal(subkeyname, GLOBAL_NAME) &&
lp_parameter_is_global(valname))
{
- DEBUG(5, ("Global paramter '%s' not allowed in "
+ DEBUG(5, ("Global parameter '%s' not allowed in "
"service definition ('%s').\n", canon_valname,
subkeyname));
werr = WERR_INVALID_PARAM;
ZERO_STRUCT(val);
val.type = REG_SZ;
- val.v.sz.str = CONST_DISCARD(char *, canon_valstr);
- val.v.sz.len = strlen(canon_valstr) + 1;
+ if (!push_reg_sz(talloc_tos(), &val.data, canon_valstr)) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
werr = reg_setvalue(key, canon_valname, &val);
if (!W_ERROR_IS_OK(werr)) {
struct registry_value *value;
uint32_t count;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ const char **array;
if (strings == NULL) {
werr = WERR_INVALID_PARAM;
goto done;
}
- value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
+ array = talloc_zero_array(tmp_ctx, const char *, num_strings + 1);
+ if (array == NULL) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
- value->type = REG_MULTI_SZ;
- value->v.multi_sz.num_strings = num_strings;
- value->v.multi_sz.strings = TALLOC_ARRAY(tmp_ctx, char *, num_strings);
- if (value->v.multi_sz.strings == NULL) {
+ value = TALLOC_ZERO_P(tmp_ctx, struct registry_value);
+ if (value == NULL) {
werr = WERR_NOMEM;
goto done;
}
+
+ value->type = REG_MULTI_SZ;
+
for (count = 0; count < num_strings; count++) {
- value->v.multi_sz.strings[count] =
- talloc_strdup(value->v.multi_sz.strings,
- strings[count]);
- if (value->v.multi_sz.strings[count] == NULL) {
+ array[count] = talloc_strdup(value, strings[count]);
+ if (array[count] == NULL) {
werr = WERR_NOMEM;
goto done;
}
}
+ if (!push_reg_multi_sz(value, &value->data, array)) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
werr = reg_setvalue(key, valname, value);
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5, ("Error adding value '%s' to key '%s': %s\n",
switch (value->type) {
case REG_DWORD:
- result = talloc_asprintf(mem_ctx, "%d", value->v.dword);
+ if (value->data.length >= 4) {
+ uint32_t v = IVAL(value->data.data, 0);
+ result = talloc_asprintf(mem_ctx, "%d", v);
+ }
break;
case REG_SZ:
- case REG_EXPAND_SZ:
- result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str);
+ case REG_EXPAND_SZ: {
+ const char *s;
+ if (!pull_reg_sz(mem_ctx, &value->data, &s)) {
+ break;
+ }
+ result = talloc_strdup(mem_ctx, s);
break;
+ }
case REG_MULTI_SZ: {
uint32 j;
- for (j = 0; j < value->v.multi_sz.num_strings; j++) {
+ const char **a = NULL;
+ if (!pull_reg_multi_sz(mem_ctx, &value->data, &a)) {
+ break;
+ }
+ for (j = 0; a[j] != NULL; j++) {
result = talloc_asprintf(mem_ctx, "%s\"%s\" ",
result ? result : "" ,
- value->v.multi_sz.strings[j]);
+ a[j]);
if (result == NULL) {
break;
}
}
case REG_BINARY:
result = talloc_asprintf(mem_ctx, "binary (%d bytes)",
- (int)value->v.binary.length);
+ (int)value->data.length);
break;
default:
result = talloc_asprintf(mem_ctx, "<unprintable>");
uint32_t count;
struct registry_value *value = NULL;
char **tmp_includes = NULL;
+ const char **array = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
if (!smbconf_value_exists(key, INCLUDES_VALNAME)) {
}
if (value->type != REG_MULTI_SZ) {
- /* wront type -- ignore */
+ /* wrong type -- ignore */
goto done;
}
- for (count = 0; count < value->v.multi_sz.num_strings; count++)
- {
+ if (!pull_reg_multi_sz(tmp_ctx, &value->data, &array)) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
+ for (count = 0; array[count] != NULL; count++) {
werr = smbconf_add_string_to_array(tmp_ctx,
&tmp_includes,
count,
- value->v.multi_sz.strings[count]);
+ array[count]);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
{
WERROR werr = WERR_OK;
- struct nt_user_token *token;
+ struct security_token *token;
if (path == NULL) {
path = KEY_SMBCONF;
}
werr = reg_open_path(ctx, ctx->path,
- SEC_RIGHTS_ENUM_SUBKEYS | REG_KEY_WRITE,
+ KEY_ENUMERATE_SUB_KEYS | REG_KEY_WRITE,
token, &rpd(ctx)->base_key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
struct registry_key *new_key = NULL;
TALLOC_CTX* mem_ctx = talloc_stackframe();
enum winreg_CreateAction action;
- struct nt_user_token *token;
+ struct security_token *token;
werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
- werr = reg_deletekey_recursive(mem_ctx, parent_key, p+1);
+ werr = reg_deletekey_recursive(parent_key, p+1);
if (!W_ERROR_IS_OK(werr)) {
goto done;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (servicename != NULL) {
- werr = reg_deletekey_recursive(mem_ctx, rpd(ctx)->base_key,
- servicename);
+ werr = reg_deletekey_recursive(rpd(ctx)->base_key, servicename);
} else {
werr = smbconf_reg_delete_values(rpd(ctx)->base_key);
}