summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-03-20 10:43:17 +0100
committerMichael Adam <obnox@samba.org>2008-03-21 02:25:55 +0100
commit1e8d72aec9411c99cd88ba48c169d7c7f4187db6 (patch)
tree2f6b1c37fda82a5f34af51d0fb54ca9e246d7c97 /source3/lib
parent7b53c84fe1c8ec0cb5e1d7a977eca6197a4c36c6 (diff)
downloadsamba-1e8d72aec9411c99cd88ba48c169d7c7f4187db6.tar.gz
samba-1e8d72aec9411c99cd88ba48c169d7c7f4187db6.tar.bz2
samba-1e8d72aec9411c99cd88ba48c169d7c7f4187db6.zip
libsmbconf: refactor autocreation of [global] into a helper function.
Michael (This used to be commit aeaf66c064de58c6f19d5a9d226843dedb552011)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/smbconf/smbconf.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c
index a5059c9eb5..dd044eef81 100644
--- a/source3/lib/smbconf/smbconf.c
+++ b/source3/lib/smbconf/smbconf.c
@@ -432,6 +432,14 @@ static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
csn->csn = (uint64_t)regdb_get_seqnum();
}
+static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
+{
+ if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
+ return smbconf_create_share(ctx, GLOBAL_NAME);
+ }
+ return WERR_OK;
+}
+
/**********************************************************************
*
* The actual net conf api functions, that are exported.
@@ -844,15 +852,11 @@ WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
{
WERROR werr;
- if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
- werr = smbconf_create_share(ctx, GLOBAL_NAME);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
+ werr = smbconf_global_check(ctx);
+ if (W_ERROR_IS_OK(werr)) {
+ werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
}
- werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
-done:
return werr;
}
@@ -919,15 +923,12 @@ WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
{
WERROR werr;
- if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
- werr = smbconf_create_share(ctx, GLOBAL_NAME);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
+ werr = smbconf_global_check(ctx);
+ if (W_ERROR_IS_OK(werr)) {
+ werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param,
+ valstr);
}
- werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, valstr);
-done:
return werr;
}
@@ -973,14 +974,10 @@ WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
{
WERROR werr;
- if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
- werr = smbconf_create_share(ctx, GLOBAL_NAME);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
+ werr = smbconf_global_check(ctx);
+ if (W_ERROR_IS_OK(werr)) {
+ werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
}
- werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
-done:
return werr;
}