summaryrefslogtreecommitdiff
path: root/source3/auth
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2017-03-13 08:58:43 +0100
committerStefan Metzmacher <metze@samba.org>2017-03-24 11:57:08 +0100
commit1e82d82571d33e0ff50c3f5fc461bf9dddc18fa5 (patch)
tree6e98e9eadcf740984d0dfbeb0e82aecfd618411d /source3/auth
parentb78de58e578eaa00391b87abbfd905726ecb559f (diff)
downloadsamba-1e82d82571d33e0ff50c3f5fc461bf9dddc18fa5.tar.gz
auth3: Introduce make_auth_context_specific
Take a string instead of a string list. Simplifies make_auth_context_subsystem and later similar callers BUG: https://bugzilla.samba.org/show_bug.cgi?id=2976 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/auth')
-rw-r--r--source3/auth/auth.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index 5f3cdb650fa..2b0eb50fcdc 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -461,6 +461,26 @@ static NTSTATUS make_auth_context_text_list(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+static NTSTATUS make_auth_context_specific(TALLOC_CTX *mem_ctx,
+ struct auth_context **auth_context,
+ const char *methods)
+{
+ char **method_list;
+ NTSTATUS status;
+
+ method_list = str_list_make_v3(talloc_tos(), methods, NULL);
+ if (method_list == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = make_auth_context_text_list(
+ mem_ctx, auth_context, method_list);
+
+ TALLOC_FREE(method_list);
+
+ return status;
+}
+
/***************************************************************************
Make a auth_context struct for the auth subsystem
***************************************************************************/
@@ -468,7 +488,7 @@ static NTSTATUS make_auth_context_text_list(TALLOC_CTX *mem_ctx,
NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
struct auth_context **auth_context)
{
- char **auth_method_list = NULL;
+ const char *methods = NULL;
NTSTATUS nt_status;
if (lp_auth_methods()) {
@@ -482,47 +502,32 @@ NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
switch (lp_server_role()) {
case ROLE_DOMAIN_MEMBER:
DEBUG(5,("Making default auth method list for server role = 'domain member'\n"));
- auth_method_list = str_list_make_v3(
- talloc_tos(), "guest sam winbind:ntdomain",
- NULL);
+ methods = "guest sam winbind:ntdomain";
break;
case ROLE_DOMAIN_BDC:
case ROLE_DOMAIN_PDC:
DEBUG(5,("Making default auth method list for DC\n"));
- auth_method_list = str_list_make_v3(
- talloc_tos(),
- "guest sam winbind:trustdomain",
- NULL);
+ methods = "guest sam winbind:trustdomain";
break;
case ROLE_STANDALONE:
DEBUG(5,("Making default auth method list for server role = 'standalone server', encrypt passwords = yes\n"));
if (lp_encrypt_passwords()) {
- auth_method_list = str_list_make_v3(
- talloc_tos(), "guest sam",
- NULL);
+ methods = "guest sam";
} else {
DEBUG(5,("Making default auth method list for server role = 'standalone server', encrypt passwords = no\n"));
- auth_method_list = str_list_make_v3(
- talloc_tos(), "guest unix", NULL);
+ methods = "guest unix";
}
break;
case ROLE_ACTIVE_DIRECTORY_DC:
DEBUG(5,("Making default auth method list for server role = 'active directory domain controller'\n"));
- auth_method_list = str_list_make_v3(
- talloc_tos(),
- "samba4",
- NULL);
+ methods = "samba4";
break;
default:
DEBUG(5,("Unknown auth method!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
- nt_status = make_auth_context_text_list(mem_ctx, auth_context,
- auth_method_list);
-
- TALLOC_FREE(auth_method_list);
- return nt_status;
+ return make_auth_context_specific(mem_ctx, auth_context, methods);
}
/***************************************************************************