diff options
author | Andreas Schneider <asn@samba.org> | 2013-11-18 14:58:04 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-11-21 15:00:44 -0800 |
commit | 6366ebb79bb72d9dcb12f8fe8d6e35611fcff150 (patch) | |
tree | ad74b0c98947a3b233d12e7612d22d0673df231a /source3/lib | |
parent | 4ea92841b72a7b701a7c0fadf63430a7d0a3fac8 (diff) | |
download | samba-6366ebb79bb72d9dcb12f8fe8d6e35611fcff150.tar.gz samba-6366ebb79bb72d9dcb12f8fe8d6e35611fcff150.tar.xz samba-6366ebb79bb72d9dcb12f8fe8d6e35611fcff150.zip |
s3-lib: Add grpname to talloc_sub_specified().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/substitute.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index a254bcaa7d..ca2ac7981f 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"); |