From 7f47cec2343ca7658460cc14fa613fdd2611677a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 13 Feb 2018 12:09:12 +0100 Subject: [PATCH] s3:auth: Pass mem_ctx to init_guest_session_info() Use a mem_ctx which gets freed if possible. Signed-off-by: Andreas Schneider Reviewed-by: Jeremy Allison --- source3/auth/auth_util.c | 9 +++++++-- source3/auth/proto.h | 2 +- source3/smbd/server.c | 2 +- source3/torture/vfstest.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 377d56d0488..c81432d277d 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -1136,12 +1136,17 @@ static struct auth_session_info *guest_info = NULL; static struct auth_serversupplied_info *guest_server_info = NULL; -bool init_guest_info(void) +bool init_guest_session_info(TALLOC_CTX *mem_ctx) { + NTSTATUS status; + if (guest_info != NULL) return true; - return NT_STATUS_IS_OK(make_new_session_info_guest(NULL, &guest_info, &guest_server_info)); + status = make_new_session_info_guest(mem_ctx, + &guest_info, + &guest_server_info); + return NT_STATUS_IS_OK(status); } NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx, diff --git a/source3/auth/proto.h b/source3/auth/proto.h index ca851c21d4b..6d6f789d8b6 100644 --- a/source3/auth/proto.h +++ b/source3/auth/proto.h @@ -240,7 +240,7 @@ NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx, struct auth_session_info **session_info); struct auth_session_info *copy_session_info(TALLOC_CTX *mem_ctx, const struct auth_session_info *src); -bool init_guest_info(void); +bool init_guest_session_info(TALLOC_CTX *mem_ctx); NTSTATUS init_system_session_info(void); bool session_info_set_session_key(struct auth_session_info *info, DATA_BLOB session_key); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 99baf9d519d..d80ea7311bd 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1991,7 +1991,7 @@ extern void build_options(bool screen); return -1; } - if (!init_guest_info()) { + if (!init_guest_session_info(NULL)) { DEBUG(0,("ERROR: failed to setup guest info.\n")); return -1; } diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c index f156def4647..17c19012384 100644 --- a/source3/torture/vfstest.c +++ b/source3/torture/vfstest.c @@ -525,7 +525,7 @@ int main(int argc, const char *argv[]) /* some basic initialization stuff */ sec_init(); - init_guest_info(); + init_guest_session_info(frame); locking_init(); vfs = talloc_zero(NULL, struct vfs_state); if (vfs == NULL) { -- 2.11.4.GIT