[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-1590-g01bda3a

Michael Adam obnox at samba.org
Mon Jan 21 08:27:00 GMT 2008


The branch, v3-2-test has been updated
       via  01bda3ab359fb3868c1dc849044f613bf2bc563e (commit)
       via  39d65d11f8eff0aff998d5bfed8480b0f00655bd (commit)
       via  4952417fca89f5d797c861cde9fe74050ae02e2f (commit)
       via  0005b88d74fca1ea1410c9911d504b0a636a0472 (commit)
       via  c3f695d3b14ee06fc5d517ca094236e885f9e707 (commit)
       via  aaf33ae5b8bfaefd2342c9ce6363577ce7c0c4f1 (commit)
       via  b85e5ee45075211dd3ab85ac79c2d856187d5e3e (commit)
       via  b3c2fb17a4226559788a47fee968ef19b7fbb6b2 (commit)
       via  cf485273f61e3dcd41ab7af756cc82f32131bf08 (commit)
       via  562c3eb37e2ff2b385203be9d556daf37df7d20e (commit)
       via  7453e78a8e63aaaff57c1779d6b7cf0ec8fc263f (commit)
      from  4a6dadc5178f4861e9c032321939db3b639734b5 (commit)

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


- Log -----------------------------------------------------------------
commit 01bda3ab359fb3868c1dc849044f613bf2bc563e
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:40:10 2008 +0100

    Rename lib/util_reg_smbconf.c to registry/reg_init_smbconf.c
    
    This actually is a counterpart to reg_init_full, in that is does
    open and initialize the registry too, but only registeres the backends
    necessary to access the SMBCONF key.
    
    Michael

commit 39d65d11f8eff0aff998d5bfed8480b0f00655bd
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:34:06 2008 +0100

    Move reg_frontend_hilvl.c to reg_dispatcher.c
    
    This is actually the dispatcher to the registered registry backends.
    
    Michael

commit 4952417fca89f5d797c861cde9fe74050ae02e2f
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:32:01 2008 +0100

    Extend/fix comments.
    
    Michael

commit 0005b88d74fca1ea1410c9911d504b0a636a0472
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:28:39 2008 +0100

    Extract regkey_open_internal() from reg_frontend.c to new reg_util_legacy.c
    
    reg_openpath should be used instead of this function (along with the
    reg_api interface). Last callers of this function are in services_db.c
    
    Michael

commit c3f695d3b14ee06fc5d517ca094236e885f9e707
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:16:40 2008 +0100

    Rename reg_db.c to reg_backend_db.c
    
    Michael

commit aaf33ae5b8bfaefd2342c9ce6363577ce7c0c4f1
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:14:10 2008 +0100

    Rename reg_shares.c to reg_backend_shares.c
    
    Michael

commit b85e5ee45075211dd3ab85ac79c2d856187d5e3e
Author: Michael Adam <obnox at samba.org>
Date:   Mon Jan 21 00:07:41 2008 +0100

    Rename reg_smbconf.c to reg_backend_smbconf.c
    
    Michael

commit b3c2fb17a4226559788a47fee968ef19b7fbb6b2
Author: Michael Adam <obnox at samba.org>
Date:   Sun Jan 20 23:59:06 2008 +0100

    Rename reg_printing.c to reg_backend_printing.c
    
    Start making naming of source files more systematic
    to facilitate understanding of the structures.
    
    Michael

commit cf485273f61e3dcd41ab7af756cc82f32131bf08
Author: Michael Adam <obnox at samba.org>
Date:   Sun Jan 20 23:48:28 2008 +0100

    Makefile.in: Group together registry related object variables.
    
    Michael

commit 562c3eb37e2ff2b385203be9d556daf37df7d20e
Author: Michael Adam <obnox at samba.org>
Date:   Sun Jan 20 23:39:16 2008 +0100

    Makefile.in: extract registry backend objects to common variable.
    
    Michael

commit 7453e78a8e63aaaff57c1779d6b7cf0ec8fc263f
Author: Michael Adam <obnox at samba.org>
Date:   Sun Jan 20 23:44:33 2008 +0100

    reg_eventlog.o and reg_perfcount.o are no longer neede for reg_smbconf.
    
    This is an effect of the removal of the dynamic registry overlay.
    This is the beginning of a restructuring of registry linkage in Makefile.in.
    
    Michael

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

Summary of changes:
 source/Makefile.in                     |   82 ++-
 source/lib/util_reg_smbconf.c          |   97 ---
 source/registry/reg_backend_db.c       |  949 ++++++++++++++++++++++++
 source/registry/reg_backend_printing.c | 1269 ++++++++++++++++++++++++++++++++
 source/registry/reg_backend_shares.c   |  164 ++++
 source/registry/reg_backend_smbconf.c  |  275 +++++++
 source/registry/reg_db.c               |  949 ------------------------
 source/registry/reg_dispatcher.c       |  235 ++++++
 source/registry/reg_frontend.c         |  119 ---
 source/registry/reg_frontend_hilvl.c   |  235 ------
 source/registry/reg_init_full.c        |  103 +++
 source/registry/reg_init_smbconf.c     |   97 +++
 source/registry/reg_printing.c         | 1269 --------------------------------
 source/registry/reg_shares.c           |  164 ----
 source/registry/reg_smbconf.c          |  275 -------
 source/registry/reg_util_legacy.c      |   47 ++
 16 files changed, 3185 insertions(+), 3144 deletions(-)
 delete mode 100644 source/lib/util_reg_smbconf.c
 create mode 100644 source/registry/reg_backend_db.c
 create mode 100644 source/registry/reg_backend_printing.c
 create mode 100644 source/registry/reg_backend_shares.c
 create mode 100644 source/registry/reg_backend_smbconf.c
 delete mode 100644 source/registry/reg_db.c
 create mode 100644 source/registry/reg_dispatcher.c
 delete mode 100644 source/registry/reg_frontend.c
 delete mode 100644 source/registry/reg_frontend_hilvl.c
 create mode 100644 source/registry/reg_init_full.c
 create mode 100644 source/registry/reg_init_smbconf.c
 delete mode 100644 source/registry/reg_printing.c
 delete mode 100644 source/registry/reg_shares.c
 delete mode 100644 source/registry/reg_smbconf.c
 create mode 100644 source/registry/reg_util_legacy.c


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index b32fc2f..c519ff8 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -411,20 +411,54 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \
 		   $(LIBNDR_GEN_OBJ) \
 		   $(RPCCLIENT_NDR_OBJ)
 
+#
+# registry-related objects
+#
+UTIL_REG_OBJ = lib/util_reg.o
+UTIL_REG_API_OBJ = lib/util_reg_api.o
+REG_INIT_SMBCONF_OBJ = registry/reg_init_smbconf.o
+
+REGFIO_OBJ = registry/regfio.o
+
 REGOBJS_OBJ = registry/reg_objects.o
 
-REGISTRY_OBJ = registry/reg_frontend.o registry/reg_cachehook.o registry/reg_printing.o \
-               registry/reg_db.o registry/reg_eventlog.o registry/reg_shares.o \
+REGISTRY_BACKENDS = registry/reg_backend_printing.o \
+		    registry/reg_backend_db.o \
+		    registry/reg_backend_smbconf.o \
+		    registry/reg_backend_shares.o \
+		    registry/reg_backend_netlogon_params.o \
+		    registry/reg_backend_prod_options.o \
+		    registry/reg_backend_tcpip_params.o \
+		    registry/reg_backend_hkpt_params.o \
+		    registry/reg_backend_current_version.o \
+		    registry/reg_backend_perflib.o
+
+
+REGISTRY_OBJ = registry/reg_init_full.o registry/reg_cachehook.o \
+               registry/reg_eventlog.o \
                registry/reg_util.o registry/reg_perfcount.o \
-	       registry/reg_smbconf.o registry/reg_api.o \
-	       registry/reg_frontend_hilvl.o \
-	       registry/reg_backend_netlogon_params.o \
-	       registry/reg_backend_prod_options.o \
-	       registry/reg_backend_tcpip_params.o \
-	       registry/reg_backend_hkpt_params.o \
-	       registry/reg_backend_current_version.o \
-	       registry/reg_backend_perflib.o \
-	       $(UTIL_REG_API_OBJ) $(UTIL_REG_SMBCONF_OBJ)
+	       registry/reg_util_legacy.o \
+	       registry/reg_api.o \
+	       registry/reg_dispatcher.o \
+	       $(REGISTRY_BACKENDS) \
+	       $(UTIL_REG_API_OBJ) \
+	       $(REG_INIT_SMBCONF_OBJ)
+
+# objects to be used when not all of the registry code should be
+# loaded but only the portion needed by reg_api, typically for
+# using smbconf (registry) - full access
+REG_API_OBJ = registry/reg_api.o \
+	      registry/reg_dispatcher.o \
+	      registry/reg_backend_smbconf.o \
+	      registry/reg_backend_db.o \
+	      registry/reg_util.o \
+	      \
+	      registry/reg_cachehook.o \
+	      \
+	      lib/util_nttoken.o \
+	      $(UTIL_REG_API_OBJ) \
+	      $(REG_INIT_SMBCONF_OBJ)
+
 
 RPC_LSA_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o librpc/gen_ndr/srv_lsa.o
 
@@ -433,8 +467,6 @@ RPC_NETLOG_OBJ = rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o
 RPC_SAMR_OBJ = rpc_server/srv_samr.o rpc_server/srv_samr_nt.o \
                rpc_server/srv_samr_util.o
 
-REGFIO_OBJ = registry/regfio.o
-
 RPC_INITSHUTDOWN_OBJ =  librpc/gen_ndr/srv_initshutdown.o rpc_server/srv_initshutdown_nt.o
 
 RPC_REG_OBJ =  rpc_server/srv_winreg_nt.o \
@@ -725,28 +757,6 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
              $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
 	     $(DISPLAY_SEC_OBJ) 
 
-UTIL_REG_OBJ = lib/util_reg.o
-UTIL_REG_API_OBJ = lib/util_reg_api.o
-UTIL_REG_SMBCONF_OBJ = lib/util_reg_smbconf.o
-
-# objects to be used when not all of the registry code should be
-# loaded but only the portion needed by reg_api, typically for
-# using smbconf (registry) - full access
-REG_API_OBJ = registry/reg_api.o \
-	      registry/reg_frontend_hilvl.o \
-	      registry/reg_smbconf.o \
-	      registry/reg_db.o \
-	      registry/reg_util.o \
-	      \
-	      registry/reg_cachehook.o \
-	      registry/reg_eventlog.o \
-	      registry/reg_perfcount.o \
-	      \
-	      lib/util_nttoken.o \
-	      $(UTIL_REG_API_OBJ) \
-	      $(UTIL_REG_SMBCONF_OBJ)
-
-
 LIBNETAPI_OBJ1 = lib/netapi/netapi.o \
 		 lib/netapi/joindomain.o \
 		 lib/netapi/serverinfo.o \
@@ -853,7 +863,7 @@ EVTLOGADM_OBJ	= $(EVTLOGADM_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(REGOBJS_OBJ)
 		$(ERRORMAP_OBJ) $(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(DOSERR_OBJ) \
 		$(SECRETS_OBJ) \
 	        registry/reg_eventlog.o rpc_server/srv_eventlog_lib.o registry/reg_util.o \
-		registry/reg_db.o
+		registry/reg_backend_db.o
 
 SHARESEC_OBJ0 = utils/sharesec.o
 SHARESEC_OBJ  = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(REGOBJS_OBJ) \
diff --git a/source/lib/util_reg_smbconf.c b/source/lib/util_reg_smbconf.c
deleted file mode 100644
index 6452b0b..0000000
--- a/source/lib/util_reg_smbconf.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Registry helper routines
- * Copyright (C) Michael Adam 2007
- * 
- * 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 the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- * 
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "includes.h"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_REGISTRY
-
-extern REGISTRY_OPS smbconf_reg_ops;
-
-/*
- * create a fake token just with enough rights to
- * locally access the registry:
- *
- * - builtin administrators sid
- * - disk operators privilege
- */
-NTSTATUS registry_create_admin_token(TALLOC_CTX *mem_ctx,
-				     NT_USER_TOKEN **ptoken)
-{
-	NTSTATUS status;
-	NT_USER_TOKEN *token = NULL;
-
-	if (ptoken == NULL) {
-		return NT_STATUS_INVALID_PARAMETER;
-	}
-
-	token = TALLOC_ZERO_P(mem_ctx, NT_USER_TOKEN);
-	if (token == NULL) {
-		DEBUG(1, ("talloc failed\n"));
-		status = NT_STATUS_NO_MEMORY;
-		goto done;
-	}
-	token->privileges = se_disk_operators;
-	status = add_sid_to_array(token, &global_sid_Builtin_Administrators,
-				  &token->user_sids, &token->num_sids);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(1, ("Error adding builtin administrators sid "
-			  "to fake token.\n"));
-		goto done;
-	}
-
-	*ptoken = token;
-
-done:
-	return status;
-}
-
-/*
- * init the smbconf portion of the registry.
- * for use in places where not the whole registry is needed,
- * e.g. utils/net_conf.c and loadparm.c
- */
-bool registry_init_regdb(void)
-{
-	bool ret = false;
-	int saved_errno = 0;
-	static REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops};
-
-	DEBUG(10, ("registry_init_regdb called\n"));
-
-	if (!regdb_init()) {
-		saved_errno = errno;
-		DEBUG(1, ("Can't open the registry"));
-		if (saved_errno) {
-			DEBUGADD(1, (": %s", strerror(saved_errno)));
-		}
-		DEBUGADD(1, (".\n"));
-		goto done;
-	}
-	reghook_cache_init();
-	if (!reghook_cache_add(&smbconf_reg_hook)) {
-		DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n"));
-		goto done;
-	}
-
-	ret = true;
-
-done:
-	return ret;
-}
diff --git a/source/registry/reg_backend_db.c b/source/registry/reg_backend_db.c
new file mode 100644
index 0000000..e162fb5
--- /dev/null
+++ b/source/registry/reg_backend_db.c
@@ -0,0 +1,949 @@
+/* 
+ *  Unix SMB/CIFS implementation.
+ *  Virtual Windows Registry Layer
+ *  Copyright (C) Gerald Carter                     2002-2005
+ *
+ *  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
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Implementation of internal registry database functions. */
+
+#include "includes.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_REGISTRY
+
+static struct tdb_wrap *tdb_reg = NULL;
+static int tdb_refcount;
+
+/* List the deepest path into the registry.  All part components will be created.*/
+
+/* If you want to have a part of the path controlled by the tdb and part by
+   a virtual registry db (e.g. printing), then you have to list the deepest path.
+   For example,"HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Print" 
+   allows the reg_db backend to handle everything up to 
+   "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion" and then we'll hook 
+   the reg_printing backend onto the last component of the path (see 
+   KEY_PRINTING_2K in include/rpc_reg.h)   --jerry */
+
+static const char *builtin_registry_paths[] = {
+	KEY_PRINTING_2K,
+	KEY_PRINTING_PORTS,
+	KEY_PRINTING,
+	KEY_SHARES,
+	KEY_EVENTLOG,
+	KEY_SMBCONF,
+	KEY_PERFLIB,
+	KEY_PERFLIB_009,
+	"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
+	KEY_PROD_OPTIONS,
+	"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\DefaultUserConfiguration",
+	KEY_TCPIP_PARAMS,
+	KEY_NETLOGON_PARAMS,
+	KEY_HKU,
+	KEY_HKCR,
+	KEY_HKPD,
+	KEY_HKPT,
+	 NULL };
+
+struct builtin_regkey_value {
+	const char *path;
+	const char *valuename;
+	uint32 type;
+	union {
+		const char *string;
+		uint32 dw_value;
+	} data;
+};
+
+static struct builtin_regkey_value builtin_registry_values[] = {
+	{ KEY_PRINTING_PORTS,
+		SAMBA_PRINTER_PORT_NAME, REG_SZ, { "" } },
+	{ KEY_PRINTING_2K,
+		"DefaultSpoolDirectory", REG_SZ, { "C:\\Windows\\System32\\Spool\\Printers" } },
+	{ KEY_EVENTLOG,
+		"DisplayName", REG_SZ, { "Event Log" } }, 
+	{ KEY_EVENTLOG,
+		"ErrorControl", REG_DWORD, { (char*)0x00000001 } },
+	{ NULL, NULL, 0, { NULL } }
+};
+
+/***********************************************************************
+ Open the registry data in the tdb
+ ***********************************************************************/
+
+static bool init_registry_data( void )
+{
+	char *path = NULL;
+	char *base = NULL;
+	char *remaining = NULL;
+	TALLOC_CTX *frame = NULL;
+	char *keyname;
+	char *subkeyname;
+	REGSUBKEY_CTR *subkeys;
+	REGVAL_CTR *values;
+	int i;
+	const char *p, *p2;
+	UNISTR2 data;
+
+	/*
+	 * There are potentially quite a few store operations which are all
+	 * indiviually wrapped in tdb transactions. Wrapping them in a single
+	 * transaction gives just a single transaction_commit() to actually do
+	 * its fsync()s. See tdb/common/transaction.c for info about nested
+	 * transaction behaviour.
+	 */
+
+	if ( tdb_transaction_start( tdb_reg->tdb ) == -1 ) {
+		DEBUG(0, ("init_registry_data: tdb_transaction_start "
+			  "failed\n"));
+		return false;
+	}
+
+	/* loop over all of the predefined paths and add each component */
+
+	for ( i=0; builtin_registry_paths[i] != NULL; i++ ) {
+
+		frame = talloc_stackframe();
+
+		DEBUG(6,("init_registry_data: Adding [%s]\n", builtin_registry_paths[i]));
+
+		path = talloc_strdup(talloc_tos(), builtin_registry_paths[i]);
+		base = talloc_strdup(talloc_tos(), "");
+		if (!path || !base) {
+			goto fail;
+		}
+		p = path;
+
+		while (next_token_talloc(talloc_tos(), &p, &keyname, "\\")) {
+
+			/* build up the registry path from the components */
+
+			if (*base) {
+				base = talloc_asprintf(talloc_tos(), "%s\\", base);
+				if (!base) {
+					goto fail;
+				}
+			}
+			base = talloc_asprintf_append(base, "%s", keyname);
+			if (!base) {
+				goto fail;
+			}
+
+			/* get the immediate subkeyname (if we have one ) */
+
+			subkeyname = talloc_strdup(talloc_tos(), "");
+			if (!subkeyname) {
+				goto fail;
+			}
+			if (*p) {
+				remaining = talloc_strdup(talloc_tos(), p);
+				if (!remaining) {
+					goto fail;
+				}
+				p2 = remaining;
+
+				if (!next_token_talloc(talloc_tos(), &p2,
+							&subkeyname, "\\")) {
+					subkeyname = talloc_strdup(talloc_tos(),p2);
+					if (!subkeyname) {
+						goto fail;
+					}
+				}
+			}
+
+			DEBUG(10,("init_registry_data: Storing key [%s] with subkey [%s]\n",
+				base, *subkeyname ? subkeyname : "NULL"));
+
+			/* we don't really care if the lookup succeeds or not since
+			   we are about to update the record.  We just want any
+			   subkeys already present */
+
+			if ( !(subkeys = TALLOC_ZERO_P(talloc_tos(), REGSUBKEY_CTR )) ) {
+				DEBUG(0,("talloc() failure!\n"));
+				goto fail;
+			}
+
+			regdb_fetch_keys(base, subkeys);
+			if (*subkeyname) {
+				regsubkey_ctr_addkey( subkeys, subkeyname);
+			}
+			if (!regdb_store_keys( base, subkeys)) {
+				goto fail;
+			}
+		}
+
+		TALLOC_FREE(frame);
+	}
+
+	/* loop over all of the predefined values and add each component */
+
+	for (i=0; builtin_registry_values[i].path != NULL; i++) {
+
+		if (!(values = TALLOC_ZERO_P(talloc_tos(), REGVAL_CTR))) {
+			goto fail;
+		}
+
+		regdb_fetch_values( builtin_registry_values[i].path, values);
+
+		/* preserve existing values across restarts.  Only add new ones */
+
+		if (!regval_ctr_key_exists(values, builtin_registry_values[i].valuename)) {
+			switch(builtin_registry_values[i].type) {
+			case REG_DWORD:
+				regval_ctr_addvalue( values,
+				                     builtin_registry_values[i].valuename,
+						     REG_DWORD,
+						     (char*)&builtin_registry_values[i].data.dw_value,
+						     sizeof(uint32) );
+				break;
+
+			case REG_SZ:
+				init_unistr2( &data, builtin_registry_values[i].data.string, UNI_STR_TERMINATE);
+				regval_ctr_addvalue( values,
+				                     builtin_registry_values[i].valuename,
+						     REG_SZ,
+						     (char*)data.buffer,
+						     data.uni_str_len*sizeof(uint16) );
+				break;
+
+			default:
+				DEBUG(0,("init_registry_data: invalid value type in builtin_registry_values [%d]\n",
+					builtin_registry_values[i].type));
+			}
+			regdb_store_values( builtin_registry_values[i].path, values );
+		}
+		TALLOC_FREE( values );
+	}
+
+	TALLOC_FREE(frame);
+
+	if (tdb_transaction_commit( tdb_reg->tdb ) == -1) {
+		DEBUG(0, ("init_registry_data: Could not commit "
+			  "transaction\n"));
+		return false;
+	}
+
+	return true;
+
+ fail:
+
+	TALLOC_FREE(frame);
+
+	if (tdb_transaction_cancel( tdb_reg->tdb ) == -1) {
+		smb_panic("init_registry_data: tdb_transaction_cancel "
+			  "failed\n");
+	}
+
+	return false;
+}
+
+/***********************************************************************
+ Open the registry database
+ ***********************************************************************/
+ 
+bool regdb_init( void )
+{
+	const char *vstring = "INFO/version";
+	uint32 vers_id;
+
+	if ( tdb_reg )
+		return true;
+
+	if ( !(tdb_reg = tdb_wrap_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600)) )
+	{
+		tdb_reg = tdb_wrap_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
+		if ( !tdb_reg ) {
+			DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
+				state_path("registry.tdb"), strerror(errno) ));
+			return false;
+		}
+		
+		DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
+	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list