summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/libnet/libnet_conf.c24
-rw-r--r--source3/utils/net_conf.c22
2 files changed, 34 insertions, 12 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index 69a105f8f5..121ec35468 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -271,6 +271,30 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx,
return werr;
}
+WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx,
+ const char *service,
+ const char *param,
+ struct registry_value **value)
+{
+ WERROR werr;
+ struct registry_key *key = NULL;
+
+ 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_queryvalue(mem_ctx, key, param, value);
+
+ return werr;
+}
+
WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx,
const char *service,
const char *param)
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 673d373177..f3f2321643 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -869,7 +869,6 @@ static int net_conf_getparm(int argc, const char **argv)
{
int ret = -1;
WERROR werr = WERR_OK;
- struct registry_key *key = NULL;
char *service = NULL;
char *param = NULL;
struct registry_value *value = NULL;
@@ -884,21 +883,20 @@ static int net_conf_getparm(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_getparm(ctx, service, param, &value);
+
+ if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
- "ERROR: given service '%s' does not exist.\n",
+ "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)) {
+ } 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_queryvalue(ctx, key, param, &value);
- if (!W_ERROR_IS_OK(werr)) {
- d_fprintf(stderr, "Error querying value '%s': %s.\n",
+ } else if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, "Error getting value '%s': %s.\n",
param, dos_errstr(werr));
goto done;
}