|
|
841ac7 |
From 45580b2c90d7c19f1d8df57ce7b3e9f3e0acc244 Mon Sep 17 00:00:00 2001
|
|
|
841ac7 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
841ac7 |
Date: Wed, 27 Mar 2019 21:05:06 +0100
|
|
|
841ac7 |
Subject: [PATCH 19/21] PAM: add initial prompting configuration
|
|
|
841ac7 |
|
|
|
841ac7 |
Add new section for sssd.conf to allow more flexible prompting during
|
|
|
841ac7 |
authentication.
|
|
|
841ac7 |
|
|
|
841ac7 |
Related to https://pagure.io/SSSD/sssd/issue/3264
|
|
|
841ac7 |
|
|
|
841ac7 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
841ac7 |
(cherry picked with fixes from commit a4d178593bec65a4c7534b841cedfbb74c56f49f)
|
|
|
841ac7 |
---
|
|
|
841ac7 |
Makefile.am | 7 +
|
|
|
841ac7 |
src/confdb/confdb.h | 10 +
|
|
|
841ac7 |
src/man/sssd.conf.5.xml | 66 ++++++
|
|
|
841ac7 |
src/responder/pam/pam_prompting_config.c | 275 +++++++++++++++++++++++
|
|
|
841ac7 |
src/responder/pam/pamsrv.c | 16 +-
|
|
|
841ac7 |
src/responder/pam/pamsrv.h | 6 +
|
|
|
841ac7 |
src/responder/pam/pamsrv_cmd.c | 8 +
|
|
|
841ac7 |
7 files changed, 387 insertions(+), 1 deletion(-)
|
|
|
841ac7 |
create mode 100644 src/responder/pam/pam_prompting_config.c
|
|
|
841ac7 |
|
|
|
841ac7 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
841ac7 |
index f7f55e96a..e22423071 100644
|
|
|
841ac7 |
--- a/Makefile.am
|
|
|
841ac7 |
+++ b/Makefile.am
|
|
|
841ac7 |
@@ -1397,8 +1397,13 @@ sssd_pam_SOURCES = \
|
|
|
841ac7 |
src/responder/pam/pamsrv_cmd.c \
|
|
|
841ac7 |
src/responder/pam/pamsrv_p11.c \
|
|
|
841ac7 |
src/responder/pam/pamsrv_dp.c \
|
|
|
841ac7 |
+ src/responder/pam/pam_prompting_config.c \
|
|
|
841ac7 |
+ src/sss_client/pam_sss_prompt_config.c \
|
|
|
841ac7 |
src/responder/pam/pam_helpers.c \
|
|
|
841ac7 |
$(SSSD_RESPONDER_OBJ)
|
|
|
841ac7 |
+sssd_pam_CFLAGS = \
|
|
|
841ac7 |
+ $(AM_CFLAGS) \
|
|
|
841ac7 |
+ $(NULL)
|
|
|
841ac7 |
sssd_pam_LDADD = \
|
|
|
841ac7 |
$(LIBADD_DL) \
|
|
|
841ac7 |
$(TDB_LIBS) \
|
|
|
841ac7 |
@@ -2446,6 +2451,8 @@ pam_srv_tests_SOURCES = \
|
|
|
841ac7 |
src/responder/pam/pam_helpers.c \
|
|
|
841ac7 |
src/responder/pam/pamsrv_dp.c \
|
|
|
841ac7 |
src/responder/pam/pam_LOCAL_domain.c \
|
|
|
841ac7 |
+ src/responder/pam/pam_prompting_config.c \
|
|
|
841ac7 |
+ src/sss_client/pam_sss_prompt_config.c \
|
|
|
841ac7 |
$(NULL)
|
|
|
841ac7 |
pam_srv_tests_CFLAGS = \
|
|
|
841ac7 |
-U SSSD_LIBEXEC_PATH -DSSSD_LIBEXEC_PATH=\"$(abs_builddir)\" \
|
|
|
841ac7 |
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
|
|
|
841ac7 |
index e8091fcd9..0251ab606 100644
|
|
|
841ac7 |
--- a/src/confdb/confdb.h
|
|
|
841ac7 |
+++ b/src/confdb/confdb.h
|
|
|
841ac7 |
@@ -266,6 +266,16 @@
|
|
|
841ac7 |
#define CONFDB_KCM_SOCKET "socket_path"
|
|
|
841ac7 |
#define CONFDB_KCM_DB "ccache_storage" /* Undocumented on purpose */
|
|
|
841ac7 |
|
|
|
841ac7 |
+/* Prompting */
|
|
|
841ac7 |
+#define CONFDB_PC_CONF_ENTRY "config/prompting"
|
|
|
841ac7 |
+#define CONFDB_PC_TYPE_PASSWORD "password"
|
|
|
841ac7 |
+#define CONFDB_PC_PASSWORD_PROMPT "password_prompt"
|
|
|
841ac7 |
+#define CONFDB_PC_TYPE_2FA "2fa"
|
|
|
841ac7 |
+#define CONFDB_PC_2FA_SINGLE_PROMPT "single_prompt"
|
|
|
841ac7 |
+#define CONFDB_PC_2FA_1ST_PROMPT "first_prompt"
|
|
|
841ac7 |
+#define CONFDB_PC_2FA_2ND_PROMPT "second_prompt"
|
|
|
841ac7 |
+#define CONFDB_PC_TYPE_CERT_AUTH "cert_auth"
|
|
|
841ac7 |
+
|
|
|
841ac7 |
struct confdb_ctx;
|
|
|
841ac7 |
struct config_file_ctx;
|
|
|
841ac7 |
|
|
|
841ac7 |
diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml
|
|
|
841ac7 |
index 3d017f638..274809e24 100644
|
|
|
841ac7 |
--- a/src/man/sssd.conf.5.xml
|
|
|
841ac7 |
+++ b/src/man/sssd.conf.5.xml
|
|
|
841ac7 |
@@ -3364,6 +3364,72 @@ ldap_user_extra_attrs = phone:telephoneNumber
|
|
|
841ac7 |
</para>
|
|
|
841ac7 |
</refsect1>
|
|
|
841ac7 |
|
|
|
841ac7 |
+ <refsect1 id='prompting_configuration'>
|
|
|
841ac7 |
+ <title>PROMPTING CONFIGURATION SECTION</title>
|
|
|
841ac7 |
+ <para>
|
|
|
841ac7 |
+ If a special file
|
|
|
841ac7 |
+ (<filename>/var/lib/sss/pubconf/pam_preauth_available</filename>)
|
|
|
841ac7 |
+ exists SSSD's PAM module pam_sss will ask SSSD to figure out which
|
|
|
841ac7 |
+ authentication methods are available for the user trying to log in.
|
|
|
841ac7 |
+ Based on the results pam_sss will prompt the user for appropriate
|
|
|
841ac7 |
+ credentials.
|
|
|
841ac7 |
+ </para>
|
|
|
841ac7 |
+ <para>
|
|
|
841ac7 |
+ With the growing number of authentication methods and the
|
|
|
841ac7 |
+ possibility that there are multiple ones for a single user the
|
|
|
841ac7 |
+ heuristic used by pam_sss to select the prompting might not be
|
|
|
841ac7 |
+ suitable for all use cases. To following options should provide a
|
|
|
841ac7 |
+ better flexibility here.
|
|
|
841ac7 |
+ </para>
|
|
|
841ac7 |
+ <para>
|
|
|
841ac7 |
+ Each supported authentication method has it's own configuration
|
|
|
841ac7 |
+ sub-section under <quote>[prompting/...]</quote>. Currently there
|
|
|
841ac7 |
+ are:
|
|
|
841ac7 |
+ <variablelist>
|
|
|
841ac7 |
+ <varlistentry>
|
|
|
841ac7 |
+ <term>[prompting/password]</term>
|
|
|
841ac7 |
+ <listitem>
|
|
|
841ac7 |
+ <para>to configure password prompting, allowed options are:
|
|
|
841ac7 |
+ <variablelist><varlistentry><term>password_prompt</term>
|
|
|
841ac7 |
+ <listitem><para>to change the string of the password
|
|
|
841ac7 |
+ prompt</para></listitem></varlistentry></variablelist>
|
|
|
841ac7 |
+ </para>
|
|
|
841ac7 |
+ </listitem>
|
|
|
841ac7 |
+ </varlistentry>
|
|
|
841ac7 |
+ </variablelist>
|
|
|
841ac7 |
+ <variablelist>
|
|
|
841ac7 |
+ <varlistentry>
|
|
|
841ac7 |
+ <term>[prompting/2fa]</term>
|
|
|
841ac7 |
+ <listitem>
|
|
|
841ac7 |
+ <para>to configure two-factor authentication prompting,
|
|
|
841ac7 |
+ allowed options are:
|
|
|
841ac7 |
+ <variablelist><varlistentry><term>first_prompt</term>
|
|
|
841ac7 |
+ <listitem><para>to change the string of the prompt for
|
|
|
841ac7 |
+ the first factor </para></listitem>
|
|
|
841ac7 |
+ </varlistentry>
|
|
|
841ac7 |
+ <varlistentry><term>second_prompt</term>
|
|
|
841ac7 |
+ <listitem><para>to change the string of the prompt for
|
|
|
841ac7 |
+ the second factor </para></listitem>
|
|
|
841ac7 |
+ </varlistentry>
|
|
|
841ac7 |
+ <varlistentry><term>single_prompt</term>
|
|
|
841ac7 |
+ <listitem><para>boolean value, if True there will be
|
|
|
841ac7 |
+ only a single prompt using the value of first_prompt
|
|
|
841ac7 |
+ where it is expected that both factor are entered as a
|
|
|
841ac7 |
+ single string</para></listitem>
|
|
|
841ac7 |
+ </varlistentry>
|
|
|
841ac7 |
+ </variablelist>
|
|
|
841ac7 |
+ </para>
|
|
|
841ac7 |
+ </listitem>
|
|
|
841ac7 |
+ </varlistentry>
|
|
|
841ac7 |
+ </variablelist>
|
|
|
841ac7 |
+ </para>
|
|
|
841ac7 |
+ <para>
|
|
|
841ac7 |
+ It is possible to add a sub-section for specific PAM services like
|
|
|
841ac7 |
+ e.g. <quote>[prompting/password/sshd]</quote> to individual change
|
|
|
841ac7 |
+ the prompting for this service.
|
|
|
841ac7 |
+ </para>
|
|
|
841ac7 |
+ </refsect1>
|
|
|
841ac7 |
+
|
|
|
841ac7 |
<refsect1 id='example'>
|
|
|
841ac7 |
<title>EXAMPLES</title>
|
|
|
841ac7 |
<para>
|
|
|
841ac7 |
diff --git a/src/responder/pam/pam_prompting_config.c b/src/responder/pam/pam_prompting_config.c
|
|
|
841ac7 |
new file mode 100644
|
|
|
841ac7 |
index 000000000..c3ee41d4b
|
|
|
841ac7 |
--- /dev/null
|
|
|
841ac7 |
+++ b/src/responder/pam/pam_prompting_config.c
|
|
|
841ac7 |
@@ -0,0 +1,275 @@
|
|
|
841ac7 |
+/*
|
|
|
841ac7 |
+ SSSD
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ PAM Responder - helpers for PAM prompting configuration
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ Copyright (C) Sumit Bose <sbose@redhat.com> 2019
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
841ac7 |
+ it under the terms of the GNU General Public License as published by
|
|
|
841ac7 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
841ac7 |
+ (at your option) any later version.
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ This program is distributed in the hope that it will be useful,
|
|
|
841ac7 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
841ac7 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
841ac7 |
+ GNU General Public License for more details.
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ You should have received a copy of the GNU General Public License
|
|
|
841ac7 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
841ac7 |
+*/
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+#include "util/util.h"
|
|
|
841ac7 |
+#include "providers/data_provider.h"
|
|
|
841ac7 |
+#include "confdb/confdb.h"
|
|
|
841ac7 |
+#include "sss_client/sss_cli.h"
|
|
|
841ac7 |
+#include "responder/pam/pamsrv.h"
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+typedef errno_t (pam_set_prompting_fn_t)(TALLOC_CTX *, struct confdb_ctx *,
|
|
|
841ac7 |
+ const char *,
|
|
|
841ac7 |
+ struct prompt_config ***);
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+static errno_t pam_set_password_prompting_options(TALLOC_CTX *tmp_ctx,
|
|
|
841ac7 |
+ struct confdb_ctx *cdb,
|
|
|
841ac7 |
+ const char *section,
|
|
|
841ac7 |
+ struct prompt_config ***pc_list)
|
|
|
841ac7 |
+{
|
|
|
841ac7 |
+ int ret;
|
|
|
841ac7 |
+ char *value = NULL;
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = confdb_get_string(cdb, tmp_ctx, section, CONFDB_PC_PASSWORD_PROMPT,
|
|
|
841ac7 |
+ NULL, &value);
|
|
|
841ac7 |
+ if (ret == EOK && value != NULL) {
|
|
|
841ac7 |
+ ret = pc_list_add_password(pc_list, value);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "pc_list_add_password failed.\n");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ return ret;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ return ENOENT;
|
|
|
841ac7 |
+}
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+static errno_t pam_set_2fa_prompting_options(TALLOC_CTX *tmp_ctx,
|
|
|
841ac7 |
+ struct confdb_ctx *cdb,
|
|
|
841ac7 |
+ const char *section,
|
|
|
841ac7 |
+ struct prompt_config ***pc_list)
|
|
|
841ac7 |
+{
|
|
|
841ac7 |
+ bool single_2fa_prompt = false;
|
|
|
841ac7 |
+ char *first_prompt = NULL;
|
|
|
841ac7 |
+ char *second_prompt = NULL;
|
|
|
841ac7 |
+ int ret;
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = confdb_get_bool(cdb, section, CONFDB_PC_2FA_SINGLE_PROMPT, false,
|
|
|
841ac7 |
+ &single_2fa_prompt);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "confdb_get_bool failed, using defaults");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ ret = confdb_get_string(cdb, tmp_ctx, section, CONFDB_PC_2FA_1ST_PROMPT,
|
|
|
841ac7 |
+ NULL, &first_prompt);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "confdb_get_string failed, using defaults");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (single_2fa_prompt) {
|
|
|
841ac7 |
+ ret = pc_list_add_2fa_single(pc_list, first_prompt);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "pc_list_add_2fa_single failed.\n");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ return ret;
|
|
|
841ac7 |
+ } else {
|
|
|
841ac7 |
+ ret = confdb_get_string(cdb, tmp_ctx, section, CONFDB_PC_2FA_2ND_PROMPT,
|
|
|
841ac7 |
+ NULL, &second_prompt);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
841ac7 |
+ "confdb_get_string failed, using defaults");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = pc_list_add_2fa(pc_list, first_prompt, second_prompt);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "pc_list_add_2fa failed.\n");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ return ret;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ return ENOENT;
|
|
|
841ac7 |
+}
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+static errno_t pam_set_prompting_options(struct confdb_ctx *cdb,
|
|
|
841ac7 |
+ const char *service_name,
|
|
|
841ac7 |
+ char **sections,
|
|
|
841ac7 |
+ int num_sections,
|
|
|
841ac7 |
+ const char *section_path,
|
|
|
841ac7 |
+ pam_set_prompting_fn_t *setter,
|
|
|
841ac7 |
+ struct prompt_config ***pc_list)
|
|
|
841ac7 |
+{
|
|
|
841ac7 |
+ char *dummy;
|
|
|
841ac7 |
+ size_t c;
|
|
|
841ac7 |
+ bool global = false;
|
|
|
841ac7 |
+ bool specific = false;
|
|
|
841ac7 |
+ char *section = NULL;
|
|
|
841ac7 |
+ int ret;
|
|
|
841ac7 |
+ char *last;
|
|
|
841ac7 |
+ TALLOC_CTX *tmp_ctx = NULL;
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ tmp_ctx = talloc_new(NULL);
|
|
|
841ac7 |
+ if (tmp_ctx == NULL) {
|
|
|
841ac7 |
+ ret = ENOMEM;
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ dummy = talloc_asprintf(tmp_ctx, "%s/%s", section_path,
|
|
|
841ac7 |
+ service_name);
|
|
|
841ac7 |
+ for (c = 0; c < num_sections; c++) {
|
|
|
841ac7 |
+ if (strcmp(sections[c], CONFDB_PC_TYPE_PASSWORD) == 0) {
|
|
|
841ac7 |
+ global = true;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ if (dummy != NULL && strcmp(sections[c], dummy) == 0) {
|
|
|
841ac7 |
+ specific = true;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ section = talloc_asprintf(tmp_ctx, "%s/%s", CONFDB_PC_CONF_ENTRY, dummy);
|
|
|
841ac7 |
+ if (section == NULL) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_asprintf failed.\n");
|
|
|
841ac7 |
+ ret = ENOMEM;
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = ENOENT;
|
|
|
841ac7 |
+ if (specific) {
|
|
|
841ac7 |
+ ret = setter(tmp_ctx, cdb, section, pc_list);
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ if (global && ret == ENOENT) {
|
|
|
841ac7 |
+ last = strrchr(section, '/');
|
|
|
841ac7 |
+ if (last != NULL) {
|
|
|
841ac7 |
+ *last = '\0';
|
|
|
841ac7 |
+ ret = setter(tmp_ctx, cdb, section, pc_list);
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ if (ret != EOK && ret != ENOENT) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "setter failed.\n");
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = EOK;
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+done:
|
|
|
841ac7 |
+ talloc_free(tmp_ctx);
|
|
|
841ac7 |
+ return ret;
|
|
|
841ac7 |
+}
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+errno_t pam_eval_prompting_config(struct pam_ctx *pctx, struct pam_data *pd)
|
|
|
841ac7 |
+{
|
|
|
841ac7 |
+ int ret;
|
|
|
841ac7 |
+ struct response_data *resp;
|
|
|
841ac7 |
+ bool password_auth = false;
|
|
|
841ac7 |
+ bool otp_auth = false;
|
|
|
841ac7 |
+ bool cert_auth = false;
|
|
|
841ac7 |
+ struct prompt_config **pc_list = NULL;
|
|
|
841ac7 |
+ int resp_len;
|
|
|
841ac7 |
+ uint8_t *resp_data = NULL;
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (pctx->num_prompting_config_sections == 0) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_TRACE_ALL, "No prompting configuration found.\n");
|
|
|
841ac7 |
+ return EOK;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ resp = pd->resp_list;
|
|
|
841ac7 |
+ while (resp != NULL) {
|
|
|
841ac7 |
+ switch (resp->type) {
|
|
|
841ac7 |
+ case SSS_PAM_OTP_INFO:
|
|
|
841ac7 |
+ otp_auth = true;
|
|
|
841ac7 |
+ break;
|
|
|
841ac7 |
+ case SSS_PAM_CERT_INFO:
|
|
|
841ac7 |
+ cert_auth = true;
|
|
|
841ac7 |
+ break;
|
|
|
841ac7 |
+ case SSS_PASSWORD_PROMPTING:
|
|
|
841ac7 |
+ password_auth = true;
|
|
|
841ac7 |
+ break;
|
|
|
841ac7 |
+ case SSS_CERT_AUTH_PROMPTING:
|
|
|
841ac7 |
+ /* currently not used */
|
|
|
841ac7 |
+ break;
|
|
|
841ac7 |
+ default:
|
|
|
841ac7 |
+ break;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ resp = resp->next;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (!password_auth && !otp_auth && !cert_auth) {
|
|
|
841ac7 |
+ /* If the backend cannot determine which authentication types are
|
|
|
841ac7 |
+ * available the default would be to prompt for a password. */
|
|
|
841ac7 |
+ password_auth = true;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ DEBUG(SSSDBG_TRACE_ALL, "Authentication types for user [%s] and service "
|
|
|
841ac7 |
+ "[%s]:%s%s%s\n", pd->user, pd->service,
|
|
|
841ac7 |
+ password_auth ? " password": "",
|
|
|
841ac7 |
+ otp_auth ? " two-factor" : "",
|
|
|
841ac7 |
+ cert_auth ? " smartcard" : "");
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (cert_auth) {
|
|
|
841ac7 |
+ /* If certificate based authentication is possilbe, i.e. a Smartcard
|
|
|
841ac7 |
+ * or similar with the mapped certificate is available we currently
|
|
|
841ac7 |
+ * prefer this authentication type unconditionally. If other types
|
|
|
841ac7 |
+ * should be used the Smartcard can be removed during authentication.
|
|
|
841ac7 |
+ * Since there currently are no specific options for cert_auth we are
|
|
|
841ac7 |
+ * done. */
|
|
|
841ac7 |
+ ret = EOK;
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ /* If OTP and password auth are possible we currently prefer OTP. */
|
|
|
841ac7 |
+ if (otp_auth) {
|
|
|
841ac7 |
+ ret = pam_set_prompting_options(pctx->rctx->cdb, pd->service,
|
|
|
841ac7 |
+ pctx->prompting_config_sections,
|
|
|
841ac7 |
+ pctx->num_prompting_config_sections,
|
|
|
841ac7 |
+ CONFDB_PC_TYPE_2FA,
|
|
|
841ac7 |
+ pam_set_2fa_prompting_options,
|
|
|
841ac7 |
+ &pc_list);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
841ac7 |
+ "pam_set_prompting_options failed.\n");
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (password_auth) {
|
|
|
841ac7 |
+ ret = pam_set_prompting_options(pctx->rctx->cdb, pd->service,
|
|
|
841ac7 |
+ pctx->prompting_config_sections,
|
|
|
841ac7 |
+ pctx->num_prompting_config_sections,
|
|
|
841ac7 |
+ CONFDB_PC_TYPE_PASSWORD,
|
|
|
841ac7 |
+ pam_set_password_prompting_options,
|
|
|
841ac7 |
+ &pc_list);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
841ac7 |
+ "pam_set_prompting_options failed.\n");
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (pc_list != NULL) {
|
|
|
841ac7 |
+ ret = pam_get_response_prompt_config(pc_list, &resp_len, &resp_data);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
841ac7 |
+ "pam_get_response_prompt_config failed.\n");
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = pam_add_response(pd, SSS_PAM_PROMPT_CONFIG, resp_len, resp_data);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "pam_add_response failed.\n");
|
|
|
841ac7 |
+ goto done;
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ ret = EOK;
|
|
|
841ac7 |
+done:
|
|
|
841ac7 |
+ free(resp_data);
|
|
|
841ac7 |
+ pc_list_free(pc_list);
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ return ret;
|
|
|
841ac7 |
+}
|
|
|
841ac7 |
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
|
|
|
841ac7 |
index 4ddd1d0b3..fb799d28b 100644
|
|
|
841ac7 |
--- a/src/responder/pam/pamsrv.c
|
|
|
841ac7 |
+++ b/src/responder/pam/pamsrv.c
|
|
|
841ac7 |
@@ -315,6 +315,16 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
|
|
|
841ac7 |
goto done;
|
|
|
841ac7 |
}
|
|
|
841ac7 |
|
|
|
841ac7 |
+ /* Check if there is a prompting configuration */
|
|
|
841ac7 |
+ pctx->prompting_config_sections = NULL;
|
|
|
841ac7 |
+ pctx->num_prompting_config_sections = 0;
|
|
|
841ac7 |
+ ret = confdb_get_sub_sections(pctx, pctx->rctx->cdb, CONFDB_PC_CONF_ENTRY,
|
|
|
841ac7 |
+ &pctx->prompting_config_sections,
|
|
|
841ac7 |
+ &pctx->num_prompting_config_sections);
|
|
|
841ac7 |
+ if (ret != EOK && ret != ENOENT) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "confdb_get_sub_sections failed, not fatal.\n");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
/* Check if certificate based authentication is enabled */
|
|
|
841ac7 |
ret = confdb_get_bool(pctx->rctx->cdb,
|
|
|
841ac7 |
CONFDB_PAM_CONF_ENTRY,
|
|
|
841ac7 |
@@ -346,11 +356,15 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
|
|
|
841ac7 |
goto done;
|
|
|
841ac7 |
}
|
|
|
841ac7 |
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ if (pctx->cert_auth || pctx->num_prompting_config_sections != 0) {
|
|
|
841ac7 |
ret = create_preauth_indicator();
|
|
|
841ac7 |
if (ret != EOK) {
|
|
|
841ac7 |
DEBUG(SSSDBG_OP_FAILURE,
|
|
|
841ac7 |
"Failed to create pre-authentication indicator file, "
|
|
|
841ac7 |
- "Smartcard authentication might not work as expected.\n");
|
|
|
841ac7 |
+ "Smartcard authentication or configured prompting might "
|
|
|
841ac7 |
+ "not work as expected.\n");
|
|
|
841ac7 |
}
|
|
|
841ac7 |
}
|
|
|
841ac7 |
|
|
|
841ac7 |
diff --git a/src/responder/pam/pamsrv.h b/src/responder/pam/pamsrv.h
|
|
|
841ac7 |
index 3325d9b9f..319362a95 100644
|
|
|
841ac7 |
--- a/src/responder/pam/pamsrv.h
|
|
|
841ac7 |
+++ b/src/responder/pam/pamsrv.h
|
|
|
841ac7 |
@@ -52,6 +52,9 @@ struct pam_ctx {
|
|
|
841ac7 |
char *nss_db;
|
|
|
841ac7 |
struct sss_certmap_ctx *sss_certmap_ctx;
|
|
|
841ac7 |
char **smartcard_services;
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+ char **prompting_config_sections;
|
|
|
841ac7 |
+ int num_prompting_config_sections;
|
|
|
841ac7 |
};
|
|
|
841ac7 |
|
|
|
841ac7 |
struct pam_auth_dp_req {
|
|
|
841ac7 |
@@ -130,4 +133,7 @@ pam_set_last_online_auth_with_curr_token(struct sss_domain_info *domain,
|
|
|
841ac7 |
errno_t filter_responses(struct confdb_ctx *cdb,
|
|
|
841ac7 |
struct response_data *resp_list,
|
|
|
841ac7 |
struct pam_data *pd);
|
|
|
841ac7 |
+
|
|
|
841ac7 |
+errno_t pam_eval_prompting_config(struct pam_ctx *pctx, struct pam_data *pd);
|
|
|
841ac7 |
+
|
|
|
841ac7 |
#endif /* __PAMSRV_H__ */
|
|
|
841ac7 |
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
|
|
|
841ac7 |
index 6f3a7e56b..6b2dc5bdc 100644
|
|
|
841ac7 |
--- a/src/responder/pam/pamsrv_cmd.c
|
|
|
841ac7 |
+++ b/src/responder/pam/pamsrv_cmd.c
|
|
|
841ac7 |
@@ -1003,6 +1003,14 @@ static void pam_reply(struct pam_auth_req *preq)
|
|
|
841ac7 |
}
|
|
|
841ac7 |
}
|
|
|
841ac7 |
|
|
|
841ac7 |
+ if (pd->cmd == SSS_PAM_PREAUTH) {
|
|
|
841ac7 |
+ ret = pam_eval_prompting_config(pctx, pd);
|
|
|
841ac7 |
+ if (ret != EOK) {
|
|
|
841ac7 |
+ DEBUG(SSSDBG_OP_FAILURE, "Failed to add prompting information, "
|
|
|
841ac7 |
+ "using defaults.\n");
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+ }
|
|
|
841ac7 |
+
|
|
|
841ac7 |
/*
|
|
|
841ac7 |
* Export non-overridden shell to tlog-rec-session when opening the session
|
|
|
841ac7 |
*/
|
|
|
841ac7 |
--
|
|
|
841ac7 |
2.19.1
|
|
|
841ac7 |
|