s3:smbd/service: switch load_registry_service/shares to use loadparm routines
authorMichael Adam <obnox@samba.org>
Tue, 28 Apr 2009 23:49:53 +0000 (01:49 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 29 Apr 2009 00:20:19 +0000 (02:20 +0200)
instead of reading the registry directly with tdb and activating the
configure options by hand.

This eliminates the need for repeating checks done in loadparm.
For instance it disables registry shares without path in the server
as is the case with text based shares.

Michael

source3/include/proto.h
source3/param/loadparm.c
source3/smbd/service.c

index 6dd9c7e7e80408199633b366bf9167869ad1dfe4..2eb838fd2a080900572f0da2e11776a0d6756250 100644 (file)
@@ -4080,6 +4080,7 @@ bool lp_invert_boolean(const char *str, const char **inverse_str);
 bool lp_canonicalize_boolean(const char *str, const char**canon_str);
 bool service_ok(int iService);
 bool process_registry_service(const char *service_name);
+bool process_registry_shares(void);
 bool lp_config_backend_is_registry(void);
 bool lp_config_backend_is_file(void);
 bool lp_file_list_changed(void);
index 380b9e1b8c8ed4603fa19780afc2089331c51ecb..7b794020a1d26e0ccfca2c362d71583a6dc972a7 100644 (file)
@@ -6883,7 +6883,7 @@ static bool process_registry_globals(void)
        return process_registry_service(GLOBAL_NAME);
 }
 
-static bool process_registry_shares(void)
+bool process_registry_shares(void)
 {
        WERROR werr;
        uint32_t count;
index e33f04d971bfee5c8ab498a58e7dbce46b19db53..c66a4d3f8c9fec0f9b131fddeda7dd4d1ad9b9d3 100644 (file)
@@ -220,16 +220,6 @@ bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir)
 
 static int load_registry_service(const char *servicename)
 {
-       struct registry_key *key;
-       char *path;
-       WERROR err;
-
-       uint32 i;
-       char *value_name;
-       struct registry_value *value;
-
-       int res = -1;
-
        if (!lp_registry_shares()) {
                return -1;
        }
@@ -242,79 +232,22 @@ static int load_registry_service(const char *servicename)
                return -2;
        }
 
-       if (asprintf(&path, "%s\\%s", KEY_SMBCONF, servicename) == -1) {
-               return -1;
-       }
-
-       err = reg_open_path(NULL, path, REG_KEY_READ, get_root_nt_token(),
-                           &key);
-       SAFE_FREE(path);
-
-       if (!W_ERROR_IS_OK(err)) {
+       if (!process_registry_service(servicename)) {
                return -1;
        }
 
-       res = lp_add_service(servicename, -1);
-       if (res == -1) {
-               goto error;
-       }
-
-       for (i=0;
-            W_ERROR_IS_OK(reg_enumvalue(key, key, i, &value_name, &value));
-            i++) {
-               switch (value->type) {
-               case REG_DWORD: { 
-                       char *tmp;
-                       if (asprintf(&tmp, "%d", value->v.dword) == -1) {
-                               continue;
-                       }
-                       lp_do_parameter(res, value_name, tmp);
-                       SAFE_FREE(tmp);
-                       break;
-               }
-               case REG_SZ: {
-                       lp_do_parameter(res, value_name, value->v.sz.str);
-                       break;
-               }
-               default:
-                       /* Ignore all the rest */
-                       break;
-               }
-
-               TALLOC_FREE(value_name);
-               TALLOC_FREE(value);
-       }
-
- error:
-
-       TALLOC_FREE(key);
-       return res;
+       return lp_servicenumber(servicename);
 }
 
 void load_registry_shares(void)
 {
-       struct registry_key *key;
-       char *name;
-       WERROR err;
-       int i;
-
        DEBUG(8, ("load_registry_shares()\n"));
        if (!lp_registry_shares()) {
                return;
        }
 
-       err = reg_open_path(NULL, KEY_SMBCONF, REG_KEY_READ,
-                           get_root_nt_token(), &key);
-       if (!(W_ERROR_IS_OK(err))) {
-               return;
-       }
-
-       for (i=0; W_ERROR_IS_OK(reg_enumkey(key, key, i, &name, NULL)); i++) {
-               load_registry_service(name);
-               TALLOC_FREE(name);
-       }
+       process_registry_shares();
 
-       TALLOC_FREE(key);
        return;
 }