summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/dir.c2
-rw-r--r--source4/lib/registry/hive.c5
-rw-r--r--source4/lib/registry/hive.h8
-rw-r--r--source4/lib/registry/interface.c2
-rw-r--r--source4/lib/registry/ldb.c9
-rw-r--r--source4/lib/registry/local.c10
-rw-r--r--source4/lib/registry/patchfile_preg.c76
-rw-r--r--source4/lib/registry/regf.c228
-rw-r--r--source4/lib/registry/registry.h4
-rw-r--r--source4/lib/registry/registry.i26
-rw-r--r--source4/lib/registry/registry.py51
-rw-r--r--source4/lib/registry/registry_wrap.c329
-rw-r--r--source4/lib/registry/rpc.c2
-rw-r--r--source4/lib/registry/samba.c4
-rw-r--r--source4/lib/registry/tests/generic.c7
-rw-r--r--source4/lib/registry/tests/hive.c8
-rw-r--r--source4/lib/registry/tests/registry.c4
-rw-r--r--source4/lib/registry/tools/common.c3
-rw-r--r--source4/lib/registry/tools/regshell.c8
-rw-r--r--source4/lib/registry/tools/regtree.c2
-rw-r--r--source4/lib/registry/util.c5
21 files changed, 491 insertions, 302 deletions
diff --git a/source4/lib/registry/dir.c b/source4/lib/registry/dir.c
index 532770bcaf..2f00d2fea0 100644
--- a/source4/lib/registry/dir.c
+++ b/source4/lib/registry/dir.c
@@ -272,7 +272,7 @@ static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
}
static WERROR reg_dir_enum_value(TALLOC_CTX *mem_ctx,
- const struct hive_key *key, int idx,
+ struct hive_key *key, int idx,
const char **name,
uint32_t *type, DATA_BLOB *data)
{
diff --git a/source4/lib/registry/hive.c b/source4/lib/registry/hive.c
index 16534aac9c..64bee8251b 100644
--- a/source4/lib/registry/hive.c
+++ b/source4/lib/registry/hive.c
@@ -27,6 +27,7 @@
_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx,
struct hive_key **root)
{
int fd, num;
@@ -51,11 +52,11 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
if (!strncmp(peek, "regf", 4)) {
close(fd);
- return reg_open_regf_file(parent_ctx, location, root);
+ return reg_open_regf_file(parent_ctx, location, lp_ctx, root);
} else if (!strncmp(peek, "TDB file", 8)) {
close(fd);
return reg_open_ldb_file(parent_ctx, location, session_info,
- credentials, root);
+ credentials, lp_ctx, root);
}
return WERR_BADFILE;
diff --git a/source4/lib/registry/hive.h b/source4/lib/registry/hive.h
index 2f783dd15d..ffb92f8e79 100644
--- a/source4/lib/registry/hive.h
+++ b/source4/lib/registry/hive.h
@@ -22,6 +22,7 @@
#define __REGISTRY_HIVE_H__
#include <talloc.h>
+#include "libcli/util/werror.h"
#include "librpc/gen_ndr/security.h"
#include "libcli/util/ntstatus.h"
@@ -81,7 +82,7 @@ struct hive_operations {
* Retrieve a registry value with a specific index.
*/
WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
- const struct hive_key *key, int idx,
+ struct hive_key *key, int idx,
const char **name, uint32_t *type,
DATA_BLOB *data);
@@ -143,6 +144,7 @@ struct auth_session_info;
WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx,
struct hive_key **root);
WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
const char **classname, uint32_t *num_subkeys,
@@ -182,10 +184,12 @@ WERROR hive_key_flush(struct hive_key *key);
WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
const char *location, struct hive_key **key);
WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key);
+ const char *location, struct loadparm_context *lp_ctx,
+ struct hive_key **key);
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx,
struct hive_key **k);
diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c
index 8f60a55ae9..b914fbab30 100644
--- a/source4/lib/registry/interface.c
+++ b/source4/lib/registry/interface.c
@@ -74,7 +74,7 @@ _PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
}
/** Get predefined key by id. */
-_PUBLIC_ WERROR reg_get_predefined_key(const struct registry_context *ctx,
+_PUBLIC_ WERROR reg_get_predefined_key(struct registry_context *ctx,
uint32_t hkey, struct registry_key **key)
{
return ctx->ops->get_predefined_key(ctx, hkey, key);
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 0e556da9e2..c9697ddb4c 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -54,7 +54,7 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg,
{
case REG_SZ:
case REG_EXPAND_SZ:
- data->length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF8, CH_UTF16,
+ data->length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF8, CH_UTF16,
val->data, val->length,
(void **)&data->data);
break;
@@ -85,7 +85,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
switch (type) {
case REG_SZ:
case REG_EXPAND_SZ:
- val.length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX,
+ val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
(void *)data.data,
data.length,
(void **)&val.data);
@@ -249,7 +249,7 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k,
+static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct hive_key *k,
int idx, const char **name,
uint32_t *data_type, DATA_BLOB *data)
{
@@ -337,6 +337,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx,
struct hive_key **k)
{
struct ldb_key_data *kd;
@@ -345,7 +346,7 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
if (location == NULL)
return WERR_INVALID_PARAM;
- wrap = ldb_wrap_connect(parent_ctx, global_loadparm,
+ wrap = ldb_wrap_connect(parent_ctx, lp_ctx,
location, session_info, credentials, 0, NULL);
if (wrap == NULL) {
diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c
index b54f0cf30a..1ed4f0262e 100644
--- a/source4/lib/registry/local.c
+++ b/source4/lib/registry/local.c
@@ -126,7 +126,7 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-WERROR local_get_predefined_key(const struct registry_context *ctx,
+WERROR local_get_predefined_key(struct registry_context *ctx,
uint32_t key_id, struct registry_key **key)
{
struct registry_local *rctx = talloc_get_type(ctx,
@@ -168,7 +168,7 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx,
struct security_descriptor *security,
struct registry_key **key)
{
- const struct local_key *local_parent;
+ struct local_key *local_parent;
struct hive_key *hivekey;
const char **elements;
int i;
@@ -177,11 +177,11 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx,
last_part = strrchr(name, '\\');
if (last_part == NULL) {
last_part = name;
- local_parent = (const struct local_key *)parent_key;
+ local_parent = (struct local_key *)parent_key;
} else {
W_ERROR_NOT_OK_RETURN(reg_open_key(mem_ctx, parent_key,
talloc_strndup(mem_ctx, name, last_part-name),
- &local_parent));
+ (struct registry_key **)&local_parent));
last_part++;
}
@@ -321,7 +321,7 @@ WERROR reg_mount_hive(struct registry_context *rctx,
mp->path.predefined_key = key_id;
mp->prev = mp->next = NULL;
mp->key = hive_key;
- if (elements != NULL) {
+ if (elements != NULL && str_list_length(elements) != 0) {
mp->path.elements = talloc_array(mp, const char *,
str_list_length(elements));
for (i = 0; elements[i] != NULL; i++) {
diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index 6af239fc21..9cc9a5dec2 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -23,7 +23,7 @@
#include "lib/registry/registry.h"
#include "lib/registry/patchfile.h"
#include "system/filesys.h"
-#include "pstring.h"
+#include "param/param.h"
struct preg_data {
int fd;
@@ -36,20 +36,18 @@ static WERROR preg_read_utf16(int fd, char *c)
if (read(fd, &v, 2) < 2) {
return WERR_GENERAL_FAILURE;
}
- push_codepoint(global_smb_iconv_convenience, c, v);
+ push_codepoint(lp_iconv_convenience(global_loadparm), c, v);
return WERR_OK;
}
/* FIXME These functions need to be implemented */
static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
{
- struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
{
- struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
@@ -57,20 +55,17 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name,
const char *value_name,
uint32_t value_type, DATA_BLOB value_data)
{
- struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
static WERROR reg_preg_diff_del_value(void *_data, const char *key_name,
const char *value_name)
{
- struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
static WERROR reg_preg_diff_del_all_values(void *_data, const char *key_name)
{
- struct preg_data *data = (struct preg_data *)_data;
return WERR_OK;
}
@@ -135,22 +130,29 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
char hdr[4];
uint32_t version;
} preg_header;
- pstring buf;
- char *buf_ptr = buf;
+ char *buf;
+ size_t buf_size = 1024;
+ char *buf_ptr;
TALLOC_CTX *mem_ctx = talloc_init("reg_preg_diff_load");
+ WERROR ret = WERR_OK;
+ DATA_BLOB data = {NULL, 0};
+ char *key = NULL;
+ char *value_name = NULL;
+ buf = talloc_array(mem_ctx, char, buf_size);
+ buf_ptr = buf;
/* Read first 8 bytes (the header) */
if (read(fd, &preg_header, 8) != 8) {
DEBUG(0, ("Could not read PReg file: %s\n",
strerror(errno)));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
if (strncmp(preg_header.hdr, "PReg", 4) != 0) {
DEBUG(0, ("This file is not a valid preg registry file\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
if (preg_header.version > 1) {
DEBUG(0, ("Warning: file format version is higher than expected.\n"));
@@ -158,23 +160,21 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Read the entries */
while(1) {
- char *key, *value_name;
uint32_t value_type, length;
- DATA_BLOB data;
if (!W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr))) {
break;
}
if (*buf_ptr != '[') {
DEBUG(0, ("Error in PReg file.\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
/* Get the path */
buf_ptr = buf;
while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
- *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
+ *buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
key = talloc_asprintf(mem_ctx, "\\%s", buf);
@@ -182,7 +182,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Get the name */
buf_ptr = buf;
while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
- *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
+ *buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
value_name = talloc_strdup(mem_ctx, buf);
@@ -190,45 +190,45 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Get the type */
if (read(fd, &value_type, 4) < 4) {
DEBUG(0, ("Error while reading PReg\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
/* Read past delimiter */
buf_ptr = buf;
if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
- *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
+ *buf_ptr == ';') && buf_ptr-buf < buf_size) {
DEBUG(0, ("Error in PReg file.\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
/* Get data length */
if (read(fd, &length, 4) < 4) {
DEBUG(0, ("Error while reading PReg\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
/* Read past delimiter */
buf_ptr = buf;
if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
- *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
+ *buf_ptr == ';') && buf_ptr-buf < buf_size) {
DEBUG(0, ("Error in PReg file.\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
/* Get the data */
buf_ptr = buf;
- if (length < sizeof(buf) &&
+ if (length < buf_size &&
read(fd, buf_ptr, length) != length) {
DEBUG(0, ("Error while reading PReg\n"));
- close(fd);
- return WERR_GENERAL_FAILURE;
+ ret = WERR_GENERAL_FAILURE;
+ goto cleanup;
}
data = data_blob_talloc(mem_ctx, buf, length);
/* Check if delimiter is in place (whine if it isn't) */
buf_ptr = buf;
if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
- *buf_ptr == ']') && buf_ptr-buf < sizeof(buf)) {
+ *buf_ptr == ']') && buf_ptr-buf < buf_size) {
DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",
*buf_ptr, *buf_ptr));
}
@@ -277,10 +277,12 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
callbacks->set_value(callback_data, key, value_name,
value_type, data);
}
- talloc_free(key);
- talloc_free(value_name);
- talloc_free(data.data);
}
+cleanup:
close(fd);
- return WERR_OK;
+ talloc_free(data.data);
+ talloc_free(key);
+ talloc_free(value_name);
+ talloc_free(buf);
+ return ret;
}
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 3ae299b3ef..28bd0ad461 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -24,6 +24,7 @@
#include "lib/registry/tdr_regf.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
static struct hive_operations reg_backend_regf;
@@ -47,6 +48,7 @@ struct regf_data {
int fd;
struct hbin_block **hbins;
struct regf_hdr *header;
+ struct smb_iconv_convenience *iconv_convenience;
};
static WERROR regf_save_hbin(struct regf_data *data);
@@ -131,21 +133,22 @@ static DATA_BLOB hbin_get(const struct regf_data *data, uint32_t offset)
static bool hbin_get_tdr(struct regf_data *regf, uint32_t offset,
TALLOC_CTX *ctx, tdr_pull_fn_t pull_fn, void *p)
{
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
- ZERO_STRUCT(pull);
-
- pull.data = hbin_get(regf, offset);
- if (!pull.data.data) {
+ pull->data = hbin_get(regf, offset);
+ if (!pull->data.data) {
DEBUG(1, ("Unable to get data at 0x%04x\n", offset));
+ talloc_free(pull);
return false;
}
- if (NT_STATUS_IS_ERR(pull_fn(&pull, ctx, p))) {
+ if (NT_STATUS_IS_ERR(pull_fn(pull, ctx, p))) {
DEBUG(1, ("Error parsing record at 0x%04x using tdr\n",
offset));
+ talloc_free(pull);
return false;
}
+ talloc_free(pull);
return true;
}
@@ -263,7 +266,7 @@ static uint32_t hbin_store (struct regf_data *data, DATA_BLOB blob)
static uint32_t hbin_store_tdr(struct regf_data *data,
tdr_push_fn_t push_fn, void *p)
{
- struct tdr_push *push = talloc_zero(data, struct tdr_push);
+ struct tdr_push *push = tdr_push_init(data, data->iconv_convenience);
uint32_t ret;
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
@@ -390,7 +393,7 @@ static uint32_t hbin_store_tdr_resize(struct regf_data *regf,
tdr_push_fn_t push_fn,
uint32_t orig_offset, void *p)
{
- struct tdr_push *push = talloc_zero(regf, struct tdr_push);
+ struct tdr_push *push = tdr_push_init(regf, regf->iconv_convenience);
uint32_t ret;
if (NT_STATUS_IS_ERR(push_fn(push, p))) {
@@ -485,7 +488,7 @@ static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
}
-static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
+static WERROR regf_get_value(TALLOC_CTX *ctx, struct hive_key *key,
int idx, const char **name,
uint32_t *data_type, DATA_BLOB *data)
{
@@ -592,16 +595,17 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
if (!strncmp((char *)data.data, "li", 2)) {
struct li_block li;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(private_data->hive, private_data->hive->iconv_convenience);
DEBUG(10, ("Subkeys in LI list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(pull, nk, &li))) {
DEBUG(0, ("Error parsing LI list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(li.header, "li", 2));
if (li.key_count != nk->num_subkeys) {
@@ -612,16 +616,17 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
} else if (!strncmp((char *)data.data, "lf", 2)) {
struct lf_block lf;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(private_data->hive, private_data->hive->iconv_convenience);
DEBUG(10, ("Subkeys in LF list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, nk, &lf))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lf_block(pull, nk, &lf))) {
DEBUG(0, ("Error parsing LF list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lf.header, "lf", 2));
if (lf.key_count != nk->num_subkeys) {
@@ -632,16 +637,17 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
key_off = lf.hr[idx].nk_offset;
} else if (!strncmp((char *)data.data, "lh", 2)) {
struct lh_block lh;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(private_data->hive, private_data->hive->iconv_convenience);
DEBUG(10, ("Subkeys in LH list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(pull, nk, &lh))) {
DEBUG(0, ("Error parsing LH list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
if (lh.key_count != nk->num_subkeys) {
@@ -651,16 +657,16 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
key_off = lh.hr[idx].nk_offset;
} else if (!strncmp((char *)data.data, "ri", 2)) {
struct ri_block ri;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
uint16_t i;
uint16_t sublist_count = 0;
DEBUG(10, ("Subkeys in RI list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_ri_block(&pull, nk, &ri))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_ri_block(pull, nk, &ri))) {
DEBUG(0, ("Error parsing RI list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(ri.header, "ri", 2));
@@ -672,21 +678,22 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
list_data = hbin_get(private_data->hive, ri.offset[i]);
if (!list_data.data) {
DEBUG(0, ("Error getting RI list."));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
- ZERO_STRUCT(pull);
- pull.data = list_data;
+ pull->data = list_data;
if (!strncmp((char *)list_data.data, "li", 2)) {
struct li_block li;
DEBUG(10, ("Subkeys in RI->LI list\n"));
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull,
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(pull,
nk,
&li))) {
DEBUG(0, ("Error parsing LI list from RI\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(li.header, "li", 2));
@@ -704,10 +711,11 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
DEBUG(10, ("Subkeys in RI->LH list\n"));
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull,
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(pull,
nk,
&lh))) {
DEBUG(0, ("Error parsing LH list from RI\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
@@ -722,11 +730,14 @@ static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
break;
} else {
DEBUG(0,("Unknown sublist in ri block\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
}
+ talloc_free(pull);
+
if (idx > sublist_count) {
return WERR_NO_MORE_ITEMS;
@@ -769,7 +780,7 @@ static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
{
DATA_BLOB subkey_data;
struct nk_block subkey;
- struct tdr_pull pull;
+ struct tdr_pull *pull;
const struct regf_key_data *private_data =
(const struct regf_key_data *)key;
@@ -779,13 +790,16 @@ static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
return WERR_GENERAL_FAILURE;
}
- ZERO_STRUCT(pull);
- pull.data = subkey_data;
+ pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
+
+ pull->data = subkey_data;
- if (NT_STATUS_IS_ERR(tdr_pull_nk_block(&pull, ctx, &subkey))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_nk_block(pull, ctx, &subkey))) {
DEBUG(0, ("Error parsing NK structure.\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
if (strncmp(subkey.header, "nk", 2)) {
DEBUG(0, ("Not an NK structure.\n"));
@@ -819,17 +833,18 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
if (!strncmp((char *)data.data, "li", 2)) {
struct li_block li;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
uint16_t i;
DEBUG(10, ("Subkeys in LI list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(pull, nk, &li))) {
DEBUG(0, ("Error parsing LI list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(li.header, "li", 2));
if (li.key_count != nk->num_subkeys) {
@@ -849,17 +864,18 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
return WERR_NOT_FOUND;
} else if (!strncmp((char *)data.data, "lf", 2)) {
struct lf_block lf;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
uint16_t i;
DEBUG(10, ("Subkeys in LF list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, nk, &lf))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lf_block(pull, nk, &lf))) {
DEBUG(0, ("Error parsing LF list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lf.header, "lf", 2));
if (lf.key_count != nk->num_subkeys) {
@@ -883,18 +899,19 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
return WERR_NOT_FOUND;
} else if (!strncmp((char *)data.data, "lh", 2)) {
struct lh_block lh;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
uint16_t i;
uint32_t hash;
DEBUG(10, ("Subkeys in LH list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(pull, nk, &lh))) {
DEBUG(0, ("Error parsing LH list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
if (lh.key_count != nk->num_subkeys) {
@@ -919,15 +936,15 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
return WERR_NOT_FOUND;
} else if (!strncmp((char *)data.data, "ri", 2)) {
struct ri_block ri;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
uint16_t i, j;
DEBUG(10, ("Subkeys in RI list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_ri_block(&pull, nk, &ri))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_ri_block(pull, nk, &ri))) {
DEBUG(0, ("Error parsing RI list\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(ri.header, "ri", 2));
@@ -939,19 +956,20 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
list_data = hbin_get(private_data->hive, ri.offset[i]);
if (list_data.data == NULL) {
DEBUG(0, ("Error getting RI list."));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
- ZERO_STRUCT(pull);
- pull.data = list_data;
+ pull->data = list_data;
if (!strncmp((char *)list_data.data, "li", 2)) {
struct li_block li;
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull,
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(pull,
nk,
&li))) {
DEBUG(0, ("Error parsing LI list from RI\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(li.header, "li", 2));
@@ -968,10 +986,11 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
struct lh_block lh;
uint32_t hash;
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull,
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(pull,
nk,
&lh))) {
DEBUG(0, ("Error parsing LH list from RI\n"));
+ talloc_free(pull);
return WERR_GENERAL_FAILURE;
}
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
@@ -992,6 +1011,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
if (key_off)
break;
}
+ talloc_free(pull);
if (!key_off)
return WERR_NOT_FOUND;
} else {
@@ -1258,16 +1278,17 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
}
if (!strncmp((char *)data.data, "li", 2)) {
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
struct li_block li;
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, regf, &li))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(pull, regf, &li))) {
DEBUG(0, ("Error parsing LI list\n"));
+ talloc_free(pull);
return WERR_BADFILE;
}
+ talloc_free(pull);
if (strncmp(li.header, "li", 2) != 0) {
abort();
@@ -1286,16 +1307,17 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
talloc_free(li.nk_offset);
} else if (!strncmp((char *)data.data, "lf", 2)) {
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
struct lf_block lf;
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, regf, &lf))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lf_block(pull, regf, &lf))) {
DEBUG(0, ("Error parsing LF list\n"));
+ talloc_free(pull);
return WERR_BADFILE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lf.header, "lf", 2));
lf.hr = talloc_realloc(regf, lf.hr, struct hash_record,
@@ -1311,16 +1333,17 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
talloc_free(lf.hr);
} else if (!strncmp((char *)data.data, "lh", 2)) {
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
struct lh_block lh;
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, regf, &lh))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(pull, regf, &lh))) {
DEBUG(0, ("Error parsing LH list\n"));
+ talloc_free(pull);
return WERR_BADFILE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
lh.hr = talloc_realloc(regf, lh.hr, struct lh_hash,
@@ -1359,19 +1382,20 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
if (strncmp((char *)data.data, "li", 2) == 0) {
struct li_block li;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
uint16_t i;
bool found_offset = false;
DEBUG(10, ("Subkeys in LI list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, regf, &li))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_li_block(pull, regf, &li))) {
DEBUG(0, ("Error parsing LI list\n"));
+ talloc_free(pull);
return WERR_BADFILE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(li.header, "li", 2));
@@ -1402,19 +1426,20 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
list_offset, &li);
} else if (strncmp((char *)data.data, "lf", 2) == 0) {
struct lf_block lf;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
uint16_t i;
bool found_offset = false;
DEBUG(10, ("Subkeys in LF list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, regf, &lf))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lf_block(pull, regf, &lf))) {
DEBUG(0, ("Error parsing LF list\n"));
+ talloc_free(pull);
return WERR_BADFILE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lf.header, "lf", 2));
@@ -1447,19 +1472,20 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
list_offset, &lf);
} else if (strncmp((char *)data.data, "lh", 2) == 0) {
struct lh_block lh;
- struct tdr_pull pull;
+ struct tdr_pull *pull = tdr_pull_init(regf, regf->iconv_convenience);
uint16_t i;
bool found_offset = false;
DEBUG(10, ("Subkeys in LH list\n"));
- ZERO_STRUCT(pull);
- pull.data = data;
+ pull->data = data;
- if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, regf, &lh))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_lh_block(pull, regf, &lh))) {
DEBUG(0, ("Error parsing LF list\n"));
+ talloc_free(pull);
return WERR_BADFILE;
}
+ talloc_free(pull);
SMB_ASSERT(!strncmp(lh.header, "lh", 2));
@@ -1503,8 +1529,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
static WERROR regf_del_value (struct hive_key *key, const char *name)
{
- const struct regf_key_data *private_data =
- (const struct regf_key_data *)key;
+ struct regf_key_data *private_data = (struct regf_key_data *)key;
struct regf_data *regf = private_data->hive;
struct nk_block *nk = private_data->nk;
struct vk_block vk;
@@ -1677,8 +1702,7 @@ static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
static WERROR regf_set_value(struct hive_key *key, const char *name,
uint32_t type, const DATA_BLOB data)
{
- const struct regf_key_data *private_data =
- (const struct regf_key_data *)key;
+ struct regf_key_data *private_data = (struct regf_key_data *)key;
struct regf_data *regf = private_data->hive;
struct nk_block *nk = private_data->nk;
struct vk_block vk;
@@ -1788,7 +1812,7 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
static WERROR regf_save_hbin(struct regf_data *regf)
{
- struct tdr_push *push = talloc_zero(regf, struct tdr_push);
+ struct tdr_push *push = tdr_push_init(regf, regf->iconv_convenience);
int i;
W_ERROR_HAVE_NO_MEMORY(push);
@@ -1806,7 +1830,7 @@ static WERROR regf_save_hbin(struct regf_data *regf)
regf->header->chksum = regf_hdr_checksum(push->data.data);
talloc_free(push);
- if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
+ if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd, regf->iconv_convenience,
(tdr_push_fn_t)tdr_push_regf_hdr,
regf->header))) {
DEBUG(0, ("Error writing registry file header\n"));
@@ -1819,7 +1843,7 @@ static WERROR regf_save_hbin(struct regf_data *regf)
}
for (i = 0; regf->hbins[i]; i++) {
- if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
+ if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd, regf->iconv_convenience,
(tdr_push_fn_t)tdr_push_hbin_block,
regf->hbins[i]))) {
DEBUG(0, ("Error writing HBIN block\n"));
@@ -1835,13 +1859,14 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
{
struct regf_data *regf;
struct regf_hdr *regf_hdr;
- struct tdr_pull pull;
int i;
struct nk_block nk;
WERROR error;
regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
+ regf->iconv_convenience = lp_iconv_convenience(global_loadparm);
+
W_ERROR_HAVE_NO_MEMORY(regf);
DEBUG(5, ("Attempting to create registry file\n"));
@@ -1870,8 +1895,6 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
regf->header = regf_hdr;
- pull.offset = 0x1000;
-
i = 0;
/* Create all hbin blocks */
regf->hbins = talloc_array(regf, struct hbin_block *, 1);
@@ -1917,16 +1940,18 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
return WERR_OK;
}
-WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
- const char *location, struct hive_key **key)
+WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
+ struct loadparm_context *lp_ctx, struct hive_key **key)
{
struct regf_data *regf;
struct regf_hdr *regf_hdr;
- struct tdr_pull pull;
+ struct tdr_pull *pull;
int i;
regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
+ regf->iconv_convenience = lp_iconv_convenience(lp_ctx);
+
W_ERROR_HAVE_NO_MEMORY(regf);
DEBUG(5, ("Attempting to load registry file\n"));
@@ -1941,10 +1966,11 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
return WERR_GENERAL_FAILURE;
}
- ZERO_STRUCT(pull);
- pull.data.data = (uint8_t*)fd_load(regf->fd, &pull.data.length, regf);
+ pull = tdr_pull_init(regf, regf->iconv_convenience);
+
+ pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, regf);
- if (pull.data.data == NULL) {
+ if (pull->data.data == NULL) {
DEBUG(0, ("Error reading data\n"));
talloc_free(regf);
return WERR_GENERAL_FAILURE;
@@ -1953,7 +1979,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
regf_hdr = talloc(regf, struct regf_hdr);
W_ERROR_HAVE_NO_MEMORY(regf_hdr);
- if (NT_STATUS_IS_ERR(tdr_pull_regf_hdr(&pull, regf_hdr, regf_hdr))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_regf_hdr(pull, regf_hdr, regf_hdr))) {
talloc_free(regf);
return WERR_GENERAL_FAILURE;
}
@@ -1968,15 +1994,15 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
}
/* Validate the header ... */
- if (regf_hdr_checksum(pull.data.data) != regf_hdr->chksum) {
+ if (regf_hdr_checksum(pull->data.data) != regf_hdr->chksum) {
DEBUG(0, ("Registry file checksum error: %s: %d,%d\n",
location, regf_hdr->chksum,
- regf_hdr_checksum(pull.data.data)));
+ regf_hdr_checksum(pull->data.data)));
talloc_free(regf);
return WERR_GENERAL_FAILURE;
}
- pull.offset = 0x1000;
+ pull->offset = 0x1000;
i = 0;
/* Read in all hbin blocks */
@@ -1985,14 +2011,14 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
regf->hbins[0] = NULL;
- while (pull.offset < pull.data.length &&
- pull.offset <= regf->header->last_block) {
+ while (pull->offset < pull->data.length &&
+ pull->offset <= regf->header->last_block) {
struct hbin_block *hbin = talloc(regf->hbins,
struct hbin_block);
W_ERROR_HAVE_NO_MEMORY(hbin);
- if (NT_STATUS_IS_ERR(tdr_pull_hbin_block(&pull, hbin, hbin))) {
+ if (NT_STATUS_IS_ERR(tdr_pull_hbin_block(pull, hbin, hbin))) {
DEBUG(0, ("[%d] Error parsing HBIN block\n", i));
talloc_free(regf);
return WERR_FOOBAR;
@@ -2012,6 +2038,8 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
regf->hbins[i] = NULL;
}
+ talloc_free(pull);
+
DEBUG(1, ("%d HBIN blocks read\n", i));
*key = (struct hive_key *)regf_get_key(parent_ctx, regf,
diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h
index edd6c6713f..a02acbea1e 100644
--- a/source4/lib/registry/registry.h
+++ b/source4/lib/registry/registry.h
@@ -94,7 +94,7 @@ struct registry_operations {
WERROR (*flush_key) (struct registry_key *key);
- WERROR (*get_predefined_key) (const struct registry_context *ctx,
+ WERROR (*get_predefined_key) (struct registry_context *ctx,
uint32_t key_id,
struct registry_key **key);
@@ -195,7 +195,7 @@ const char *reg_get_predef_name(uint32_t hkey);
WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
const char *name,
struct registry_key **key);
-WERROR reg_get_predefined_key(const struct registry_context *ctx,
+WERROR reg_get_predefined_key(struct registry_context *ctx,
uint32_t hkey,
struct registry_key **key);
diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i
index 330f0856e1..1819e7df80 100644
--- a/source4/lib/registry/registry.i
+++ b/source4/lib/registry/registry.i
@@ -25,6 +25,7 @@
#include "includes.h"
#include "registry.h"
+#include "param/param.h"
typedef struct registry_context reg;
typedef struct hive_key hive;
@@ -39,6 +40,7 @@ typedef struct hive_key hive;
%import "../../lib/talloc/talloc.i"
%import "../../auth/credentials/credentials.i"
%import "../../libcli/util/errors.i"
+%import "../../param/param.i"
/* Utility functions */
@@ -86,10 +88,11 @@ WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
free((char **) $1);
}
+%talloctype(reg);
+
typedef struct registry_context {
%extend {
- ~reg() { talloc_free($self); }
WERROR get_predefined_key_by_name(const char *name,
struct registry_key **key);
@@ -101,11 +104,18 @@ typedef struct registry_context {
WERROR mount_hive(struct hive_key *hive_key, uint32_t hkey_id,
const char **elements=NULL);
- }
- %pythoncode {
- def mount(self, path, hkey_id, elements=[]):
- self.mount_hive(Hive(path), hkey_id, elements)
+ WERROR mount_hive(struct hive_key *hive_key, const char *predef_name)
+ {
+ int i;
+ for (i = 0; reg_predefined_keys[i].name; i++) {
+ if (!strcasecmp(reg_predefined_keys[i].name, predef_name))
+ return reg_mount_hive($self, hive_key,
+ reg_predefined_keys[i].handle, NULL);
+ }
+ return WERR_INVALID_NAME;
+ }
+
}
} reg;
@@ -123,12 +133,12 @@ typedef struct registry_context {
WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct loadparm_context *lp_ctx,
struct hive_key **root);
+%talloctype(hive);
+
typedef struct hive_key {
- %extend {
- ~hive() { talloc_free($self); }
- }
} hive;
%rename(open_samba) reg_open_samba;
diff --git a/source4/lib/registry/registry.py b/source4/lib/registry/registry.py
index b61d713df8..67607cd7ac 100644
--- a/source4/lib/registry/registry.py
+++ b/source4/lib/registry/registry.py
@@ -2,7 +2,6 @@
# Version 1.3.33
#
# Don't modify this file, modify the SWIG interface instead.
-# This file is compatible with both classic and new-style classes.
import _registry
import new
@@ -48,45 +47,41 @@ except AttributeError:
del types
+def _swig_setattr_nondynamic_method(set):
+ def set_attr(self,name,value):
+ if (name == "thisown"): return self.this.own(value)
+ if hasattr(self,name) or (name == "this"):
+ set(self,name,value)
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+ return set_attr
+
+
import credentials
+import param
reg_get_predef_name = _registry.reg_get_predef_name
str_regtype = _registry.str_regtype
Registry = _registry.Registry
-class reg(_object):
- __swig_setmethods__ = {}
- __setattr__ = lambda self, name, value: _swig_setattr(self, reg, name, value)
- __swig_getmethods__ = {}
- __getattr__ = lambda self, name: _swig_getattr(self, reg, name)
+class reg(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
- __swig_destroy__ = _registry.delete_reg
- __del__ = lambda self : None;
- def get_predefined_key_by_name(*args, **kwargs): return _registry.reg_get_predefined_key_by_name(*args, **kwargs)
- def get_predefined_key(*args, **kwargs): return _registry.reg_get_predefined_key(*args, **kwargs)
- def apply_patchfile(*args, **kwargs): return _registry.reg_apply_patchfile(*args, **kwargs)
- def mount_hive(*args, **kwargs): return _registry.reg_mount_hive(*args, **kwargs)
- def mount(self, path, hkey_id, elements=[]):
- self.mount_hive(Hive(path), hkey_id, elements)
-
def __init__(self, *args, **kwargs):
- this = _registry.new_reg(*args, **kwargs)
- try: self.this.append(this)
- except: self.this = this
+ _registry.reg_swiginit(self,_registry.new_reg(*args, **kwargs))
+ __swig_destroy__ = _registry.delete_reg
+reg.get_predefined_key_by_name = new_instancemethod(_registry.reg_get_predefined_key_by_name,None,reg)
+reg.get_predefined_key = new_instancemethod(_registry.reg_get_predefined_key,None,reg)
+reg.apply_patchfile = new_instancemethod(_registry.reg_apply_patchfile,None,reg)
+reg.mount_hive = new_instancemethod(_registry.reg_mount_hive,None,reg)
reg_swigregister = _registry.reg_swigregister
reg_swigregister(reg)
Hive = _registry.Hive
-class hive(_object):
- __swig_setmethods__ = {}
- __setattr__ = lambda self, name, value: _swig_setattr(self, hive, name, value)
- __swig_getmethods__ = {}
- __getattr__ = lambda self, name: _swig_getattr(self, hive, name)
+class hive(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
- __swig_destroy__ = _registry.delete_hive
- __del__ = lambda self : None;
def __init__(self, *args, **kwargs):
- this = _registry.new_hive(*args, **kwargs)
- try: self.this.append(this)
- except: self.this = this
+ _registry.hive_swiginit(self,_registry.new_hive(*args, **kwargs))
+ __swig_destroy__ = _registry.delete_hive
hive_swigregister = _registry.hive_swigregister
hive_swigregister(hive)
diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c
index 3ab0af10b5..fcbd2ea165 100644
--- a/source4/lib/registry/registry_wrap.c
+++ b/source4/lib/registry/registry_wrap.c
@@ -9,7 +9,7 @@
* ----------------------------------------------------------------------------- */
#define SWIGPYTHON
-#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
+#define SWIG_PYTHON_NO_BUILD_NONE
/* -----------------------------------------------------------------------------
* This section contains generic SWIG labels for method/variable
* declarations/attributes, and other compiler dependent labels.
@@ -2463,20 +2463,24 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_hive_key swig_types[4]
#define SWIGTYPE_p_int swig_types[5]
#define SWIGTYPE_p_loadparm_context swig_types[6]
-#define SWIGTYPE_p_long_long swig_types[7]
-#define SWIGTYPE_p_p_char swig_types[8]
-#define SWIGTYPE_p_p_hive_key swig_types[9]
-#define SWIGTYPE_p_p_registry_context swig_types[10]
-#define SWIGTYPE_p_p_registry_key swig_types[11]
-#define SWIGTYPE_p_registry_context swig_types[12]
-#define SWIGTYPE_p_short swig_types[13]
-#define SWIGTYPE_p_signed_char swig_types[14]
-#define SWIGTYPE_p_unsigned_char swig_types[15]
-#define SWIGTYPE_p_unsigned_int swig_types[16]
-#define SWIGTYPE_p_unsigned_long_long swig_types[17]
-#define SWIGTYPE_p_unsigned_short swig_types[18]
-static swig_type_info *swig_types[20];
-static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
+#define SWIGTYPE_p_loadparm_service swig_types[7]
+#define SWIGTYPE_p_long_long swig_types[8]
+#define SWIGTYPE_p_p_char swig_types[9]
+#define SWIGTYPE_p_p_hive_key swig_types[10]
+#define SWIGTYPE_p_p_registry_context swig_types[11]
+#define SWIGTYPE_p_p_registry_key swig_types[12]
+#define SWIGTYPE_p_param_context swig_types[13]
+#define SWIGTYPE_p_param_opt swig_types[14]
+#define SWIGTYPE_p_param_section swig_types[15]
+#define SWIGTYPE_p_registry_context swig_types[16]
+#define SWIGTYPE_p_short swig_types[17]
+#define SWIGTYPE_p_signed_char swig_types[18]
+#define SWIGTYPE_p_unsigned_char swig_types[19]
+#define SWIGTYPE_p_unsigned_int swig_types[20]
+#define SWIGTYPE_p_unsigned_long_long swig_types[21]
+#define SWIGTYPE_p_unsigned_short swig_types[22]
+static swig_type_info *swig_types[24];
+static swig_module_info swig_module = {swig_types, 23, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2487,6 +2491,19 @@ static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
# error "This python version requires swig to be run with the '-classic' option"
# endif
#endif
+#if (PY_VERSION_HEX <= 0x02020000)
+# error "This python version requires swig to be run with the '-nomodern' option"
+#endif
+#if (PY_VERSION_HEX <= 0x02020000)
+# error "This python version requires swig to be run with the '-nomodernargs' option"
+#endif
+#ifndef METH_O
+# error "This python version requires swig to be run with the '-nofastunpack' option"
+#endif
+#ifdef SWIG_TypeQuery
+# undef SWIG_TypeQuery
+#endif
+#define SWIG_TypeQuery SWIG_Python_TypeQuery
/*-----------------------------------------------
@(target):= _registry.so
@@ -2509,6 +2526,7 @@ static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
#include "includes.h"
#include "registry.h"
+#include "param/param.h"
typedef struct registry_context reg;
typedef struct hive_key hive;
@@ -2755,7 +2773,6 @@ SWIG_AsVal_int (PyObject * obj, int *val)
return res;
}
-SWIGINTERN void delete_reg(reg *self){ talloc_free(self); }
SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
@@ -2814,7 +2831,15 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
SWIGINTERN WERROR reg_apply_patchfile(reg *self,char const *filename){
return reg_diff_apply(filename, self);
}
-SWIGINTERN void delete_hive(hive *self){ talloc_free(self); }
+SWIGINTERN WERROR reg_mount_hive__SWIG_1(reg *self,struct hive_key *hive_key,char const *predef_name){
+ int i;
+ for (i = 0; reg_predefined_keys[i].name; i++) {
+ if (!strcasecmp(reg_predefined_keys[i].name, predef_name))
+ return reg_mount_hive(self, hive_key,
+ reg_predefined_keys[i].handle, NULL);
+ }
+ return WERR_INVALID_NAME;
+ }
#define SWIG_From_long PyInt_FromLong
@@ -2949,28 +2974,6 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_reg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- reg *arg1 = (reg *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)"O:delete_reg",&obj0)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_reg" "', argument " "1"" of type '" "reg *""'");
- }
- arg1 = (reg *)(argp1);
- delete_reg(arg1);
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_reg_get_predefined_key_by_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
reg *arg1 = (reg *) 0 ;
@@ -3118,7 +3121,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_reg_mount_hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_0(PyObject *SWIGUNUSEDPARM(self), int nobjs, PyObject **swig_obj) {
PyObject *resultobj = 0;
reg *arg1 = (reg *) 0 ;
struct hive_key *arg2 = (struct hive_key *) 0 ;
@@ -3131,41 +3134,34 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive(PyObject *SWIGUNUSEDPARM(self), PyObje
int res2 = 0 ;
unsigned int val3 ;
int ecode3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- PyObject * obj3 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "hive_key",(char *) "hkey_id",(char *) "elements", NULL
- };
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:reg_mount_hive",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_registry_context, 0 | 0 );
+ if ((nobjs < 3) || (nobjs > 4)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_registry_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reg_mount_hive" "', argument " "1"" of type '" "reg *""'");
}
arg1 = (reg *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_hive_key, 0 | 0 );
+ res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_hive_key, 0 | 0 );
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reg_mount_hive" "', argument " "2"" of type '" "struct hive_key *""'");
}
arg2 = (struct hive_key *)(argp2);
- ecode3 = SWIG_AsVal_unsigned_SS_int(obj2, &val3);
+ ecode3 = SWIG_AsVal_unsigned_SS_int(swig_obj[2], &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "reg_mount_hive" "', argument " "3"" of type '" "uint32_t""'");
}
arg3 = (uint32_t)(val3);
- if (obj3) {
+ if (swig_obj[3]) {
{
/* Check if is a list */
- if (PyList_Check(obj3)) {
- int size = PyList_Size(obj3);
+ if (PyList_Check(swig_obj[3])) {
+ int size = PyList_Size(swig_obj[3]);
int i = 0;
arg4 = (char **) malloc((size+1)*sizeof(const char *));
for (i = 0; i < size; i++) {
- PyObject *o = PyList_GetItem(obj3,i);
+ PyObject *o = PyList_GetItem(swig_obj[3],i);
if (PyString_Check(o))
- arg4[i] = PyString_AsString(PyList_GetItem(obj3,i));
+ arg4[i] = PyString_AsString(PyList_GetItem(swig_obj[3],i));
else {
PyErr_SetString(PyExc_TypeError,"list must contain strings");
free(arg4);
@@ -3200,11 +3196,87 @@ fail:
}
+SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_1(PyObject *SWIGUNUSEDPARM(self), int nobjs, PyObject **swig_obj) {
+ PyObject *resultobj = 0;
+ reg *arg1 = (reg *) 0 ;
+ struct hive_key *arg2 = (struct hive_key *) 0 ;
+ char *arg3 = (char *) 0 ;
+ WERROR result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+
+ if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_registry_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reg_mount_hive" "', argument " "1"" of type '" "reg *""'");
+ }
+ arg1 = (reg *)(argp1);
+ res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_hive_key, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reg_mount_hive" "', argument " "2"" of type '" "struct hive_key *""'");
+ }
+ arg2 = (struct hive_key *)(argp2);
+ res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reg_mount_hive" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ result = reg_mount_hive__SWIG_1(arg1,arg2,(char const *)arg3);
+ {
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ }
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_reg_mount_hive(PyObject *self, PyObject *args) {
+ int argc;
+ PyObject *argv[5];
+
+ if (!(argc = SWIG_Python_UnpackTuple(args,"reg_mount_hive",0,4,argv))) SWIG_fail;
+ --argc;
+ if ((argc >= 3) && (argc <= 4)) {
+ int _v = 0;
+ {
+ {
+ int res = SWIG_AsVal_unsigned_SS_int(argv[2], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ return _wrap_reg_mount_hive__SWIG_0(self, argc, argv);
+ }
+check_1:
+
+ if (argc == 3) {
+ return _wrap_reg_mount_hive__SWIG_1(self, argc, argv);
+ }
+
+fail:
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'reg_mount_hive'.\n Possible C/C++ prototypes are:\n"" mount_hive(reg *,struct hive_key *,uint32_t,char const **)\n"" mount_hive(reg *,struct hive_key *,char const *)\n");
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_new_reg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
reg *result = 0 ;
- if (!PyArg_ParseTuple(args,(char *)":new_reg")) SWIG_fail;
+ if (!SWIG_Python_UnpackTuple(args,"new_reg",0,0,0)) SWIG_fail;
result = (reg *)(reg *) calloc(1, sizeof(reg));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_registry_context, SWIG_POINTER_NEW | 0 );
return resultobj;
@@ -3213,20 +3285,48 @@ fail:
}
+SWIGINTERN PyObject *_wrap_delete_reg(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ reg *arg1 = (reg *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_registry_context, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_reg" "', argument " "1"" of type '" "reg *""'");
+ }
+ arg1 = (reg *)(argp1);
+ free((char *) arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *reg_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_registry_context, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *reg_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
SWIGINTERN PyObject *_wrap_Hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
char *arg2 = (char *) 0 ;
struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
- struct hive_key **arg5 = (struct hive_key **) 0 ;
+ struct loadparm_context *arg5 = (struct loadparm_context *) 0 ;
+ struct hive_key **arg6 = (struct hive_key **) 0 ;
WERROR result;
int res2 ;
char *buf2 = 0 ;
@@ -3235,12 +3335,15 @@ SWIGINTERN PyObject *_wrap_Hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args,
int res3 = 0 ;
void *argp4 = 0 ;
int res4 = 0 ;
- struct hive_key *tmp5 ;
+ void *argp5 = 0 ;
+ int res5 = 0 ;
+ struct hive_key *tmp6 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
char * kwnames[] = {
- (char *) "location",(char *) "session_info",(char *) "credentials", NULL
+ (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL
};
{
@@ -3250,12 +3353,15 @@ SWIGINTERN PyObject *_wrap_Hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args,
arg4 = NULL;
}
{
+ arg5 = loadparm_init(NULL);
+ }
+ {
arg1 = NULL;
}
{
- arg5 = &tmp5;
+ arg6 = &tmp6;
}
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OO:Hive",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:Hive",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Hive" "', argument " "2"" of type '" "char const *""'");
@@ -3275,7 +3381,14 @@ SWIGINTERN PyObject *_wrap_Hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args,
}
arg4 = (struct cli_credentials *)(argp4);
}
- result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5);
+ if (obj3) {
+ res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res5)) {
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Hive" "', argument " "5"" of type '" "struct loadparm_context *""'");
+ }
+ arg5 = (struct loadparm_context *)(argp5);
+ }
+ result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
{
if (!W_ERROR_IS_OK(result)) {
PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
@@ -3286,7 +3399,7 @@ SWIGINTERN PyObject *_wrap_Hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args,
}
{
Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg5, SWIGTYPE_p_hive_key, 0);
+ resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
}
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
@@ -3296,20 +3409,34 @@ fail:
}
+SWIGINTERN PyObject *_wrap_new_hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ hive *result = 0 ;
+
+ if (!SWIG_Python_UnpackTuple(args,"new_hive",0,0,0)) SWIG_fail;
+ result = (hive *)(hive *) calloc(1, sizeof(hive));
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_hive_key, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_delete_hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
hive *arg1 = (hive *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- PyObject * obj0 = 0 ;
+ PyObject *swig_obj[1] ;
- if (!PyArg_ParseTuple(args,(char *)"O:delete_hive",&obj0)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_hive_key, SWIG_POINTER_DISOWN | 0 );
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_hive_key, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_hive" "', argument " "1"" of type '" "hive *""'");
}
arg1 = (hive *)(argp1);
- delete_hive(arg1);
+ free((char *) arg1);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -3318,26 +3445,17 @@ fail:
}
-SWIGINTERN PyObject *_wrap_new_hive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- hive *result = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)":new_hive")) SWIG_fail;
- result = (hive *)(hive *) calloc(1, sizeof(hive));
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_hive_key, SWIG_POINTER_NEW | 0 );
- return resultobj;
-fail:
- return NULL;
-}
-
-
SWIGINTERN PyObject *hive_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_hive_key, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *hive_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
@@ -3361,6 +3479,9 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
};
{
+ arg3 = loadparm_init(NULL);
+ }
+ {
arg4 = NULL;
}
{
@@ -3372,12 +3493,14 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
{
arg2 = &tmp2;
}
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OO:open_samba",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
- res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_loadparm_context, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "open_samba" "', argument " "3"" of type '" "struct loadparm_context *""'");
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:open_samba",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (obj0) {
+ res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "open_samba" "', argument " "3"" of type '" "struct loadparm_context *""'");
+ }
+ arg3 = (struct loadparm_context *)(argp3);
}
- arg3 = (struct loadparm_context *)(argp3);
if (obj1) {
res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_auth_session_info, 0 | 0 );
if (!SWIG_IsOK(res4)) {
@@ -3414,17 +3537,19 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"reg_get_predef_name", (PyCFunction) _wrap_reg_get_predef_name, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"str_regtype", (PyCFunction) _wrap_str_regtype, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Registry", (PyCFunction) _wrap_Registry, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"delete_reg", _wrap_delete_reg, METH_VARARGS, NULL},
{ (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"reg_apply_patchfile", (PyCFunction) _wrap_reg_apply_patchfile, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_mount_hive", (PyCFunction) _wrap_reg_mount_hive, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"new_reg", _wrap_new_reg, METH_VARARGS, NULL},
+ { (char *)"reg_mount_hive", _wrap_reg_mount_hive, METH_VARARGS, NULL},
+ { (char *)"new_reg", (PyCFunction)_wrap_new_reg, METH_NOARGS, NULL},
+ { (char *)"delete_reg", (PyCFunction)_wrap_delete_reg, METH_O, NULL},
{ (char *)"reg_swigregister", reg_swigregister, METH_VARARGS, NULL},
+ { (char *)"reg_swiginit", reg_swiginit, METH_VARARGS, NULL},
{ (char *)"Hive", (PyCFunction) _wrap_Hive, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"delete_hive", _wrap_delete_hive, METH_VARARGS, NULL},
- { (char *)"new_hive", _wrap_new_hive, METH_VARARGS, NULL},
+ { (char *)"new_hive", (PyCFunction)_wrap_new_hive, METH_NOARGS, NULL},
+ { (char *)"delete_hive", (PyCFunction)_wrap_delete_hive, METH_O, NULL},
{ (char *)"hive_swigregister", hive_swigregister, METH_VARARGS, NULL},
+ { (char *)"hive_swiginit", hive_swiginit, METH_VARARGS, NULL},
{ (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, NULL},
{ NULL, NULL, 0, NULL }
};
@@ -3438,12 +3563,16 @@ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_hive_key = {"_p_hive_key", "struct hive_key *|hive *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_hive_key = {"_p_p_hive_key", "struct hive_key **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_registry_context = {"_p_p_registry_context", "struct registry_context **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_registry_key = {"_p_p_registry_key", "struct registry_key **", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_registry_context = {"_p_registry_context", "struct registry_context *|reg *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
@@ -3460,11 +3589,15 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_hive_key,
&_swigt__p_int,
&_swigt__p_loadparm_context,
+ &_swigt__p_loadparm_service,
&_swigt__p_long_long,
&_swigt__p_p_char,
&_swigt__p_p_hive_key,
&_swigt__p_p_registry_context,
&_swigt__p_p_registry_key,
+ &_swigt__p_param_context,
+ &_swigt__p_param_opt,
+ &_swigt__p_param_section,
&_swigt__p_registry_context,
&_swigt__p_short,
&_swigt__p_signed_char,
@@ -3481,11 +3614,15 @@ static swig_cast_info _swigc__p_cli_credentials[] = { {&_swigt__p_cli_credentia
static swig_cast_info _swigc__p_hive_key[] = { {&_swigt__p_hive_key, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_hive_key[] = { {&_swigt__p_p_hive_key, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_registry_context[] = { {&_swigt__p_p_registry_context, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_registry_key[] = { {&_swigt__p_p_registry_key, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_registry_context[] = { {&_swigt__p_registry_context, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
@@ -3502,11 +3639,15 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_hive_key,
_swigc__p_int,
_swigc__p_loadparm_context,
+ _swigc__p_loadparm_service,
_swigc__p_long_long,
_swigc__p_p_char,
_swigc__p_p_hive_key,
_swigc__p_p_registry_context,
_swigc__p_p_registry_key,
+ _swigc__p_param_context,
+ _swigc__p_param_opt,
+ _swigc__p_param_section,
_swigc__p_registry_context,
_swigc__p_short,
_swigc__p_signed_char,
diff --git a/source4/lib/registry/rpc.c b/source4/lib/registry/rpc.c
index ac0eecd0ac..7f800b786e 100644
--- a/source4/lib/registry/rpc.c
+++ b/source4/lib/registry/rpc.c
@@ -91,7 +91,7 @@ static struct {
static WERROR rpc_query_key(const struct registry_key *k);
-static WERROR rpc_get_predefined_key(const struct registry_context *ctx,
+static WERROR rpc_get_predefined_key(struct registry_context *ctx,
uint32_t hkey_type,
struct registry_key **k)
{
diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c
index a5a60ba610..02f3363bab 100644
--- a/source4/lib/registry/samba.c
+++ b/source4/lib/registry/samba.c
@@ -40,11 +40,11 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
lp_private_dir(lp_ctx),
name);
- error = reg_open_hive(ctx, location, auth_info, creds, &hive);
+ error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive);
if (W_ERROR_EQUAL(error, WERR_NOT_FOUND))
error = reg_open_ldb_file(ctx, location, auth_info,
- creds, &hive);
+ creds, lp_ctx, &hive);
if (!W_ERROR_IS_OK(error))
return error;
diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c
index 1acb6342e7..25a89793bd 100644
--- a/source4/lib/registry/tests/generic.c
+++ b/source4/lib/registry/tests/generic.c
@@ -23,6 +23,7 @@
#include "lib/registry/registry.h"
#include "torture/torture.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
struct torture_suite *torture_registry_hive(TALLOC_CTX *mem_ctx);
struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx);
@@ -52,7 +53,7 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx)
static bool test_reg_val_data_string_sz(struct torture_context *ctx)
{
DATA_BLOB db;
- db.length = convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+ db.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16,
"bla", 3, (void **)&db.data);
torture_assert_str_equal(ctx, "bla",
reg_val_data_string(ctx, REG_SZ, db),
@@ -87,7 +88,7 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx)
static bool test_reg_val_description(struct torture_context *ctx)
{
DATA_BLOB data;
- data.length = convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+ data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16,
"stationary traveller",
strlen("stationary traveller"),
(void **)&data.data);
@@ -101,7 +102,7 @@ static bool test_reg_val_description(struct torture_context *ctx)
static bool test_reg_val_description_nullname(struct torture_context *ctx)
{
DATA_BLOB data;
- data.length = convert_string_talloc(ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+ data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16,
"west berlin",
strlen("west berlin"),
(void **)&data.data);
diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c
index 2a0f04eb54..fdb7282395 100644
--- a/source4/lib/registry/tests/hive.c
+++ b/source4/lib/registry/tests/hive.c
@@ -290,7 +290,7 @@ static bool hive_setup_dir(struct torture_context *tctx, void **data)
{
struct hive_key *key;
WERROR error;
- const char *dirname;
+ char *dirname;
NTSTATUS status;
status = torture_temp_dir(tctx, "hive-dir", &dirname);
@@ -314,7 +314,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data)
{
struct hive_key *key;
WERROR error;
- const char *dirname;
+ char *dirname;
NTSTATUS status;
status = torture_temp_dir(tctx, "hive-ldb", &dirname);
@@ -323,7 +323,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data)
rmdir(dirname);
- error = reg_open_ldb_file(tctx, dirname, NULL, NULL, &key);
+ error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->lp_ctx, &key);
if (!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to initialize ldb hive\n");
return false;
@@ -338,7 +338,7 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data)
{
struct hive_key *key;
WERROR error;
- const char *dirname;
+ char *dirname;
NTSTATUS status;
status = torture_temp_dir(tctx, "hive-dir", &dirname);
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index f0035071f2..6c520f54ed 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -535,7 +535,7 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
{
struct registry_context *rctx;
WERROR error;
- const char *tempdir;
+ char *tempdir;
NTSTATUS status;
struct hive_key *hive_key;
const char *filename;
@@ -547,7 +547,7 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
- error = reg_open_ldb_file(tctx, filename, NULL, NULL, &hive_key);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->lp_ctx, &hive_key);
torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c
index c9293cd310..29e96475e6 100644
--- a/source4/lib/registry/tools/common.c
+++ b/source4/lib/registry/tools/common.c
@@ -42,13 +42,14 @@ struct registry_context *reg_common_open_remote(const char *remote,
}
struct registry_key *reg_common_open_file(const char *path,
+ struct loadparm_context *lp_ctx,
struct cli_credentials *creds)
{
struct hive_key *hive_root;
struct registry_context *h;
WERROR error;
- error = reg_open_hive(NULL, path, NULL, creds, &hive_root);
+ error = reg_open_hive(NULL, path, NULL, creds, lp_ctx, &hive_root);
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open '%s': %s \n",
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 2c692952fb..329d6ab670 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -500,7 +500,7 @@ int main(int argc, char **argv)
ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx,
cmdline_credentials);
} else if (file != NULL) {
- ctx->current = reg_common_open_file(file, cmdline_credentials);
+ ctx->current = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
if (ctx->current == NULL)
return 1;
ctx->registry = ctx->current->context;
@@ -546,12 +546,16 @@ int main(int argc, char **argv)
via readline :-( */
line = smb_readline(prompt, NULL, reg_completion);
- if (line == NULL)
+ if (line == NULL) {
+ free(prompt);
break;
+ }
if (line[0] != '\n') {
ret = W_ERROR_IS_OK(process_cmd(ctx, line));
}
+ free(line);
+ free(prompt);
}
talloc_free(ctx);
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index b267e11b43..0f47d8f8dd 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -131,7 +131,7 @@ int main(int argc, char **argv)
if (remote != NULL) {
h = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials);
} else if (file != NULL) {
- start_key = reg_common_open_file(file, cmdline_credentials);
+ start_key = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
} else {
h = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx);
}
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index f75fc835b5..a251ae49a5 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "lib/registry/registry.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
/**
* @file
@@ -61,7 +62,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
switch (type) {
case REG_EXPAND_SZ:
case REG_SZ:
- convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UTF16, CH_UNIX,
+ convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
data.data, data.length,
(void **)&ret);
return ret;
@@ -117,7 +118,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str,
{
case REG_SZ:
case REG_EXPAND_SZ:
- data->length = convert_string_talloc(mem_ctx, global_smb_iconv_convenience, CH_UNIX, CH_UTF16,
+ data->length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
data_str, strlen(data_str),
(void **)&data->data);
break;