summaryrefslogtreecommitdiff
path: root/source3/auth/auth_util.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-12-18 18:06:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:53 -0500
commit28fb5b6f97c17af58ae99be98219de70ee95baba (patch)
tree0b174e5ad07aa1a33dd73bb986e00a9386043b09 /source3/auth/auth_util.c
parent0a585102d656b267af723a5bdd258e83f532c3a6 (diff)
downloadsamba-28fb5b6f97c17af58ae99be98219de70ee95baba.tar.gz
samba-28fb5b6f97c17af58ae99be98219de70ee95baba.tar.bz2
samba-28fb5b6f97c17af58ae99be98219de70ee95baba.zip
r12313: Introduce yet another copy of the string_sub function:
talloc_string_sub. Someone with time on his hands could convert all the callers of all_string_sub to this. realloc_string_sub is *only* called from within substitute.c, it could be moved there I think. Volker (This used to be commit be6c9012da174d5d5116e5172a53bbe6486d6c38)
Diffstat (limited to 'source3/auth/auth_util.c')
-rw-r--r--source3/auth/auth_util.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 497f16adf2..eb15fff7c8 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -591,33 +591,36 @@ static NTSTATUS create_nt_user_token(const DOM_SID *user_sid, const DOM_SID *gro
(strlen(lp_log_nt_token_command()) > 0)) {
TALLOC_CTX *mem_ctx;
char *command;
- fstring sidstr;
- char *user_sidstr, *group_sidstr;
+ char *group_sidstr;
mem_ctx = talloc_init("setnttoken");
if (mem_ctx == NULL)
return NT_STATUS_NO_MEMORY;
- sid_to_string(sidstr, &ptoken->user_sids[0]);
- user_sidstr = talloc_strdup(mem_ctx, sidstr);
-
group_sidstr = talloc_strdup(mem_ctx, "");
for (i=1; i<ptoken->num_sids; i++) {
- sid_to_string(sidstr, &ptoken->user_sids[i]);
- group_sidstr = talloc_asprintf(mem_ctx, "%s %s",
- group_sidstr, sidstr);
+ group_sidstr = talloc_asprintf(
+ mem_ctx, "%s %s", group_sidstr,
+ sid_string_static(&ptoken->user_sids[i]));
+ }
+
+ command = talloc_string_sub(
+ mem_ctx, lp_log_nt_token_command(),
+ "%s", sid_string_static(&ptoken->user_sids[0]));
+ command = talloc_string_sub(
+ mem_ctx, command, "%t", group_sidstr);
+
+ if (command == NULL) {
+ talloc_destroy(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
}
- command = SMB_STRDUP(lp_log_nt_token_command());
- command = realloc_string_sub(command, "%s", user_sidstr);
- command = realloc_string_sub(command, "%t", group_sidstr);
DEBUG(8, ("running command: [%s]\n", command));
if (smbrun(command, NULL) != 0) {
DEBUG(0, ("Could not log NT token\n"));
nt_status = NT_STATUS_ACCESS_DENIED;
}
talloc_destroy(mem_ctx);
- SAFE_FREE(command);
}
*token = ptoken;