From: Stefan Metzmacher Date: Tue, 15 Oct 2019 10:29:08 +0000 (+0200) Subject: s3:param: split out lp_parm_substituted_string() X-Git-Tag: ldb-2.1.0~596 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=236857b43453a2460d508fb4a2d7915a5055d195;p=thirdparty%2Fsamba.git s3:param: split out lp_parm_substituted_string() Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 15ed176d11c..93467167189 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -733,6 +733,13 @@ NTSTATUS trust_pw_change(struct netlogon_creds_cli_context *context, const struct loadparm_substitution *loadparm_s3_global_substitution(void); +char *lp_parm_substituted_string(TALLOC_CTX *mem_ctx, + const struct loadparm_substitution *lp_sub, + int snum, + const char *type, + const char *option, + const char *def); + #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 15abf281dd7..d7421d38fd6 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1232,19 +1232,40 @@ static int lp_enum(const char *s,const struct enum_list *_enum) /* Return parametric option from a given service. Type is a part of option before ':' */ /* Parametric option has following syntax: 'Type: option = value' */ -char *lp_parm_talloc_string(TALLOC_CTX *ctx, int snum, const char *type, const char *option, const char *def) +char *lp_parm_substituted_string(TALLOC_CTX *mem_ctx, + const struct loadparm_substitution *lp_sub, + int snum, + const char *type, + const char *option, + const char *def) { struct parmlist_entry *data = get_parametrics(snum, type, option); + SMB_ASSERT(lp_sub != NULL); + if (data == NULL||data->value==NULL) { if (def) { - return lp_string(ctx, def); + return lpcfg_substituted_string(mem_ctx, lp_sub, def); } else { return NULL; } } - return lp_string(ctx, data->value); + return lpcfg_substituted_string(mem_ctx, lp_sub, data->value); +} + +char *lp_parm_talloc_string(TALLOC_CTX *mem_ctx, + int snum, + const char *type, + const char *option, + const char *def) +{ + return lp_parm_substituted_string(mem_ctx, + &s3_global_substitution, + snum, + type, + option, + def); } /* Return parametric option from a given service. Type is a part of option before ':' */