mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-02-22 00:54:30 +01:00
Add deprecated support for old ldapserver keyword.
This commit is contained in:
parent
fb752ec959
commit
adcf7e2c4e
5
NEWS
5
NEWS
@ -2,6 +2,11 @@ pam_yubico NEWS -- History of user-visible changes. -*- outline -*-
|
|||||||
|
|
||||||
* Version 2.3 (unreleased)
|
* Version 2.3 (unreleased)
|
||||||
|
|
||||||
|
** New keyword "ldap_uri" added.
|
||||||
|
This keyword is preferred over the old "ldapserver" keyword, and
|
||||||
|
allows you to specify a complete LDAP URI instead of only the hostname
|
||||||
|
of your LDAP server. Contributed by Zubrick.
|
||||||
|
|
||||||
* Version 2.2 (released 2009-05-11)
|
* Version 2.2 (released 2009-05-11)
|
||||||
|
|
||||||
** Added new PAM configuration variable "key" for base64 client key.
|
** Added new PAM configuration variable "key" for base64 client key.
|
||||||
|
39
pam_yubico.c
39
pam_yubico.c
@ -195,7 +195,7 @@ authorize_user_token (const char *authfile,
|
|||||||
* remote host.
|
* remote host.
|
||||||
*
|
*
|
||||||
* You need the following parameters in you pam config:
|
* You need the following parameters in you pam config:
|
||||||
* ldap_uri=
|
* ldapserver= OR ldap_uri=
|
||||||
* ldapdn=
|
* ldapdn=
|
||||||
* user_attr=
|
* user_attr=
|
||||||
* yubi_attr=
|
* yubi_attr=
|
||||||
@ -203,8 +203,11 @@ authorize_user_token (const char *authfile,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
authorize_user_token_ldap (const char *ldap_uri,
|
authorize_user_token_ldap (const char *ldap_uri,
|
||||||
const char *ldapdn, const char *user_attr,
|
const char *ldapserver,
|
||||||
const char *yubi_attr, const char *user,
|
const char *ldapdn,
|
||||||
|
const char *user_attr,
|
||||||
|
const char *yubi_attr,
|
||||||
|
const char *user,
|
||||||
const char *token_id)
|
const char *token_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -244,11 +247,20 @@ authorize_user_token_ldap (const char *ldap_uri,
|
|||||||
D(("sr: %s",sr));
|
D(("sr: %s",sr));
|
||||||
|
|
||||||
/* Get a handle to an LDAP connection. */
|
/* Get a handle to an LDAP connection. */
|
||||||
rc = ldap_initialize (&ld,ldap_uri);
|
if (ldap_uri)
|
||||||
if (rc != LDAP_SUCCESS)
|
|
||||||
{
|
{
|
||||||
D (("ldap_init: %s", ldap_err2string (rc)));
|
rc = ldap_initialize (&ld,ldap_uri);
|
||||||
return (0);
|
if (rc != LDAP_SUCCESS)
|
||||||
|
{
|
||||||
|
D (("ldap_init: %s", ldap_err2string (rc)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((ld = ldap_init (ldapserver, PORT_NUMBER)) == NULL)
|
||||||
|
D (("ldap_init"));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind anonymously to the LDAP server. */
|
/* Bind anonymously to the LDAP server. */
|
||||||
@ -325,6 +337,7 @@ struct cfg
|
|||||||
int use_first_pass;
|
int use_first_pass;
|
||||||
char *auth_file;
|
char *auth_file;
|
||||||
char *url;
|
char *url;
|
||||||
|
char *ldapserver;
|
||||||
char *ldap_uri;
|
char *ldap_uri;
|
||||||
char *ldapdn;
|
char *ldapdn;
|
||||||
char *user_attr;
|
char *user_attr;
|
||||||
@ -343,6 +356,7 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
|||||||
cfg->use_first_pass = 0;
|
cfg->use_first_pass = 0;
|
||||||
cfg->auth_file = NULL;
|
cfg->auth_file = NULL;
|
||||||
cfg->url = NULL;
|
cfg->url = NULL;
|
||||||
|
cfg->ldapserver = NULL;
|
||||||
cfg->ldap_uri = NULL;
|
cfg->ldap_uri = NULL;
|
||||||
cfg->ldapdn = NULL;
|
cfg->ldapdn = NULL;
|
||||||
cfg->user_attr = NULL;
|
cfg->user_attr = NULL;
|
||||||
@ -366,6 +380,8 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
|||||||
cfg->auth_file = (char *) argv[i] + 9;
|
cfg->auth_file = (char *) argv[i] + 9;
|
||||||
if (strncmp (argv[i], "url=", 4) == 0)
|
if (strncmp (argv[i], "url=", 4) == 0)
|
||||||
cfg->url = (char *) argv[i] + 4;
|
cfg->url = (char *) argv[i] + 4;
|
||||||
|
if (strncmp (argv[i], "ldapserver=", 11) == 0)
|
||||||
|
cfg->ldapserver = (char *) argv[i] + 11;
|
||||||
if (strncmp (argv[i], "ldap_uri=", 9) == 0)
|
if (strncmp (argv[i], "ldap_uri=", 9) == 0)
|
||||||
cfg->ldap_uri = (char *) argv[i] + 9;
|
cfg->ldap_uri = (char *) argv[i] + 9;
|
||||||
if (strncmp (argv[i], "ldapdn=", 7) == 0)
|
if (strncmp (argv[i], "ldapdn=", 7) == 0)
|
||||||
@ -389,6 +405,7 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
|||||||
D (("try_first_pass=%d", cfg->try_first_pass));
|
D (("try_first_pass=%d", cfg->try_first_pass));
|
||||||
D (("use_first_pass=%d", cfg->use_first_pass));
|
D (("use_first_pass=%d", cfg->use_first_pass));
|
||||||
D (("authfile=%s", cfg->auth_file ? cfg->auth_file : "(null)"));
|
D (("authfile=%s", cfg->auth_file ? cfg->auth_file : "(null)"));
|
||||||
|
D (("ldapserver=%s", cfg->ldapserver ? cfg->ldapserver : "(null)"));
|
||||||
D (("ldap_uri=%s", cfg->ldap_uri ? cfg->ldap_uri : "(null)"));
|
D (("ldap_uri=%s", cfg->ldap_uri ? cfg->ldap_uri : "(null)"));
|
||||||
D (("ldapdn=%s", cfg->ldapdn ? cfg->ldapdn : "(null)"));
|
D (("ldapdn=%s", cfg->ldapdn ? cfg->ldapdn : "(null)"));
|
||||||
D (("user_attr=%s", cfg->user_attr ? cfg->user_attr : "(null)"));
|
D (("user_attr=%s", cfg->user_attr ? cfg->user_attr : "(null)"));
|
||||||
@ -567,10 +584,10 @@ pam_sm_authenticate (pam_handle_t * pamh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* authorize the user with supplied token id */
|
/* authorize the user with supplied token id */
|
||||||
if (cfg.ldap_uri != NULL)
|
if (cfg.ldapserver != NULL || cfg.ldap_uri != NULL)
|
||||||
valid_token = authorize_user_token_ldap (cfg.ldap_uri, cfg.ldapdn,
|
valid_token = authorize_user_token_ldap (cfg.ldap_uri, cfg.ldapserver,
|
||||||
cfg.user_attr, cfg.yubi_attr,
|
cfg.ldapdn, cfg.user_attr,
|
||||||
user, otp_id);
|
cfg.yubi_attr, user, otp_id);
|
||||||
else
|
else
|
||||||
valid_token = authorize_user_token (cfg.auth_file, user, otp_id);
|
valid_token = authorize_user_token (cfg.auth_file, user, otp_id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user