diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2020-03-17 21:29:24 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2020-03-19 18:40:16 +0000 |
commit | 3130acba872c2645d2effa11cc80d1f6bfa59858 (patch) | |
tree | 32a40c306b545903d1154447fc956f9b85e4cf08 | |
parent | a512eaaf4d6334976e071bf7f57be866f1c42f6c (diff) | |
download | pam-3130acba872c2645d2effa11cc80d1f6bfa59858.tar.gz pam-3130acba872c2645d2effa11cc80d1f6bfa59858.tar.bz2 pam-3130acba872c2645d2effa11cc80d1f6bfa59858.zip |
modules/pam_pwhistory: use pam_str_skip_icase_prefix
* modules/pam_pwhistory/pam_pwhistory.c: Include "pam_inline.h".
(parse_option): Use pam_str_skip_icase_prefix instead of ugly
strncasecmp invocations.
-rw-r--r-- | modules/pam_pwhistory/pam_pwhistory.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/pam_pwhistory/pam_pwhistory.c b/modules/pam_pwhistory/pam_pwhistory.c index 3efb0ca5..2d4507d5 100644 --- a/modules/pam_pwhistory/pam_pwhistory.c +++ b/modules/pam_pwhistory/pam_pwhistory.c @@ -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); |