summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-12-23 02:55:25 +0100
committerMichael Adam <obnox@samba.org>2007-12-23 04:10:31 +0100
commitb04708866f146ada8a7cc353347244df54821fbf (patch)
tree993ad031df8f302c7c6d9f77cf45ca68a6bd8ad2 /source3
parentec3e8587ecdef8e4a52d4c37ac379d9e414b861b (diff)
downloadsamba-b04708866f146ada8a7cc353347244df54821fbf.tar.gz
samba-b04708866f146ada8a7cc353347244df54821fbf.tar.bz2
samba-b04708866f146ada8a7cc353347244df54821fbf.zip
Move logic of net_smbconf_delparm() to libnet/libnet_conf.c
Logic in new function libnet_smbconf_delparm(). Michael (This used to be commit 0cff79e3552e91ba0b6bc054802d28afcf4e8da4)
Diffstat (limited to 'source3')
-rw-r--r--source3/libnet/libnet_conf.c25
-rw-r--r--source3/utils/net_conf.c18
2 files changed, 29 insertions, 14 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index 9f64e7fc0d..960ee80dbc 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -194,7 +194,7 @@ WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx,
return do_modify_val_config(key, param, val);
}
-bool libnet_smbconf_value_exists(TALLOC_CTX *ctx,
+static bool libnet_smbconf_value_exists(TALLOC_CTX *ctx,
struct registry_key *key,
const char *param)
{
@@ -211,3 +211,26 @@ bool libnet_smbconf_value_exists(TALLOC_CTX *ctx,
return ret;
}
+WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx,
+ const char *service,
+ const char *param)
+{
+ struct registry_key *key = NULL;
+ WERROR werr = WERR_OK;
+
+ if (!libnet_smbconf_key_exists(mem_ctx, service)) {
+ return WERR_NO_SUCH_SERVICE;
+ }
+
+ werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key);
+ W_ERROR_NOT_OK_RETURN(werr);
+
+ if (!libnet_smbconf_value_exists(mem_ctx, key, param)) {
+ return WERR_INVALID_PARAM;
+ }
+
+ werr = reg_deletevalue(key, param);
+ W_ERROR_NOT_OK_RETURN(werr);
+
+ return WERR_OK;
+}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index c4707e4248..8d0b4b9bbe 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -995,7 +995,6 @@ static int net_conf_delparm(int argc, const char **argv)
{
int ret = -1;
WERROR werr = WERR_OK;
- struct registry_key *key = NULL;
char *service = NULL;
char *param = NULL;
TALLOC_CTX *ctx;
@@ -1009,26 +1008,19 @@ static int net_conf_delparm(int argc, const char **argv)
service = strdup_lower(argv[0]);
param = strdup_lower(argv[1]);
- if (!libnet_smbconf_key_exists(ctx, service)) {
+ werr = libnet_smbconf_delparm(ctx, service, param);
+
+ if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
"Error: given service '%s' does not exist.\n",
service);
goto done;
- }
-
- werr = libnet_smbconf_open_path(ctx, service, REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
-
- if (!libnet_smbconf_value_exists(ctx, key, param)) {
+ } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
d_fprintf(stderr,
"Error: given parameter '%s' is not set.\n",
param);
goto done;
- }
- werr = reg_deletevalue(key, param);
- if (!W_ERROR_IS_OK(werr)) {
+ } else if (!W_ERROR_IS_OK(werr)) {
d_fprintf(stderr, "Error deleting value '%s': %s.\n",
param, dos_errstr(werr));
goto done;