From 6366ebb79bb72d9dcb12f8fe8d6e35611fcff150 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 18 Nov 2013 14:58:04 +0100 Subject: s3-lib: Add grpname to talloc_sub_specified(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191 Signed-off-by: Andreas Schneider Reviewed-by: Jeremy Allison --- source3/lib/substitute.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'source3/lib/substitute.c') diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index a254bcaa7d5..ca2ac7981fa 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -613,6 +613,7 @@ done: char *talloc_sub_specified(TALLOC_CTX *mem_ctx, const char *input_string, const char *username, + const char *grpname, const char *domain, uid_t uid, gid_t gid) @@ -648,9 +649,18 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, break; case 'G' : if (gid != -1) { - a_string = talloc_string_sub( - tmp_ctx, a_string, "%G", - gidtoname(gid)); + const char *name; + + if (grpname != NULL) { + name = grpname; + } else { + name = gidtoname(gid); + } + + a_string = talloc_string_sub(tmp_ctx, + a_string, + "%G", + name); } else { a_string = talloc_string_sub( tmp_ctx, a_string, @@ -659,9 +669,18 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, break; case 'g' : if (gid != -1) { - a_string = talloc_string_sub( - tmp_ctx, a_string, "%g", - gidtoname(gid)); + const char *name; + + if (grpname != NULL) { + name = grpname; + } else { + name = gidtoname(gid); + } + + a_string = talloc_string_sub(tmp_ctx, + a_string, + "%g", + name); } else { a_string = talloc_string_sub( tmp_ctx, a_string, "%g", "NO_GROUP"); -- cgit v1.2.1