/*
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2009 Red Hat
Copyright (C) 2010, rhafer@suse.de, Novell Inc.
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <syslog.h>
#include <time.h>
#include <fcntl.h>
#include <errno.h>
#include <locale.h>
#include <stdbool.h>
#include <security/pam_modules.h>
#include <security/pam_appl.h>
#ifdef HAVE_GDM_PAM_EXTENSIONS
#include <gdm/gdm-pam-extensions.h>
#endif
#include "sss_pam_compat.h"
#include "sss_pam_macros.h"
#include "sss_cli.h"
#include "pam_message.h"
#include "util/atomic_io.h"
#include "util/authtok-utils.h"
#include "util/dlinklist.h"
#include <libintl.h>
#ifdef DEBUG
int ret;
if (ret >= DEBUG_MGS_LEN) {
D(("the following message is truncated: %s", debug_msg));
} else if (ret < 0) {
D(("vsnprintf failed to format debug message!"));
} else {
D((debug_msg));
}
#endif
}
{
}
{
#ifdef PAM_DATA_REPLACE
if (err & PAM_DATA_REPLACE) {
/* Nothing to do */
return;
}
#endif /* PAM_DATA_REPLACE */
D(("Closing the fd"));
}
struct cert_auth_info {
char *cert_user;
char *cert;
char *token_name;
char *module_name;
char *key_id;
char *prompt_str;
};
{
}
}
{
}
}
}
{
}
}
}
}
{
}
}
enum {
SSS_PAM_CONV_DONE = 0,
};
const char *msg,
const char *reenter_msg,
char **_answer)
{
int ret;
if ((msg_style == PAM_PROMPT_ECHO_OFF ||
msg_style == PAM_PROMPT_ECHO_ON) &&
msg);
}
return PAM_SYSTEM_ERR;
}
do {
D(("Malloc failed."));
goto failed;
}
if (state == SSS_PAM_CONV_REENTER) {
} else {
}
conv->appdata_ptr);
if (ret != PAM_SUCCESS) {
goto failed;
}
if (msg_style == PAM_PROMPT_ECHO_OFF ||
msg_style == PAM_PROMPT_ECHO_ON) {
D(("response expected, but resp==NULL"));
goto failed;
}
if (state == SSS_PAM_CONV_REENTER) {
_pam_overwrite((void *) answer);
}
_("Passwords do not match"),
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
goto failed;
}
ret = PAM_CRED_ERR;
goto failed;
}
} else {
D(("Empty password"));
} else {
D(("strndup failed"));
ret = PAM_BUF_ERR;
goto failed;
}
}
}
}
} else {
}
} while (state != SSS_PAM_CONV_DONE);
return PAM_SUCCESS;
return ret;
}
const char *domain_name,
const char *suffix)
{
int ret;
D(("Suffix [%s] or domain name [%s] contain illegal character.", suffix,
domain_name));
return EINVAL;
}
D(("malloc failed."));
goto done;
}
suffix);
D(("snprintf failed."));
goto done;
}
if (fd == -1) {
goto done;
}
if (ret == -1) {
goto done;
}
"Password reset message file is not a regular file.");
goto done;
}
"file [%s] must be owned by root with permissions 0644.",
filename);
goto done;
}
goto done;
}
D(("malloc failed."));
goto done;
}
errno = 0;
if (total_len == -1) {
goto done;
}
fd = -1;
if (ret == -1) {
}
D(("read fewer bytes [%d] than expected [%d].", total_len,
goto done;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
}
done:
if (fd != -1) {
}
return ret;
}
{
int ret;
char *locale;
const char *domain_name;
D(("Domain name is unknown."));
return EINVAL;
}
ret = -1;
}
if (ret != 0) {
}
if (ret != 0) {
_("Password reset by root is not supported."),
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
}
}
return ret;
}
{
int ret;
expire_str[0] = '\0';
D(("User info response data has the wrong size"));
return PAM_BUF_ERR;
}
if (expire_date > 0) {
if (ret == 0) {
D(("strftime failed."));
expire_str[0] = '\0';
}
} else {
D(("localtime_r failed"));
}
}
_("Authenticated with cached credentials"),
D(("snprintf failed."));
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
D(("User info response data has the wrong size"));
return PAM_BUF_ERR;
}
_("Your password has expired. "
"You have %1$d grace login(s) remaining."),
grace);
D(("snprintf failed."));
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
D(("User info response data has the wrong size"));
return PAM_BUF_ERR;
}
unit = "day(s)";
unit = "hour(s)";
unit = "minute(s)";
}
D(("snprintf failed."));
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
delay_str[0] = '\0';
D(("User info response data has the wrong size"));
return PAM_BUF_ERR;
}
if (delayed_until <= 0) {
D(("User info response data has an invalid value"));
return PAM_BUF_ERR;
}
if (ret == 0) {
D(("strftime failed."));
delay_str[0] = '\0';
}
} else {
D(("localtime_r failed"));
}
_("Authentication is denied until: "),
D(("snprintf failed."));
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
_("System is offline, password change not possible"),
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
_("After changing the OTP password, you need to "
"log out and back in order to acquire a ticket"),
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
char *user_msg;
/* resp_type and length of message are expected to be in buf */
D(("User info response data is too short"));
return PAM_BUF_ERR;
}
/* msg_len = legth of message */
D(("User info response data has the wrong size"));
return PAM_BUF_ERR;
}
if (msg_len > 0) {
}
if (!user_msg) {
D(("Out of memory."));
return PAM_SYSTEM_ERR;
}
(int)msg_len,
D(("snprintf failed."));
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
char *user_msg;
D(("User info response data is too short"));
return PAM_BUF_ERR;
}
D(("User info response data has the wrong size"));
return PAM_BUF_ERR;
}
if (msg_len > 0) {
}
if (!user_msg) {
D(("Out of memory."));
return PAM_SYSTEM_ERR;
}
_("Password change failed. "),
(int)msg_len,
D(("snprintf failed."));
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return PAM_SYSTEM_ERR;
}
return PAM_SUCCESS;
}
{
int ret;
D(("User info response data is too short"));
return PAM_BUF_ERR;
}
switch(type) {
break;
break;
break;
break;
break;
break;
break;
break;
default:
D(("Unknown user info type [%d]", type));
}
return ret;
}
{
int ret;
D(("cert info does not end with \\0."));
return EINVAL;
}
return ENOMEM;
}
D(("strdup failed"));
goto done;
}
}
D(("Cert message size mismatch"));
goto done;
}
D(("strdup failed"));
goto done;
}
D(("Cert message size mismatch"));
goto done;
}
D(("strdup failed"));
goto done;
}
D(("Cert message size mismatch"));
goto done;
}
D(("strdup failed"));
goto done;
}
D(("Cert message size mismatch"));
goto done;
}
D(("strdup failed"));
goto done;
}
D(("cert user: [%s] token name: [%s] module: [%s] key id: [%s] "
"prompt: [%s]",
ret = 0;
done:
if (ret != 0) {
}
return ret;
}
{
int ret;
size_t p=0;
char *env_item;
int32_t c;
const char *cert_user;
D(("response buffer is too small"));
return PAM_BUF_ERR;
}
p += sizeof(int32_t);
p += sizeof(int32_t);
while(c>0) {
D(("response buffer is too small"));
return PAM_BUF_ERR;
}
p += sizeof(int32_t);
p += sizeof(int32_t);
D(("response buffer is too small"));
return PAM_BUF_ERR;
}
switch(type) {
case SSS_PAM_SYSTEM_INFO:
D(("system info does not end with \\0."));
break;
}
break;
case SSS_PAM_DOMAIN_NAME:
D(("domain name does not end with \\0."));
break;
}
D(("domain name: [%s]", &buf[p]));
D(("strdup failed"));
}
break;
case SSS_ENV_ITEM:
case SSS_PAM_ENV_ITEM:
case SSS_ALL_ENV_ITEM:
D(("env item does not end with \\0."));
break;
}
D(("env item: [%s]", &buf[p]));
if (ret != PAM_SUCCESS) {
D(("pam_putenv failed."));
break;
}
}
D(("strdup failed"));
break;
}
if (ret == -1) {
D(("putenv failed."));
break;
}
}
break;
case SSS_PAM_USER_INFO:
if (ret != PAM_SUCCESS) {
D(("eval_user_info_response failed"));
}
break;
case SSS_PAM_TEXT_MSG:
D(("system info does not end with \\0."));
break;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
}
break;
case SSS_OTP:
D(("OTP was used, removing authtokens."));
if (ret != PAM_SUCCESS) {
D(("Failed to remove PAM_AUTHTOK after using otp [%s]",
}
break;
case SSS_PAM_OTP_INFO:
D(("otp info does not end with \\0."));
break;
}
D(("strdup failed"));
break;
}
D(("OTP message size mismatch"));
break;
}
D(("strdup failed"));
break;
}
D(("OTP message size mismatch"));
break;
}
D(("strdup failed"));
break;
}
break;
case SSS_PAM_CERT_INFO:
D(("cert info does not end with \\0."));
break;
}
if (type == SSS_PAM_CERT_INFO_WITH_HINT) {
pi->user_name_hint = true;
} else {
pi->user_name_hint = false;
}
if (ret != 0) {
D(("Failed to parse cert info"));
break;
}
&& *cert_user != '\0') {
if (ret != PAM_SUCCESS) {
D(("Failed to set PAM_USER during "
"Smartcard authentication [%s]",
break;
}
if (ret != PAM_SUCCESS) {
D(("Failed to get PAM_USER during "
"Smartcard authentication [%s]",
break;
}
}
break;
case SSS_PASSWORD_PROMPTING:
D(("Password prompting available."));
pi->password_prompting = true;
break;
default:
D(("Unknown response type [%d]", type));
}
p += len;
--c;
}
return PAM_SUCCESS;
}
{
int ret;
pi->pam_authtok_size = 0;
pi->pam_newauthtok_size = 0;
ret = PAM_SUCCESS;
}
if (flags & FLAGS_ALLOW_MISSING_NAME) {
} else {
D(("No user found, aborting."));
return PAM_BAD_ITEM;
}
}
D(("pam_sss will not handle root."));
return PAM_USER_UNKNOWN;
}
(const void **) &(pi->pamstack_authtok));
(const void **) &(pi->pamstack_oldauthtok));
pi->password_prompting = false;
return PAM_SUCCESS;
}
{
D(("Pamstack_Authtok: %s",
D(("Pamstack_Oldauthtok: %s",
}
{
int ret;
int sret;
int errnop;
if (ret != 0) {
D(("pack_message failed."));
goto done;
}
errnop = 0;
if (sret != PAM_SUCCESS) {
D(("pam_set_data failed, client might leaks fds"));
}
if (ret != PAM_SUCCESS) {
if (errnop != 0) {
}
goto done;
}
/* FIXME: add an end signature */
D(("response not in expected format."));
goto done;
}
if (ret != PAM_SUCCESS) {
D(("eval_response failed."));
pam_status = ret;
goto done;
}
switch (task) {
case SSS_PAM_AUTHENTICATE:
"authentication %s; logname=%s uid=%lu euid=%d tty=%s "
"ruser=%s rhost=%s user=%s",
if (pam_status != PAM_SUCCESS) {
/* don't log if quiet_mode is on and pam_status is
* User not known to the underlying authentication module
*/
}
}
break;
case SSS_PAM_CHAUTHTOK_PRELIM:
if (pam_status != PAM_SUCCESS) {
/* don't log if quiet_mode is on and pam_status is
* User not known to the underlying authentication module
*/
"Authentication failed for user %s: %d (%s)",
}
}
break;
case SSS_PAM_CHAUTHTOK:
if (pam_status != PAM_SUCCESS) {
"Password change failed for user %s: %d (%s)",
}
break;
case SSS_PAM_ACCT_MGMT:
if (pam_status != PAM_SUCCESS) {
/* don't log if quiet_mode is on and pam_status is
* User not known to the underlying authentication module
*/
"Access denied for user %s: %d (%s)",
}
}
break;
case SSS_PAM_OPEN_SESSION:
case SSS_PAM_SETCRED:
case SSS_PAM_CLOSE_SESSION:
case SSS_PAM_PREAUTH:
break;
default:
D(("Illegal task [%#x]", task));
return PAM_SYSTEM_ERR;
}
done:
}
return pam_status;
}
const char *prompt)
{
int ret;
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return ret;
}
pi->pam_authtok_size=0;
} else {
_pam_overwrite((void *)answer);
return PAM_BUF_ERR;
}
}
return PAM_SUCCESS;
}
const char *prompt_fa1, const char *prompt_fa2)
{
int ret;
struct pam_message m[2] = { {0}, {0} };
if (ret != PAM_SUCCESS) {
return ret;
}
return PAM_SYSTEM_ERR;
}
m[0].msg_style = PAM_PROMPT_ECHO_OFF;
m[0].msg = prompt_fa1;
mesg[0] = (const struct pam_message *) m;
/* The following assignment might look a bit odd but is recommended in the
* pam_conv man page to make sure that the second argument of the PAM
* conversation function can be interpreted in two different ways.
* Basically it is important that both the actual struct pam_message and
* the pointers to the struct pam_message are arrays. Since the assignment
* makes clear that mesg[] and (*mesg)[] are arrays it should be kept this
* way and not be replaced by other equivalent assignments. */
if (ret != PAM_SUCCESS) {
return ret;
}
D(("response expected, but resp==NULL"));
return PAM_SYSTEM_ERR;
}
D(("Missing factor."));
goto done;
}
/* Missing second factor, assume first factor contains combined 2FA
* credentials.
* Special handling for SSH with password authentication. Combined
* 2FA credentials are used but SSH puts them in both responses. */
D(("strndup failed."));
ret = PAM_BUF_ERR;
goto done;
}
} else {
&needed_size);
D(("sss_auth_pack_2fa_blob failed."));
ret = PAM_BUF_ERR;
goto done;
}
D(("malloc failed."));
ret = PAM_BUF_ERR;
goto done;
}
&needed_size);
D(("sss_auth_pack_2fa_blob failed."));
ret = PAM_BUF_ERR;
goto done;
}
D(("strndup failed."));
ret = PAM_BUF_ERR;
goto done;
}
}
ret = PAM_SUCCESS;
done:
}
}
}
return ret;
}
#ifndef discard_const
#endif
{
#ifdef HAVE_GDM_PAM_EXTENSIONS
int ret;
size_t c;
char *prompt;
return ENOTSUP;
}
return EINVAL;
}
cert_count++;
}
if (ret != PAM_SUCCESS) {
return ret;
}
goto done;
}
c = 0;
if (ret == -1) {
goto done;
}
}
prompt_messages[0] = &prompt_message;
if (ret != PAM_SUCCESS) {
goto done;
}
goto done;
}
ret = 0;
break;
}
}
done:
for (c = 0; c < cert_count; c++) {
}
}
return ret;
#else
return ENOTSUP;
#endif
}
"the corresponding number\n")
{
int ret;
char *prompt;
char *tmp;
char *answer;
char *ep;
/* First check if gdm extension is supported */
return ret;
}
return EINVAL;
}
return ENOMEM;
}
cert_count++;
cai->prompt_str);
if (ret == -1) {
return ENOMEM;
}
}
do {
&answer);
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
break;
}
errno = 0;
/* do not free answer ealier because ep is pointing to it */
break;
}
resp = -1;
} while (++tries < 5);
cert_count = 0;
cert_count++;
if (resp == cert_count) {
ret = 0;
break;
}
}
}
return ret;
}
{
int ret;
char *prompt;
struct pam_message m[2] = { { 0 }, { 0 } };
return EINVAL;
}
D(("malloc failed."));
return ENOMEM;
}
D(("snprintf failed."));
return EFAULT;
}
if (pi->user_name_hint) {
if (ret != PAM_SUCCESS) {
return ret;
}
return PAM_SYSTEM_ERR;
}
m[0].msg_style = PAM_PROMPT_ECHO_OFF;
mesg[0] = (const struct pam_message *)m;
/* The following assignment might look a bit odd but is recommended in the
* pam_conv man page to make sure that the second argument of the PAM
* conversation function can be interpreted in two different ways.
* Basically it is important that both the actual struct pam_message and
* the pointers to the struct pam_message are arrays. Since the assignment
* makes clear that mesg[] and (*mesg)[] are arrays it should be kept this
* way and not be replaced by other equivalent assignments. */
if (ret != PAM_SUCCESS) {
return ret;
}
D(("response expected, but resp==NULL"));
return PAM_SYSTEM_ERR;
}
D(("Missing PIN."));
goto done;
}
D(("strndup failed"));
ret = PAM_BUF_ERR;
goto done;
}
if (ret != PAM_SUCCESS) {
D(("Failed to set PAM_USER with user name hint [%s]",
goto done;
}
if (ret != PAM_SUCCESS) {
D(("Failed to get PAM_USER with user name hint [%s]",
goto done;
}
}
} else {
&answer);
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return ret;
}
}
pi->pam_authtok_size=0;
} else {
cai->module_name, 0,
NULL, 0, &needed_size);
D(("sss_auth_pack_sc_blob failed."));
ret = PAM_BUF_ERR;
goto done;
}
D(("malloc failed."));
ret = PAM_BUF_ERR;
goto done;
}
cai->module_name, 0,
&needed_size);
D(("sss_auth_pack_sc_blob failed."));
ret = PAM_BUF_ERR;
goto done;
}
}
ret = PAM_SUCCESS;
done:
_pam_overwrite((void *)answer);
}
}
}
return ret;
}
{
int ret;
_("New Password: "),
_("Reenter new Password: "),
&answer);
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return ret;
}
} else {
_pam_overwrite((void *)answer);
return PAM_BUF_ERR;
}
}
return PAM_SUCCESS;
}
const char **domains)
{
char *ep;
*quiet_mode = false;
*flags |= FLAGS_FORWARD_PASS;
*flags |= FLAGS_USE_AUTHTOK;
*domains = "";
} else {
}
*retries = 0;
} else {
errno = 0;
if (errno != 0) {
*retries = 0;
}
if (*ep != '\0') {
"extra characters.");
*retries = 0;
}
if (*retries < 0) {
"be negative.");
*retries = 0;
}
}
*quiet_mode = true;
*flags |= FLAGS_USE_2FA;
*flags |= FLAGS_PROMPT_ALWAYS;
} else {
}
}
return;
}
{
int ret;
if ((flags & FLAGS_USE_FIRST_PASS)
&& !(flags & FLAGS_PROMPT_ALWAYS))) {
D(("option use_first_pass set, but no password found"));
return PAM_BUF_ERR;
}
} else {
if (flags & FLAGS_USE_2FA
if (pi->password_prompting) {
_("Second Factor (optional): "));
} else {
_("Second Factor: "));
}
/* Only one certificate */
} else {
if (ret != 0) {
D(("Failed to select certificate"));
return PAM_AUTHTOK_ERR;
}
}
} else {
}
if (ret != PAM_SUCCESS) {
D(("failed to get password from user"));
return ret;
}
if (flags & FLAGS_FORWARD_PASS) {
} else {
}
if (ret != PAM_SUCCESS) {
D(("Failed to set PAM_AUTHTOK [%s], "
"authtok may not be available for other modules",
}
}
}
return PAM_SUCCESS;
}
{
int pam_status;
int *authtok_type;
char *authtok_data;
(const void **) &authtok_type);
if (pam_status != PAM_SUCCESS) {
D(("pam_get_data failed."));
return EIO;
}
(const void **) &authtok_size);
if (pam_status != PAM_SUCCESS) {
D(("pam_get_data failed."));
return EIO;
}
(const void **) &authtok_data);
if (pam_status != PAM_SUCCESS) {
D(("pam_get_data failed."));
return EIO;
}
D(("malloc failed."));
return ENOMEM;
}
return 0;
}
{
int pam_status;
int *authtok_type;
char *authtok_data;
authtok_type = malloc(sizeof(int));
if (authtok_type == NULL) {
D(("malloc failed."));
return ENOMEM;
}
if (pam_status != PAM_SUCCESS) {
D(("pam_set_data failed."));
return EIO;
}
if (authtok_size == NULL) {
D(("malloc failed."));
return ENOMEM;
}
if (pam_status != PAM_SUCCESS) {
D(("pam_set_data failed."));
return EIO;
}
if (authtok_data == NULL) {
D(("malloc failed."));
return ENOMEM;
}
if (pam_status != PAM_SUCCESS) {
D(("pam_set_data failed."));
return EIO;
}
return 0;
}
int pam_flags)
{
int ret;
if (ret != PAM_SUCCESS) {
}
/* we query for the old password during PAM_PRELIM_CHECK to make
* pam_sss work e.g. with pam_cracklib */
if (pam_flags & PAM_PRELIM_CHECK) {
if (flags & FLAGS_USE_2FA
if (pi->password_prompting) {
_("Second Factor (optional): "));
} else {
_("Second Factor: "));
}
} else {
if (ret != PAM_SUCCESS) {
D(("failed to get password from user"));
return ret;
}
}
if (ret != PAM_SUCCESS) {
D(("Failed to set PAM_OLDAUTHTOK [%s], "
"oldauthtok may not be available",
return ret;
}
if (ret != 0) {
D(("Failed to store authtok data to pam handle. Password "
"change might fail."));
}
}
}
return PAM_SUCCESS;
}
if (getuid() != 0) {
D(("no password found for chauthtok"));
return PAM_BUF_ERR;
} else {
pi->pam_authtok_size = 0;
}
} else {
D(("strdup failed"));
return PAM_BUF_ERR;
}
}
}
if (flags & FLAGS_USE_AUTHTOK) {
D(("option use_authtok set, but no new password found"));
return PAM_BUF_ERR;
}
} else {
if (ret != PAM_SUCCESS) {
D(("failed to get new password from user"));
return ret;
}
if (flags & FLAGS_FORWARD_PASS) {
if (ret != PAM_SUCCESS) {
D(("Failed to set PAM_AUTHTOK [%s], "
"oldauthtok may not be available",
}
}
}
return PAM_SUCCESS;
}
bool quiet_mode)
{
int ret;
int pam_status;
char *login_token_name;
/* TODO: check multiple cert case */
D(("No certificate information available"));
return EINVAL;
}
if (login_token_name == NULL) {
return PAM_SUCCESS;
}
D(("malloc failed."));
return ENOMEM;
}
D(("snprintf failed."));
return EFAULT;
}
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
return ret;
} else {
}
if (pam_status != PAM_SUCCESS) {
D(("send_and_receive returned [%d] during pre-auth", pam_status));
/*
* Since we are waiting for the right Smartcard to be inserted errors
* can be ignored here.
*/
}
}
return PAM_SUCCESS;
}
{
int ret;
int pam_status;
const int *exp_data;
int *pw_exp_data;
bool retry = false;
bool quiet_mode = false;
int retries = 0;
D(("Hello pam_sssd: %#x", task));
/* Fail all authentication on misconfigured domains= parameter. The admin
* probably wanted to restrict authentication, so it's safer to fail */
return PAM_SYSTEM_ERR;
}
if (ret != PAM_SUCCESS) {
ret = PAM_IGNORE;
}
&& ret == PAM_AUTHINFO_UNAVAIL) {
ret = PAM_IGNORE;
}
return ret;
}
do {
retry = false;
switch(task) {
case SSS_PAM_AUTHENTICATE:
/*
* Only do preauth if
* - FLAGS_USE_FIRST_PASS is not set
* - no password is on the stack or FLAGS_PROMPT_ALWAYS is set
* - preauth indicator file exists.
*/
if ( !(flags & FLAGS_USE_FIRST_PASS)
|| (flags & FLAGS_PROMPT_ALWAYS))
if (pam_status != PAM_SUCCESS) {
D(("send_and_receive returned [%d] during pre-auth",
pam_status));
/*
* Since we are only interested in the result message
* and will always use password authentication
* as a fallback, errors can be ignored here.
*/
}
}
if (ret != PAM_SUCCESS) {
D(("check_login_token_name failed.\n"));
return ret;
}
}
if (ret != PAM_SUCCESS) {
D(("failed to get authentication token: %s",
return ret;
}
break;
case SSS_PAM_CHAUTHTOK:
/*
* Even if we only want to change the (long term) password
* there are cases where more than the password is needed to
* get the needed privileges in a backend to change the
* password.
*
* E.g. with mandatory 2-factor authentication we have to ask
* not only for the current password but for the second
* factor, e.g. the one-time token value, as well.
*
* The means the preauth step has to be done here as well but
* only if
* - PAM_PRELIM_CHECK is set
* - FLAGS_USE_FIRST_PASS is not set
* - no password is on the stack or FLAGS_PROMPT_ALWAYS is set
* - preauth indicator file exists.
*/
if ( (pam_flags & PAM_PRELIM_CHECK)
&& !(flags & FLAGS_USE_FIRST_PASS)
|| (flags & FLAGS_PROMPT_ALWAYS))
if (pam_status != PAM_SUCCESS) {
D(("send_and_receive returned [%d] during pre-auth",
pam_status));
/*
* Since we are only interested in the result message
* and will always use password authentication
* as a fallback, errors can be ignored here.
*/
}
}
if (ret != PAM_SUCCESS) {
D(("failed to get tokens for password change: %s",
return ret;
}
if (pam_flags & PAM_PRELIM_CHECK) {
/* We cannot validate the credentials with an OTP
* token value during PAM_PRELIM_CHECK because it
* would be invalid for the actual password change. So
* we are done. */
return PAM_SUCCESS;
}
}
break;
case SSS_PAM_ACCT_MGMT:
case SSS_PAM_SETCRED:
case SSS_PAM_OPEN_SESSION:
case SSS_PAM_CLOSE_SESSION:
break;
default:
D(("Illegal task [%#x]", task));
return PAM_SYSTEM_ERR;
}
&& pam_status == PAM_USER_UNKNOWN) {
}
&& pam_status == PAM_AUTHINFO_UNAVAIL) {
}
switch (task) {
case SSS_PAM_AUTHENTICATE:
/* We allow sssd to send the return code PAM_NEW_AUTHTOK_REQD during
* authentication, see sss_cli.h for details */
if (pam_status == PAM_NEW_AUTHTOK_REQD) {
D(("Authtoken expired, trying to change it"));
pw_exp_data = malloc(sizeof(int));
if (pw_exp_data == NULL) {
D(("malloc failed."));
break;
}
*pw_exp_data = 1;
if (pam_status != PAM_SUCCESS) {
D(("pam_set_data failed."));
}
}
break;
case SSS_PAM_ACCT_MGMT:
if (pam_status == PAM_SUCCESS &&
PAM_SUCCESS) {
_("Password expired. Change your password now."),
if (ret != PAM_SUCCESS) {
D(("do_pam_conversation failed."));
}
}
break;
case SSS_PAM_CHAUTHTOK:
if (ret != PAM_SUCCESS) {
D(("Failed to unset PAM_AUTHTOK [%s]",
}
if (ret != PAM_SUCCESS) {
D(("Failed to unset PAM_OLDAUTHTOK [%s]",
}
}
break;
case SSS_PAM_CHAUTHTOK_PRELIM:
getuid() == 0 &&
PAM_SUCCESS) {
if (ret != 0) {
D(("select_pw_reset_message failed.\n"));
}
}
default:
/* nothing to do */
break;
}
D(("retries [%d].", retries));
if (pam_status != PAM_SUCCESS &&
retries > 0) {
retry = true;
retries--;
if (ret != PAM_SUCCESS) {
D(("Failed to unset PAM_AUTHTOK [%s]",
}
if (ret != PAM_SUCCESS) {
D(("Failed to unset PAM_OLDAUTHTOK [%s]",
}
}
} while(retry);
return pam_status;
}
const char **argv )
{
}
const char **argv )
{
}
const char **argv )
{
}
const char **argv )
{
}
const char **argv )
{
}
const char **argv )
{
}
#ifdef PAM_STATIC
/* static module data */
"pam_sssd",
};
#endif