[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha3-1766-g0f2de29

Jelmer Vernooij jelmer at samba.org
Fri May 23 14:20:47 GMT 2008


The branch, v4-0-test has been updated
       via  0f2de29dae1b29030c2c7bcee609919fce0d674b (commit)
       via  0af138a85bba21a5009967e2610c898615fb536b (commit)
       via  0d5752c940360a0ceb5e23cd6f71cbc61271137a (commit)
       via  33cc9b0f5fae7510d490928195016cf7fe3bbe42 (commit)
       via  e8d96b61db1cddc2d8dca45e6e9b53d5c31ee5d4 (commit)
       via  b74fc23825a54eb101b413ee76b21ee605dfb16c (commit)
       via  70ebb22c3df178a26c26c0a25c5722ff9ccdb0b4 (commit)
       via  6ec206ba58777395b2d1251680b21648f4c0f78e (commit)
       via  cc38f2f086b92bbe65bd6e7f4e03fdf7f21ef2f6 (commit)
       via  497977c36c621a4820be51cbcb7b78eac1e292b7 (commit)
       via  6e9b1e35a269af2eda79356c1525f5413656d648 (commit)
       via  7ba2e5dc5b6d82457c298f7ecdb6baea43f04854 (commit)
       via  c4626f21a898da27a051f2c67f8fd73f55d4fc7d (commit)
       via  664a035dd9fc6e3b50a771baa98f8d79360cc4c1 (commit)
      from  7ca46322f5aa650cfd89c4f887393da67ae9dc7b (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 0f2de29dae1b29030c2c7bcee609919fce0d674b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri May 23 16:19:51 2008 +0200

    getting/setting security options works for the regf backend now

commit 0af138a85bba21a5009967e2610c898615fb536b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri May 23 16:19:00 2008 +0200

    Include test case name when reporting with subunit. This should make it possible to having a test fail against some test cases and success against other ones.

commit 0d5752c940360a0ceb5e23cd6f71cbc61271137a
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri May 23 16:17:58 2008 +0200

    Cope with new event context parameter in API and removed parameters to reg_open_local().

commit 33cc9b0f5fae7510d490928195016cf7fe3bbe42
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri May 23 16:17:23 2008 +0200

    Report full 'path' of unexpected test results for easier inclusion in knownfailure file.

commit e8d96b61db1cddc2d8dca45e6e9b53d5c31ee5d4
Merge: b74fc23825a54eb101b413ee76b21ee605dfb16c 7ca46322f5aa650cfd89c4f887393da67ae9dc7b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri May 23 15:24:40 2008 +0200

    Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into registry

commit b74fc23825a54eb101b413ee76b21ee605dfb16c
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Apr 15 22:19:05 2008 +0200

    Fix const.

commit 70ebb22c3df178a26c26c0a25c5722ff9ccdb0b4
Merge: 6ec206ba58777395b2d1251680b21648f4c0f78e b9cac469f3c869a26f415a6c551cf6e8fbb06ed6
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Apr 15 22:08:49 2008 +0200

    Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into registry

commit 6ec206ba58777395b2d1251680b21648f4c0f78e
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Apr 15 22:08:31 2008 +0200

    Fix formatting, remove unused function.

commit cc38f2f086b92bbe65bd6e7f4e03fdf7f21ef2f6
Author: Wilco Baan Hofman <wilco at synlap.(none)>
Date:   Tue Apr 15 21:35:59 2008 +0200

    More patchfile fixes. Write support should work now.

commit 497977c36c621a4820be51cbcb7b78eac1e292b7
Author: Wilco Baan Hofman <wilco at synlap.(none)>
Date:   Tue Apr 15 19:57:29 2008 +0200

    Fix PReg write support.
    Add tests for patch files (.REG and PReg).

commit 6e9b1e35a269af2eda79356c1525f5413656d648
Author: Wilco Baan Hofman <wilco at synlap.(none)>
Date:   Tue Apr 15 11:52:33 2008 +0200

    Fixed the patchfile tests and tidy up the patchfile backends.

commit 7ba2e5dc5b6d82457c298f7ecdb6baea43f04854
Author: Wilco Baan Hofman <wilco at synlap.(none)>
Date:   Mon Apr 14 22:56:14 2008 +0200

    Remove debug stuff.

commit c4626f21a898da27a051f2c67f8fd73f55d4fc7d
Author: Wilco Baan Hofman <wilco at synlap.(none)>
Date:   Mon Apr 14 22:52:51 2008 +0200

    Add support for security descriptors. Also patched the regf backend to support this.
    Did not touch the ldb, dir and rpc backends yet.

commit 664a035dd9fc6e3b50a771baa98f8d79360cc4c1
Author: Wilco Baan Hofman <wilco at synlap.(none)>
Date:   Mon Apr 14 12:48:25 2008 +0200

    Attempt to fix the patchfile_preg backend for big endian machines.
    Update some functions to properly state what is not supported (yet).
    Registry .reg uses UCS-2, not UTF-16.

-----------------------------------------------------------------------

Summary of changes:
 source/lib/registry/hive.c             |   18 +++
 source/lib/registry/interface.c        |   25 +---
 source/lib/registry/local.c            |   16 ++
 source/lib/registry/patchfile.c        |   27 +++-
 source/lib/registry/patchfile_dotreg.c |   10 +-
 source/lib/registry/patchfile_preg.c   |   97 +++++++++++--
 source/lib/registry/regf.c             |   64 +++++++--
 source/lib/registry/registry.h         |   26 +++-
 source/lib/registry/tests/diff.c       |  242 ++++++++++++++++++++++++++++----
 source/lib/registry/tests/hive.c       |   55 +++++++-
 source/lib/registry/tests/registry.c   |    8 +-
 source/samba4-knownfail                |    3 +-
 source/selftest/output/plain.pm        |    4 +-
 source/torture/smbtorture.c            |   27 +++-
 14 files changed, 524 insertions(+), 98 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/registry/hive.c b/source/lib/registry/hive.c
index 4a2309f..5105040 100644
--- a/source/lib/registry/hive.c
+++ b/source/lib/registry/hive.c
@@ -144,6 +144,24 @@ WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
 	return key->ops->enum_value(mem_ctx, key, idx, name, type, data);
 }
 
+WERROR hive_get_sec_desc(TALLOC_CTX *mem_ctx,
+			 struct hive_key *key, 
+			 struct security_descriptor **security)
+{
+	if (key->ops->get_sec_desc == NULL)
+		return WERR_NOT_SUPPORTED;
+
+	return key->ops->get_sec_desc(mem_ctx, key, security);
+}
+
+WERROR hive_set_sec_desc(struct hive_key *key, 
+			 const struct security_descriptor *security)
+{
+	if (key->ops->set_sec_desc == NULL)
+		return WERR_NOT_SUPPORTED;
+
+	return key->ops->set_sec_desc(key, security);
+}
 
 WERROR hive_key_del_value(struct hive_key *key, const char *name)
 {
diff --git a/source/lib/registry/interface.c b/source/lib/registry/interface.c
index ff3ddf0..c9b3b06 100644
--- a/source/lib/registry/interface.c
+++ b/source/lib/registry/interface.c
@@ -248,10 +248,10 @@ _PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx,
 		return WERR_INVALID_PARAM;
 
 	/* A 'real' set function has preference */
-	if (key->context->ops->get_security == NULL)
+	if (key->context->ops->get_sec_desc == NULL)
 		return WERR_NOT_SUPPORTED;
 
-	return key->context->ops->get_security(ctx, key, secdesc);
+	return key->context->ops->get_sec_desc(ctx, key, secdesc);
 }
 
 /**
@@ -282,27 +282,14 @@ _PUBLIC_ WERROR reg_key_flush(struct registry_key *key)
 	return key->context->ops->flush_key(key);
 }
 
-_PUBLIC_ WERROR reg_get_security(TALLOC_CTX *mem_ctx,
-				 const struct registry_key *key,
-				 struct security_descriptor **security)
-{
-	if (key == NULL)
-		return WERR_INVALID_PARAM;
-
-	if (key->context->ops->get_security == NULL)
-		return WERR_NOT_SUPPORTED;
-
-	return key->context->ops->get_security(mem_ctx, key, security);
-}
-
-_PUBLIC_ WERROR reg_set_security(struct registry_key *key,
-				 struct security_descriptor *security)
+_PUBLIC_ WERROR reg_set_sec_desc(struct registry_key *key,
+				 const struct security_descriptor *security)
 {
 	if (key == NULL)
 		return WERR_INVALID_PARAM;
 
-	if (key->context->ops->set_security == NULL)
+	if (key->context->ops->set_sec_desc == NULL)
 		return WERR_NOT_SUPPORTED;
 
-	return key->context->ops->set_security(key, security);
+	return key->context->ops->set_sec_desc(key, security);
 }
diff --git a/source/lib/registry/local.c b/source/lib/registry/local.c
index 47d6d4c..4af95e2 100644
--- a/source/lib/registry/local.c
+++ b/source/lib/registry/local.c
@@ -274,7 +274,21 @@ static WERROR local_get_key_info(TALLOC_CTX *mem_ctx,
 				 last_change_time, max_subkeynamelen, 
 				 max_valnamelen, max_valbufsize);
 }
+static WERROR local_get_sec_desc(TALLOC_CTX *mem_ctx, 
+				 const struct registry_key *key, 
+				 struct security_descriptor **security)
+{
+	const struct local_key *local = (const struct local_key *)key;
 
+	return hive_get_sec_desc(mem_ctx, local->hive_key, security);
+}
+static WERROR local_set_sec_desc(struct registry_key *key, 
+				 const struct security_descriptor *security)
+{
+	const struct local_key *local = (const struct local_key *)key;
+
+	return hive_set_sec_desc(local->hive_key, security);
+}
 const static struct registry_operations local_ops = {
 	.name = "local",
 	.open_key = local_open_key,
@@ -288,6 +302,8 @@ const static struct registry_operations local_ops = {
 	.delete_value = local_delete_value,
 	.flush_key = local_flush_key,
 	.get_key_info = local_get_key_info,
+	.get_sec_desc = local_get_sec_desc,
+	.set_sec_desc = local_set_sec_desc,
 };
 
 WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx)
diff --git a/source/lib/registry/patchfile.c b/source/lib/registry/patchfile.c
index 15e3a15..0ede310 100644
--- a/source/lib/registry/patchfile.c
+++ b/source/lib/registry/patchfile.c
@@ -45,7 +45,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
 			     void *callback_data)
 {
 	int i;
-	struct registry_key *t1, *t2;
+	struct registry_key *t1 = NULL, *t2 = NULL;
 	char *tmppath;
 	const char *keyname1;
 	WERROR error, error1, error2;
@@ -295,7 +295,7 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
 
 	/* Reset position in file */
 	lseek(fd, 0, SEEK_SET);
-#if 0
+#if 0 /* These backends are not supported yet. */
 	if (strncmp(hdr, "CREG", 4) == 0) {
 		/* Must be a W9x CREG Config.pol file */
 		return reg_creg_diff_load(diff, fd);
@@ -320,12 +320,33 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
 {
 	struct registry_context *ctx = (struct registry_context *)_ctx;
 	struct registry_key *tmp;
+	char *buf, *buf_ptr;
 	WERROR error;
 
+	/* Recursively create the path */
+	buf = talloc_strdup(ctx, key_name);
+	buf_ptr = buf;
+
+	while (*buf_ptr++ != '\0' ) {
+		if (*buf_ptr == '\\') {
+			*buf_ptr = '\0';
+			error = reg_key_add_abs(ctx, ctx, buf, 0, NULL, &tmp);
+
+			if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
+				    !W_ERROR_IS_OK(error)) {
+				DEBUG(0, ("Error adding new key '%s': %s\n",
+					key_name, win_errstr(error)));
+				return error;
+			}
+			*buf_ptr++ = '\\';
+		}
+	}
+
+	/* Add the key */
 	error = reg_key_add_abs(ctx, ctx, key_name, 0, NULL, &tmp);
 
 	if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
-	    !W_ERROR_IS_OK(error)) {
+		    !W_ERROR_IS_OK(error)) {
 		DEBUG(0, ("Error adding new key '%s': %s\n",
 			key_name, win_errstr(error)));
 		return error;
diff --git a/source/lib/registry/patchfile_dotreg.c b/source/lib/registry/patchfile_dotreg.c
index 59f4044..1bc9c60 100644
--- a/source/lib/registry/patchfile_dotreg.c
+++ b/source/lib/registry/patchfile_dotreg.c
@@ -3,7 +3,7 @@
    Reading .REG files
 
    Copyright (C) Jelmer Vernooij 2004-2007
-   Copyright (C) Wilco Baan Hofman 2006
+   Copyright (C) Wilco Baan Hofman 2006-2008
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* FIXME Newer .REG files, created by Windows XP and above use unicode UTF-16 */
+/* FIXME Newer .REG files, created by Windows XP and above use unicode UCS-2 */
 
 #include "includes.h"
 #include "lib/registry/registry.h"
@@ -112,8 +112,8 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
 	data->iconv_convenience = iconv_convenience;
 
 	if (filename) {
-		data->fd = open(filename, O_CREAT, 0755);
-		if (data->fd == -1) {
+		data->fd = open(filename, O_CREAT|O_WRONLY, 0755);
+		if (data->fd < 0) {
 			DEBUG(0, ("Unable to open %s\n", filename));
 			return WERR_BADFILE;
 		}
@@ -121,7 +121,7 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
 		data->fd = STDOUT_FILENO;
 	}
 
-	fdprintf(data->fd, "%s\n", HEADER_STRING);
+	fdprintf(data->fd, "%s\n\n", HEADER_STRING);
 
 	*callbacks = talloc(ctx, struct reg_diff_callbacks);
 
diff --git a/source/lib/registry/patchfile_preg.c b/source/lib/registry/patchfile_preg.c
index 0fa367b..bb46495 100644
--- a/source/lib/registry/patchfile_preg.c
+++ b/source/lib/registry/patchfile_preg.c
@@ -2,7 +2,7 @@
    Unix SMB/CIFS implementation.
    Reading Registry.pol PReg registry files
 
-   Copyright (C) Wilco Baan Hofman 2006
+   Copyright (C) Wilco Baan Hofman 2006-2008
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,9 +23,12 @@
 #include "lib/registry/registry.h"
 #include "system/filesys.h"
 #include "param/param.h"
+#include "librpc/gen_ndr/winreg.h"
 
 struct preg_data {
 	int fd;
+	TALLOC_CTX *ctx;
+	struct smb_iconv_convenience *ic;
 };
 
 static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
@@ -38,14 +41,22 @@ static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
 	push_codepoint(ic, 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)
+static WERROR preg_write_utf16(struct smb_iconv_convenience *ic, int fd, const char *string)
 {
+	codepoint_t v;
+	uint16_t i;
+	size_t size;
+
+	for (i = 0; i < strlen(string); i+=size) {
+		v = next_codepoint(ic, &string[i], &size);
+		if (write(fd, &v, 2) < 2) {
+			return WERR_GENERAL_FAILURE;
+		}
+	}
 	return WERR_OK;
 }
-
-static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
+/* PReg does not support adding keys. */
+static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
 {
 	return WERR_OK;
 }
@@ -54,24 +65,73 @@ 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 = _data;
+	uint32_t buf;
+	
+	preg_write_utf16(data->ic, data->fd, "[");
+	preg_write_utf16(data->ic, data->fd, key_name);
+	preg_write_utf16(data->ic, data->fd, ";");
+	preg_write_utf16(data->ic, data->fd, value_name);
+	preg_write_utf16(data->ic, data->fd, ";");
+	SIVAL(&buf, 0, value_type);
+	write(data->fd, &buf, sizeof(uint32_t));
+	preg_write_utf16(data->ic, data->fd, ";");
+	SIVAL(&buf, 0, value_data.length);
+	write(data->fd, &buf, sizeof(uint32_t));
+	preg_write_utf16(data->ic, data->fd, ";");
+	write(data->fd, value_data.data, value_data.length);
+	preg_write_utf16(data->ic, data->fd, "]");
+	
 	return WERR_OK;
 }
 
+static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
+{
+	struct preg_data *data = _data;
+	char *parent_name;
+	DATA_BLOB blob;
+
+	parent_name = talloc_strndup(data->ctx, key_name, strrchr(key_name, '\\')-key_name);
+	blob.data = (void *)talloc_strndup(data->ctx, key_name+(strrchr(key_name, '\\')-key_name)+1, 
+			strlen(key_name)-(strrchr(key_name, '\\')-key_name));
+	blob.length = strlen((char *)blob.data)+1;
+	
+
+	/* FIXME: These values should be accumulated to be written at done(). */
+	return reg_preg_diff_set_value(data, parent_name, "**DeleteKeys", REG_SZ, blob);
+}
+
 static WERROR reg_preg_diff_del_value(void *_data, const char *key_name,
 				      const char *value_name)
 {
-	return WERR_OK;
+	struct preg_data *data = _data;
+	char *val;
+	DATA_BLOB blob;
+
+	val = talloc_asprintf(data->ctx, "**Del.%s", value_name);
+
+	blob.data = (void *)talloc(data->ctx, uint32_t);
+	*(uint32_t *)blob.data = 0;
+	blob.length = 4;
+	return reg_preg_diff_set_value(data, key_name, val, REG_DWORD, blob);
 }
 
 static WERROR reg_preg_diff_del_all_values(void *_data, const char *key_name)
 {
-	return WERR_OK;
+	struct preg_data *data = _data;
+	DATA_BLOB blob;
+
+	blob.data = (void *)talloc(data->ctx, uint32_t);
+	*(uint32_t *)blob.data = 0;	
+	blob.length = 4;
+
+	return reg_preg_diff_set_value(data, key_name, "**DelVals.", REG_DWORD, blob);
 }
 
 static WERROR reg_preg_diff_done(void *_data)
 {
 	struct preg_data *data = (struct preg_data *)_data;
-
+	
 	close(data->fd);
 	talloc_free(data);
 	return WERR_OK;
@@ -81,6 +141,7 @@ static WERROR reg_preg_diff_done(void *_data)
  * Save registry diff
  */
 _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+				   struct smb_iconv_convenience *ic,
 				   struct reg_diff_callbacks **callbacks,
 				   void **callback_data)
 {
@@ -95,18 +156,22 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
 	*callback_data = data;
 
 	if (filename) {
-		data->fd = open(filename, O_CREAT, 0755);
-		if (data->fd == -1) {
+		data->fd = open(filename, O_CREAT|O_WRONLY, 0755);
+		if (data->fd < 0) {
 			DEBUG(0, ("Unable to open %s\n", filename));
 			return WERR_BADFILE;
 		}
 	} else {
 		data->fd = STDOUT_FILENO;
 	}
-	snprintf(preg_header.hdr, 4, "PReg");
+
+	strncpy(preg_header.hdr, "PReg", 4);
 	SIVAL(&preg_header, 4, 1);
 	write(data->fd, (uint8_t *)&preg_header,8);
 
+	data->ctx = ctx;
+	data->ic = ic;
+
 	*callbacks = talloc(ctx, struct reg_diff_callbacks);
 
 	(*callbacks)->add_key = reg_preg_diff_add_key;
@@ -149,6 +214,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 		ret = WERR_GENERAL_FAILURE;
 		goto cleanup;
 	}
+	preg_header.version = IVAL(&preg_header.version, 0);
+
 	if (strncmp(preg_header.hdr, "PReg", 4) != 0) {
 		DEBUG(0, ("This file is not a valid preg registry file\n"));
 		ret = WERR_GENERAL_FAILURE;
@@ -177,7 +244,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 		       *buf_ptr != ';' && buf_ptr-buf < buf_size) {
 			buf_ptr++;
 		}
-		key = talloc_asprintf(mem_ctx, "\\%s", buf);
+		buf[buf_ptr-buf] = '\0';
+		key = talloc_strdup(mem_ctx, buf);
 
 		/* Get the name */
 		buf_ptr = buf;
@@ -185,6 +253,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 		       *buf_ptr != ';' && buf_ptr-buf < buf_size) {
 			buf_ptr++;
 		}
+		buf[buf_ptr-buf] = '\0';
 		value_name = talloc_strdup(mem_ctx, buf);
 
 		/* Get the type */
@@ -193,6 +262,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
 			ret = WERR_GENERAL_FAILURE;
 			goto cleanup;
 		}
+		value_type = IVAL(&value_type, 0);
+
 		/* Read past delimiter */
 		buf_ptr = buf;
 		if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
diff --git a/source/lib/registry/regf.c b/source/lib/registry/regf.c
index 46ccca9..57a895a 100644
--- a/source/lib/registry/regf.c
+++ b/source/lib/registry/regf.c
@@ -25,6 +25,8 @@
 #include "librpc/gen_ndr/winreg.h"
 #include "param/param.h"
 #include "lib/registry/registry.h"
+#include "libcli/security/security.h"
+
 
 static struct hive_operations reg_backend_regf;
 
@@ -1915,9 +1917,12 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
 {
 	struct regf_data *regf;
 	struct regf_hdr *regf_hdr;
-	int i;
 	struct nk_block nk;
+	struct sk_block sk;
 	WERROR error;
+	DATA_BLOB data;
+	struct security_descriptor *sd;
+	uint32_t sk_offset;
 
 	regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
 
@@ -1945,20 +1950,17 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
 	regf_hdr->version.minor = minor_version;
 	regf_hdr->last_block = 0x1000; /* Block size */
 	regf_hdr->description = talloc_strdup(regf_hdr,
-					      "registry created by Samba 4");
+					      "Registry created by Samba 4");
 	W_ERROR_HAVE_NO_MEMORY(regf_hdr->description);
 	regf_hdr->chksum = 0;
 
 	regf->header = regf_hdr;
 
-	i = 0;
 	/* Create all hbin blocks */
 	regf->hbins = talloc_array(regf, struct hbin_block *, 1);
 	W_ERROR_HAVE_NO_MEMORY(regf->hbins);
 	regf->hbins[0] = NULL;
 
-	regf_hdr->data_offset = -1; /* FIXME */
-
 	nk.header = "nk";
 	nk.type = REG_SUB_KEY;
 	unix_to_nt_time(&nk.last_change, time(NULL));
@@ -1971,27 +1973,67 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
 	nk.num_values = 0;
 	nk.values_offset = -1;
 	memset(nk.unk3, 0, 5);
-	nk.clsname_offset = -1; /* FIXME: fill in */
+	nk.clsname_offset = -1;
 	nk.clsname_length = 0;
-	nk.key_name = "";
+	nk.sk_offset = 0x80;
+	nk.key_name = "SambaRootKey";
+
+	/*
+	 * It should be noted that changing the key_name to something shorter
+	 * creates a shorter nk block, which makes the position of the sk block
+	 * change. All Windows registries I've seen have the sk at 0x80. 
+	 * I therefore recommend that our regf files share that offset -- Wilco
+	 */
+
+	/* Create a security descriptor. */
+	sd = security_descriptor_dacl_create(regf,
+					 0,
+					 NULL, NULL,
+					 SID_NT_AUTHENTICATED_USERS,
+					 SEC_ACE_TYPE_ACCESS_ALLOWED,
+					 SEC_GENERIC_ALL,
+					 SEC_ACE_FLAG_OBJECT_INHERIT,
+					 NULL);
+	
+	/* Push the security descriptor to a blob */
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_struct_blob(&data, regf, NULL, 
+				     sd, (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
+		DEBUG(0, ("Unable to push security descriptor\n"));
+		return WERR_GENERAL_FAILURE;
+	}
 
-	nk.sk_offset = -1; /* FIXME: fill in */
+	ZERO_STRUCT(sk);
+	sk.header = "sk";


-- 
Samba Shared Repository


More information about the samba-cvs mailing list