]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
registry: change regdb_init() to return WERROR instead of bool.
authorMichael Adam <obnox@samba.org>
Sun, 13 Apr 2008 10:41:34 +0000 (12:41 +0200)
committerMichael Adam <obnox@samba.org>
Sun, 13 Apr 2008 13:33:47 +0000 (15:33 +0200)
Michael

source/registry/reg_backend_db.c
source/registry/reg_init_basic.c
source/registry/reg_init_full.c
source/registry/reg_init_smbconf.c

index fd442d6327244f61ba25e68ed7f5512822680225..e30d2697216c600043768535dd4c8d791d22bdd6 100644 (file)
@@ -318,16 +318,17 @@ bool init_registry_data(void)
  Open the registry database
  ***********************************************************************/
  
-bool regdb_init(void)
+WERROR regdb_init(void)
 {
        const char *vstring = "INFO/version";
        uint32 vers_id;
+       WERROR werr;
 
        if (regdb) {
                DEBUG(10, ("regdb_init: incrementing refcount (%d)\n",
                          regdb_refcount));
                regdb_refcount++;
-               return true;
+               return WERR_OK;
        }
 
        regdb = db_open_trans(NULL, state_path("registry.tdb"), 0,
@@ -336,9 +337,10 @@ bool regdb_init(void)
                regdb = db_open_trans(NULL, state_path("registry.tdb"), 0,
                                      REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
                if (!regdb) {
+                       werr = ntstatus_to_werror(map_nt_error_from_unix(errno));
                        DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
                                state_path("registry.tdb"), strerror(errno) ));
-                       return false;
+                       return werr;
                }
                
                DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
@@ -357,14 +359,14 @@ bool regdb_init(void)
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0, ("regdb_init: error storing %s = %d: %s\n",
                                  vstring, REGVER_V1, nt_errstr(status)));
-                       return false;
+                       return ntstatus_to_werror(status);
                } else {
                        DEBUG(10, ("regdb_init: stored %s = %d\n",
                                  vstring, REGVER_V1));
                }
        }
 
-       return true;
+       return WERR_OK;
 }
 
 /***********************************************************************
index 13f3c933835c2c0a0de151ace0ea9c5583e681ea..9098bc4aec273cef19a71b7b66827aacba58832f 100644 (file)
 
 bool registry_init_basic(void)
 {
-       int saved_errno = 0;
+       WERROR werr;
 
        DEBUG(10, ("registry_init_basic 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"));
+       werr = regdb_init();
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, ("Can't open the registry: %s\n", dos_errstr(werr)));
                return false;
        }
        regdb_close();
index f171949e38df9492481357b70de85438c9dd7b5c..e9273a044cbe93ab4d10c1f7852635465eb550d3 100644 (file)
@@ -65,11 +65,13 @@ REGISTRY_HOOK reg_hooks[] = {
 bool init_registry( void )
 {
        int i;
+       WERROR werr;
        bool ret = false;
 
-       if ( !regdb_init() ) {
+       werr = regdb_init();
+       if (!W_ERROR_IS_OK(werr)) {
                DEBUG(0, ("init_registry: failed to initialize the registry "
-                         "tdb!\n"));
+                         "(%s)\n", dos_errstr(werr)));
                goto fail;
        }
 
index ff9cde749ea3a7846598dc66248251559c53ca78..8d2fe53b53c65716109fdddf69b79259a21754fd 100644 (file)
@@ -69,8 +69,8 @@ done:
  */
 bool registry_init_smbconf(const char *keyname)
 {
+       WERROR werr;
        bool ret = false;
-       int saved_errno = 0;
 
        DEBUG(10, ("registry_init_smbconf called\n"));
 
@@ -80,13 +80,9 @@ bool registry_init_smbconf(const char *keyname)
                keyname = KEY_SMBCONF;
        }
 
-       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"));
+       werr = regdb_init();
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, ("Can't open the registry: %s\n", dos_errstr(werr)));
                goto done;
        }
        if (!init_registry_key(keyname)) {