summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-12-02 10:53:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:19 -0500
commitfc030c313f4ec93bceea460787484994b39af2dd (patch)
treebca6c0483d3d767a3da633b4bfc0f36acb4be4d9
parent9690500e57596dcf41888626cbb8d31cfea24926 (diff)
downloadsamba-fc030c313f4ec93bceea460787484994b39af2dd.tar.gz
samba-fc030c313f4ec93bceea460787484994b39af2dd.tar.bz2
samba-fc030c313f4ec93bceea460787484994b39af2dd.zip
r20006: Convert the registry shares to use the new API
(This used to be commit 66e889bbabde6dfd05df46937635a6d3e606cb27)
-rw-r--r--source3/smbd/service.c79
1 files changed, 31 insertions, 48 deletions
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 048c0f00b1..5779ad1be9 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -231,15 +231,15 @@ int add_home_service(const char *service, const char *username, const char *home
static int load_registry_service(const char *servicename)
{
- REGISTRY_KEY *key;
+ struct registry_key *key;
char *path;
WERROR err;
- uint32 i, num_values;
- char **value_names;
- struct registry_value **values = NULL;
+ uint32 i;
+ char *value_name;
+ struct registry_value *value;
- int res;
+ int res = -1;
if (!lp_registry_shares()) {
return -1;
@@ -249,65 +249,56 @@ static int load_registry_service(const char *servicename)
return -1;
}
- err = regkey_open_internal(NULL, &key, path, get_root_nt_token(),
- REG_KEY_READ);
+ err = reg_open_path(NULL, path, REG_KEY_READ, get_root_nt_token(),
+ &key);
SAFE_FREE(path);
if (!W_ERROR_IS_OK(err)) {
return -1;
}
- err = registry_fetch_values(NULL, key, &num_values, &value_names,
- &values);
-
- TALLOC_FREE(key);
-
- if (!W_ERROR_IS_OK(err)) {
- goto error;
- }
-
res = lp_add_service(servicename, -1);
if (res == -1) {
goto error;
}
- for (i=0; i<num_values; i++) {
- switch (values[i]->type) {
+ for (i=0;
+ W_ERROR_IS_OK(reg_enumvalue(key, key, i, &value_name, &value));
+ i++) {
+ switch (value->type) {
case REG_DWORD: {
- char *val;
- if (asprintf(&val, "%d", values[i]->v.dword) == -1) {
+ char *tmp;
+ if (asprintf(&tmp, "%d", value->v.dword) == -1) {
continue;
}
- lp_do_parameter(res, value_names[i], val);
- SAFE_FREE(val);
+ lp_do_parameter(res, value_name, tmp);
+ SAFE_FREE(tmp);
break;
}
case REG_SZ: {
- lp_do_parameter(res, value_names[i],
- values[i]->v.sz.str);
+ lp_do_parameter(res, value_name, value->v.sz.str);
break;
}
default:
/* Ignore all the rest */
break;
}
- }
- TALLOC_FREE(value_names);
- TALLOC_FREE(values);
- return res;
+ TALLOC_FREE(value_name);
+ TALLOC_FREE(value);
+ }
+ res = 0;
error:
- TALLOC_FREE(value_names);
- TALLOC_FREE(values);
- return -1;
+ TALLOC_FREE(key);
+ return res;
}
void load_registry_shares(void)
{
- REGISTRY_KEY *key;
- REGSUBKEY_CTR *keys;
+ struct registry_key *key;
+ char *name;
WERROR err;
int i;
@@ -315,26 +306,18 @@ void load_registry_shares(void)
return;
}
- if (!(keys = TALLOC_ZERO_P(NULL, REGSUBKEY_CTR))) {
- goto done;
- }
-
- err = regkey_open_internal(keys, &key, KEY_SMBCONF,
- get_root_nt_token(), REG_KEY_READ);
+ err = reg_open_path(NULL, KEY_SMBCONF, REG_KEY_READ,
+ get_root_nt_token(), &key);
if (!(W_ERROR_IS_OK(err))) {
- goto done;
- }
-
- if (fetch_reg_keys(key, keys) == -1) {
- goto done;
+ return;
}
- for (i=0; i<keys->num_subkeys; i++) {
- load_registry_service(keys->subkeys[i]);
+ for (i=0; W_ERROR_IS_OK(reg_enumkey(key, key, i, &name, NULL)); i++) {
+ load_registry_service(name);
+ TALLOC_FREE(name);
}
- done:
- TALLOC_FREE(keys);
+ TALLOC_FREE(key);
return;
}