summaryrefslogtreecommitdiff
path: root/modules/pam_pwhistory/pam_pwhistory.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_pwhistory/pam_pwhistory.c')
-rw-r--r--modules/pam_pwhistory/pam_pwhistory.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/modules/pam_pwhistory/pam_pwhistory.c b/modules/pam_pwhistory/pam_pwhistory.c
index 3efb0ca5..cf4fc078 100644
--- a/modules/pam_pwhistory/pam_pwhistory.c
+++ b/modules/pam_pwhistory/pam_pwhistory.c
@@ -1,4 +1,6 @@
/*
+ * pam_pwhistory module
+ *
* Copyright (c) 2008, 2012 Thorsten Kukuk
* Author: Thorsten Kukuk <kukuk@thkukuk.de>
*
@@ -38,8 +40,6 @@
#include <config.h>
#endif
-#define PAM_SM_PASSWORD
-
#include <pwd.h>
#include <errno.h>
#include <stdio.h>
@@ -57,6 +57,7 @@
#include <security/_pam_macros.h>
#include "opasswd.h"
+#include "pam_inline.h"
#define DEFAULT_BUFLEN 2048
@@ -72,6 +73,8 @@ typedef struct options_t options_t;
static void
parse_option (pam_handle_t *pamh, const char *argv, options_t *options)
{
+ const char *str;
+
if (strcasecmp (argv, "try_first_pass") == 0)
/* ignore */;
else if (strcasecmp (argv, "use_first_pass") == 0)
@@ -80,23 +83,23 @@ parse_option (pam_handle_t *pamh, const char *argv, options_t *options)
/* ignore, handled by pam_get_authtok */;
else if (strcasecmp (argv, "debug") == 0)
options->debug = 1;
- else if (strncasecmp (argv, "remember=", 9) == 0)
+ else if ((str = pam_str_skip_icase_prefix(argv, "remember=")) != NULL)
{
- options->remember = strtol(&argv[9], NULL, 10);
+ options->remember = strtol(str, NULL, 10);
if (options->remember < 0)
options->remember = 0;
if (options->remember > 400)
options->remember = 400;
}
- else if (strncasecmp (argv, "retry=", 6) == 0)
+ else if ((str = pam_str_skip_icase_prefix(argv, "retry=")) != NULL)
{
- options->tries = strtol(&argv[6], NULL, 10);
+ options->tries = strtol(str, NULL, 10);
if (options->tries < 0)
options->tries = 1;
}
else if (strcasecmp (argv, "enforce_for_root") == 0)
options->enforce_for_root = 1;
- else if (strncasecmp (argv, "authtok_type=", 13) == 0)
+ else if (pam_str_skip_icase_prefix(argv, "authtok_type=") != NULL)
{ /* ignore, for pam_get_authtok */; }
else
pam_syslog (pamh, LOG_ERR, "pam_pwhistory: unknown option: %s", argv);
@@ -136,15 +139,6 @@ pam_sm_chauthtok (pam_handle_t *pamh, int flags, int argc, const char **argv)
if (retval != PAM_SUCCESS)
return retval;
- if (user == NULL || strlen (user) == 0)
- {
- if (options.debug)
- pam_syslog (pamh, LOG_DEBUG,
- "User is not known to system");
-
- return PAM_USER_UNKNOWN;
- }
-
if (flags & PAM_PRELIM_CHECK)
{
if (options.debug)