From: Stefan Metzmacher Date: Tue, 15 Oct 2019 10:07:17 +0000 (+0200) Subject: s3:param: split out loadparm_s3_global_substitution from lp_string() X-Git-Tag: ldb-2.1.0~597 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=063c4b25b1529987eb2e59ac53cd0ad23a8f5669;p=thirdparty%2Fsamba.git s3:param: split out loadparm_s3_global_substitution from lp_string() 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/include/proto.h b/source3/include/proto.h index c097ab19d14..15ed176d11c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 9a1c6107520..15abf281dd7 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -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