summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;