Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ respectively.
cainfo::
Option to allow usage of a CA bundle instead of path.

prompt::
Specifies the prompt that PAM should display when prompting for the
OTP token. If not specified "YubiKey for `%s': " is used.

proxy::
specify a proxy to connect to the validation server. Valid schemes are
http://, https://, socks4://, socks4a://, socks5:// or socks5h://.
Expand Down
17 changes: 15 additions & 2 deletions pam_yubico.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct cfg
const char *capath;
const char *cainfo;
const char *proxy;
const char *prompt;
const char *url;
const char *urllist;
const char *ldapserver;
Expand Down Expand Up @@ -838,6 +839,8 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
cfg->cainfo = argv[i] + 7;
if (strncmp (argv[i], "proxy=", 6) == 0)
cfg->proxy = argv[i] + 6;
if (strncmp (argv[i], "prompt=", 7) == 0)
cfg->prompt = argv[i] + 7;
if (strncmp (argv[i], "url=", 4) == 0)
cfg->url = argv[i] + 4;
if (strncmp (argv[i], "urllist=", 8) == 0)
Expand Down Expand Up @@ -935,6 +938,7 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
DBG ("urllist=%s", cfg->urllist ? cfg->urllist : "(null)");
DBG ("capath=%s", cfg->capath ? cfg->capath : "(null)");
DBG ("cainfo=%s", cfg->cainfo ? cfg->cainfo : "(null)");
DBG ("prompt=%s", cfg->prompt ? cfg->prompt : "(null)");
DBG ("proxy=%s", cfg->proxy ? cfg->proxy : "(null)");
DBG ("token_id_length=%u", cfg->token_id_length);
DBG ("mode=%s", cfg->mode == CLIENT ? "client" : "chresp" );
Expand Down Expand Up @@ -1140,7 +1144,12 @@ pam_sm_authenticate (pam_handle_t * pamh,
pmsg[0] = &msg[0];
{
#define QUERY_TEMPLATE "YubiKey for `%s': "
size_t len = strlen (QUERY_TEMPLATE) + strlen (user);
size_t len = strlen (user);
if (cfg->prompt != NULL) {
len += strlen (cfg->prompt);
} else {
len += strlen (QUERY_TEMPLATE);
}
int wrote;

msg[0].msg = malloc (len);
Expand All @@ -1150,7 +1159,11 @@ pam_sm_authenticate (pam_handle_t * pamh,
goto done;
}

wrote = snprintf ((char *) msg[0].msg, len, QUERY_TEMPLATE, user);
if (cfg->prompt != NULL) {
wrote = snprintf ((char *) msg[0].msg, len, cfg->prompt, user);
} else {
wrote = snprintf ((char *) msg[0].msg, len, QUERY_TEMPLATE, user);
}
if (wrote < 0 || wrote >= len)
{
retval = PAM_BUF_ERR;
Expand Down