Skip to content

Commit

Permalink
s3:auth: Pass mem_ctx to init_guest_session_info()
Browse files Browse the repository at this point in the history
Use a mem_ctx which gets freed if possible.

Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
cryptomilk authored and jrasamba committed Feb 20, 2018
1 parent b2aec11 commit 7f47cec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions source3/auth/auth_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion source3/auth/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source3/smbd/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source3/torture/vfstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7f47cec

Please sign in to comment.