]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:param: split out loadparm_s3_global_substitution from lp_string()
authorStefan Metzmacher <metze@samba.org>
Tue, 15 Oct 2019 10:07:17 +0000 (12:07 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 27 Nov 2019 10:25:31 +0000 (10:25 +0000)
The idea is to get rid of the global state that's
currently used for the substitution in lp_string().

In the end all callers need to pass an explicit
const struct loadparm_substitution *sub_ctx,
which contains all relevant information
for the substitution. At that point lp_string() can be removed.

For now we provide loadparm_s3_global_substitution()
for callers to keep the current bahavior unchanged.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/proto.h
source3/param/loadparm.c

index c097ab19d14c62aa3dbceb9e88cb5e6ebb2db9e5..15ed176d11c8ba98e50dc4cba9694924623223a9 100644 (file)
@@ -731,6 +731,8 @@ NTSTATUS trust_pw_change(struct netlogon_creds_cli_context *context,
 
 /* The following definitions come from param/loadparm.c  */
 
+const struct loadparm_substitution *loadparm_s3_global_substitution(void);
+
 #include "source3/param/param_proto.h"
 
 char *lp_servicename(TALLOC_CTX *ctx, int);
index 9a1c6107520cbfb6a17d17299d726a09c1d8ffc0..15abf281dd7d7a0d94cd866e94edbbcab7f98753 100644 (file)
@@ -53,6 +53,7 @@
  *
  */
 
+#define LOADPARM_SUBSTITUTION_INTERNALS 1
 #include "includes.h"
 #include "system/filesys.h"
 #include "util_tdb.h"
@@ -991,7 +992,11 @@ static struct loadparm_context *setup_lp_context(TALLOC_CTX *mem_ctx)
  callers without affecting the source string.
 ********************************************************************/
 
-char *lp_string(TALLOC_CTX *mem_ctx, const char *s)
+static char *loadparm_s3_global_substitution_fn(
+                       TALLOC_CTX *mem_ctx,
+                       const struct loadparm_substitution *lp_sub,
+                       const char *s,
+                       void *private_data)
 {
        char *ret;
 
@@ -1023,6 +1028,20 @@ char *lp_string(TALLOC_CTX *mem_ctx, const char *s)
        return ret;
 }
 
+static const struct loadparm_substitution s3_global_substitution = {
+       .substituted_string_fn = loadparm_s3_global_substitution_fn,
+};
+
+const struct loadparm_substitution *loadparm_s3_global_substitution(void)
+{
+       return &s3_global_substitution;
+}
+
+char *lp_string(TALLOC_CTX *ctx, const char *s)
+{
+       return lpcfg_substituted_string(ctx, &s3_global_substitution, s);
+}
+
 /*
    In this section all the functions that are used to access the
    parameters from the rest of the program are defined