From 41ab92b62fbf029374b89f9d0ddf7578981f37cf Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 31 Oct 2019 11:57:39 +0100 Subject: s3:lib: factor out talloc_sub_advanced() from talloc_sub_full() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- source3/include/proto.h | 4 ++++ source3/lib/substitute.c | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index e453669b433..332a4132424 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -180,6 +180,10 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, const char *domain, uid_t uid, gid_t gid); +char *talloc_sub_advanced(TALLOC_CTX *mem_ctx, + const char *servicename, const char *user, + const char *connectpath, gid_t gid, + const char *str); char *talloc_sub_full(TALLOC_CTX *mem_ctx, const char *servicename, const char *user, const char *connectpath, gid_t gid, diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index e5cd0f28804..f3f2e1bc0e1 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -790,21 +790,19 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, /**************************************************************************** ****************************************************************************/ -char *talloc_sub_full(TALLOC_CTX *ctx, +char *talloc_sub_advanced(TALLOC_CTX *ctx, const char *servicename, const char *user, const char *connectpath, gid_t gid, - const char *smb_name, - const char *domain_name, const char *str) { - char *a_string, *ret_string; + char *a_string; char *b, *p, *s; a_string = talloc_strdup(talloc_tos(), str); if (a_string == NULL) { - DBG_ERR("Out of memory!\n"); + DEBUG(0, ("talloc_sub_advanced_only: Out of memory!\n")); return NULL; } @@ -858,6 +856,26 @@ char *talloc_sub_full(TALLOC_CTX *ctx, } } + return a_string; +} + +char *talloc_sub_full(TALLOC_CTX *ctx, + const char *servicename, + const char *user, + const char *connectpath, + gid_t gid, + const char *smb_name, + const char *domain_name, + const char *str) +{ + char *a_string, *ret_string; + + a_string = talloc_sub_advanced(ctx, servicename, user, connectpath, + gid, str); + if (a_string == NULL) { + return NULL; + } + ret_string = talloc_sub_basic(ctx, smb_name, domain_name, a_string); TALLOC_FREE(a_string); return ret_string; -- cgit v1.2.1