summaryrefslogtreecommitdiff
path: root/source4/auth/gensec/gensec_util.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-10-07 17:24:12 +1100
committerAndrew Bartlett <abartlet@samba.org>2011-10-11 13:41:36 +1100
commitfe02752ed6493efb7af28faa3d64d9fd7895d6f1 (patch)
tree22463dbd5f702c76ce0021f7aa6fbcc31afe2378 /source4/auth/gensec/gensec_util.c
parent561d834123a2a8a96954f7cca556f8838ab38b72 (diff)
downloadsamba-fe02752ed6493efb7af28faa3d64d9fd7895d6f1.tar.gz
samba-fe02752ed6493efb7af28faa3d64d9fd7895d6f1.tar.bz2
samba-fe02752ed6493efb7af28faa3d64d9fd7895d6f1.zip
auth: move gensec_start.c to the top level
This does not change who uses gensec for now, but makes it possible to write new gensec modules outside source4/ Andrew Bartlett
Diffstat (limited to 'source4/auth/gensec/gensec_util.c')
-rw-r--r--source4/auth/gensec/gensec_util.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/source4/auth/gensec/gensec_util.c b/source4/auth/gensec/gensec_util.c
new file mode 100644
index 0000000000..267366af61
--- /dev/null
+++ b/source4/auth/gensec/gensec_util.c
@@ -0,0 +1,59 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Generic Authentication Interface
+
+ Copyright (C) Andrew Tridgell 2003
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "auth/gensec/gensec.h"
+#include "auth/auth.h"
+#include "auth/system_session_proto.h"
+
+NTSTATUS gensec_generate_session_info(TALLOC_CTX *mem_ctx,
+ struct gensec_security *gensec_security,
+ struct auth_user_info_dc *user_info_dc,
+ struct auth_session_info **session_info)
+{
+ NTSTATUS nt_status;
+ uint32_t session_info_flags = 0;
+
+ if (gensec_security->want_features & GENSEC_FEATURE_UNIX_TOKEN) {
+ session_info_flags |= AUTH_SESSION_INFO_UNIX_TOKEN;
+ }
+
+ session_info_flags |= AUTH_SESSION_INFO_DEFAULT_GROUPS;
+ if (user_info_dc->info->authenticated) {
+ session_info_flags |= AUTH_SESSION_INFO_AUTHENTICATED;
+ }
+
+ if (gensec_security->auth_context) {
+ nt_status = gensec_security->auth_context->generate_session_info(mem_ctx, gensec_security->auth_context,
+ user_info_dc,
+ session_info_flags,
+ session_info);
+ } else {
+ session_info_flags |= AUTH_SESSION_INFO_SIMPLE_PRIVILEGES;
+ nt_status = auth_generate_session_info(mem_ctx,
+ NULL,
+ NULL,
+ user_info_dc, session_info_flags,
+ session_info);
+ }
+ return nt_status;
+}