summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2010-03-15 11:07:36 +0100
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2010-03-15 13:27:34 +0100
commit80300af278d346049f9bfd48f013bc2055dc104b (patch)
tree665e49d32e4c1d1aa8a2f812109261fd2c91199f /source4/lib
parentc3eb509dea715620da086f3dc8e5702fb9d03e1c (diff)
downloadsamba-80300af278d346049f9bfd48f013bc2055dc104b.tar.gz
samba-80300af278d346049f9bfd48f013bc2055dc104b.tar.bz2
samba-80300af278d346049f9bfd48f013bc2055dc104b.zip
s4:registry - add support for REG_QWORD values
Basically the same as REG_DWORD but these are eight byte long.
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/registry/ldb.c65
-rw-r--r--source4/lib/registry/util.c18
2 files changed, 82 insertions, 1 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 9e77f1f6d5..5c52cb238f 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -110,6 +110,33 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
}
break;
+ case REG_QWORD:
+ if (val != NULL) {
+ if (val->data[0] != '\0') {
+ /* The data is a plain QWORD */
+ uint64_t tmp = strtoull((char *)val->data, NULL, 0);
+ data->data = talloc_size(mem_ctx, sizeof(uint64_t) + 1);
+ if (data->data != NULL) {
+ SBVAL(data->data, 0, tmp);
+ }
+ data->length = sizeof(uint64_t);
+ } else {
+ /* Provide a possibility to store also UTF8
+ * REG_QWORD values. This is done by adding a
+ * '\0' in front of the data */
+ data->data = talloc_size(mem_ctx, val->length - 1);
+ if (data->data != NULL) {
+ memcpy(data->data, val->data + 1,
+ val->length - 1);
+ }
+ data->length = val->length - 1;
+ }
+ } else {
+ data->data = NULL;
+ data->length = 0;
+ }
+ break;
+
case REG_BINARY:
default:
if (val != NULL) {
@@ -231,6 +258,44 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
}
break;
+ case REG_QWORD:
+ if ((data.length > 0) && (data.data != NULL)) {
+ if (data.length == sizeof(uint64_t)) {
+ char *conv_str;
+
+ conv_str = talloc_asprintf(msg, "0x%llx", BVAL(data.data, 0));
+ if (conv_str == NULL) {
+ talloc_free(msg);
+ return NULL;
+ }
+ ret = ldb_msg_add_string(msg, "data", conv_str);
+ } else {
+ /* Provide a possibility to store also UTF8
+ * REG_QWORD values. This is done by adding a
+ * '\0' in front of the data */
+ struct ldb_val *val;
+
+ val = talloc_zero(msg, struct ldb_val);
+ if (val == NULL) {
+ talloc_free(msg);
+ return NULL;
+ }
+
+ val->data = talloc_size(msg, data.length + 1);
+ if (val->data == NULL) {
+ talloc_free(msg);
+ return NULL;
+ }
+ val->data[0] = '\0';
+ memcpy(val->data + 1, data.data, data.length);
+ val->length = data.length + 1;
+ ret = ldb_msg_add_value(msg, "data", val, NULL);
+ }
+ } else {
+ ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
+ }
+ break;
+
case REG_BINARY:
default:
if ((data.length > 0) && (data.data != NULL)
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index 6ff61942f9..c7f4c0844e 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -94,6 +94,16 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx,
}
}
break;
+ case REG_QWORD:
+ if (data.length == sizeof(uint64_t)) {
+ if (BVAL(data.data, 0) == 0) {
+ ret = talloc_strdup(mem_ctx, "0");
+ } else {
+ ret = talloc_asprintf(mem_ctx, "0x%llx",
+ BVAL(data.data, 0));
+ }
+ }
+ break;
case REG_NONE:
/* "NULL" is the right return value */
break;
@@ -159,10 +169,16 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
break;
case REG_DWORD: {
uint32_t tmp = strtol(data_str, NULL, 0);
- *data = data_blob_talloc(mem_ctx, NULL, 4);
+ *data = data_blob_talloc(mem_ctx, NULL, sizeof(uint32_t));
SIVAL(data->data, 0, tmp);
}
break;
+ case REG_QWORD: {
+ uint64_t tmp = strtoll(data_str, NULL, 0);
+ *data = data_blob_talloc(mem_ctx, NULL, sizeof(uint64_t));
+ SBVAL(data->data, 0, tmp);
+ }
+ break;
case REG_NONE:
ZERO_STRUCTP(data);
break;