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 | 1205c0e828eedebeac22eb52894c5c436264c638 (patch) | |
tree | 2fd98c34a891bd34cdb960a387ecbed4b8879f9c /modules/pam_userdb/pam_userdb.c | |
parent | a61b015d85aca655ed355f7ebe94f6eb7b19a74b (diff) | |
download | pam-1205c0e828eedebeac22eb52894c5c436264c638.tar.gz pam-1205c0e828eedebeac22eb52894c5c436264c638.tar.bz2 pam-1205c0e828eedebeac22eb52894c5c436264c638.zip |
modules/pam_userdb: use pam_str_skip_icase_prefix
* modules/pam_userdb/pam_userdb.c: Include "pam_inline.h".
(_pam_parse, user_lookup): Use pam_str_skip_icase_prefix
instead of ugly strncasecmp invocations.
Diffstat (limited to 'modules/pam_userdb/pam_userdb.c')
-rw-r--r-- | modules/pam_userdb/pam_userdb.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c index cab37b30..32e759e3 100644 --- a/modules/pam_userdb/pam_userdb.c +++ b/modules/pam_userdb/pam_userdb.c @@ -50,6 +50,7 @@ #include <security/pam_modules.h> #include <security/pam_ext.h> #include <security/_pam_macros.h> +#include "pam_inline.h" /* * Conversation function to obtain the user's password @@ -97,6 +98,8 @@ _pam_parse (pam_handle_t *pamh, int argc, const char **argv, /* step through arguments */ for (ctrl = 0; argc-- > 0; ++argv) { + const char *str; + /* generic options */ if (!strcmp(*argv,"debug")) @@ -113,18 +116,18 @@ _pam_parse (pam_handle_t *pamh, int argc, const char **argv, ctrl |= PAM_USE_FPASS_ARG; else if (!strcasecmp(*argv, "try_first_pass")) ctrl |= PAM_TRY_FPASS_ARG; - else if (!strncasecmp(*argv,"db=", 3)) + else if ((str = pam_str_skip_icase_prefix(*argv, "db=")) != NULL) { - *database = (*argv) + 3; + *database = str; if (**database == '\0') { *database = NULL; pam_syslog(pamh, LOG_ERR, "db= specification missing argument - ignored"); } } - else if (!strncasecmp(*argv,"crypt=", 6)) + else if ((str = pam_str_skip_icase_prefix(*argv, "crypt=")) != NULL) { - *cryptmode = (*argv) + 6; + *cryptmode = str; if (**cryptmode == '\0') pam_syslog(pamh, LOG_ERR, "crypt= specification missing argument - ignored"); @@ -209,7 +212,7 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode, return 0; /* found it, data contents don't matter */ } - if (cryptmode && strncasecmp(cryptmode, "crypt", 5) == 0) { + if (cryptmode && pam_str_skip_icase_prefix(cryptmode, "crypt") != NULL) { /* crypt(3) password storage */ @@ -260,7 +263,7 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode, compare = strncmp(data.dptr, pass, data.dsize); } - if (cryptmode && strncasecmp(cryptmode, "none", 4) + if (cryptmode && pam_str_skip_icase_prefix(cryptmode, "none") == NULL && (ctrl & PAM_DEBUG_ARG)) { pam_syslog(pamh, LOG_INFO, "invalid value for crypt parameter: %s", cryptmode); |