diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-07-18 11:40:36 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-07-20 09:17:12 +1000 |
commit | 86f2a197dfd61fbf25b170080a0796d2f77f0af8 (patch) | |
tree | fd004ae76bfe9c246f607638d89d7f226f561efa /source3 | |
parent | 4363b71f62b136d26b8e1c46ec90b4652751ccac (diff) | |
download | samba-86f2a197dfd61fbf25b170080a0796d2f77f0af8.tar.gz samba-86f2a197dfd61fbf25b170080a0796d2f77f0af8.tar.bz2 samba-86f2a197dfd61fbf25b170080a0796d2f77f0af8.zip |
s3-auth Avoid redundant copies in create_local_token()
These values were not read before being overwritten again.
Andrew Bartlett
Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/auth/auth_util.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index e27153e445..c227a1cf83 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -475,7 +475,7 @@ NTSTATUS create_local_token(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - session_info->unix_token = talloc(session_info, struct security_unix_token); + session_info->unix_token = talloc_zero(session_info, struct security_unix_token); if (!session_info->unix_token) { TALLOC_FREE(session_info); return NT_STATUS_NO_MEMORY; @@ -483,25 +483,6 @@ NTSTATUS create_local_token(TALLOC_CTX *mem_ctx, session_info->unix_token->uid = server_info->utok.uid; session_info->unix_token->gid = server_info->utok.gid; - session_info->unix_token->ngroups = server_info->utok.ngroups; - if (server_info->utok.ngroups != 0) { - session_info->unix_token->groups = (gid_t *)talloc_memdup( - session_info->unix_token, server_info->utok.groups, - sizeof(gid_t)*session_info->unix_token->ngroups); - } else { - session_info->unix_token->groups = NULL; - } - - if (server_info->security_token) { - session_info->security_token = dup_nt_token(session_info, server_info->security_token); - if (!session_info->security_token) { - TALLOC_FREE(session_info); - return NT_STATUS_NO_MEMORY; - } - } - - session_info->session_key = data_blob_talloc( session_info, server_info->session_key.data, - server_info->session_key.length); session_info->info3 = copy_netr_SamInfo3(session_info, server_info->info3); if (!session_info->info3) { @@ -538,6 +519,9 @@ NTSTATUS create_local_token(TALLOC_CTX *mem_ctx, if (!session_info->session_key.data && session_key->length) { return NT_STATUS_NO_MEMORY; } + } else { + session_info->session_key = data_blob_talloc( session_info, server_info->session_key.data, + server_info->session_key.length); } if (session_info->security_token) { @@ -545,6 +529,22 @@ NTSTATUS create_local_token(TALLOC_CTX *mem_ctx, * (nasty hack to support a cached guest session_info, * and a possible strategy for auth_samba4 to pass in * a finalised session) */ + + session_info->security_token = dup_nt_token(session_info, server_info->security_token); + if (!session_info->security_token) { + TALLOC_FREE(session_info); + return NT_STATUS_NO_MEMORY; + } + + session_info->unix_token->ngroups = server_info->utok.ngroups; + if (server_info->utok.ngroups != 0) { + session_info->unix_token->groups = (gid_t *)talloc_memdup( + session_info->unix_token, server_info->utok.groups, + sizeof(gid_t)*session_info->unix_token->ngroups); + } else { + session_info->unix_token->groups = NULL; + } + *session_info_out = session_info; return NT_STATUS_OK; } |