From 40bcefca56fe98fab2f28a73ef19979dc1bbcc64 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 16 Mar 2020 21:02:18 +0000 Subject: modules/pam_mail: use pam_str_skip_prefix * modules/pam_mail/pam_mail.c: Include "pam_inline.h". (_pam_parse): Use pam_str_skip_prefix instead of ugly strncmp invocations. --- modules/pam_mail/pam_mail.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/pam_mail') diff --git a/modules/pam_mail/pam_mail.c b/modules/pam_mail/pam_mail.c index 703c93cb..2439ae75 100644 --- a/modules/pam_mail/pam_mail.c +++ b/modules/pam_mail/pam_mail.c @@ -44,6 +44,7 @@ #include #include #include +#include "pam_inline.h" /* argument parsing */ @@ -77,6 +78,7 @@ _pam_parse (const pam_handle_t *pamh, int flags, int argc, /* step through arguments */ for (; argc-- > 0; ++argv) { + const char *str; /* generic options */ @@ -86,8 +88,8 @@ _pam_parse (const pam_handle_t *pamh, int flags, int argc, ctrl |= PAM_QUIET_MAIL; else if (!strcmp(*argv,"standard")) ctrl |= PAM_STANDARD_MAIL | PAM_EMPTY_TOO; - else if (!strncmp(*argv,"dir=",4)) { - *maildir = 4 + *argv; + else if ((str = pam_str_skip_prefix(*argv, "dir=")) != NULL) { + *maildir = str; if (**maildir != '\0') { D(("new mail directory: %s", *maildir)); ctrl |= PAM_NEW_MAIL_DIR; @@ -95,9 +97,9 @@ _pam_parse (const pam_handle_t *pamh, int flags, int argc, pam_syslog(pamh, LOG_ERR, "dir= specification missing argument - ignored"); } - } else if (!strncmp(*argv,"hash=",5)) { + } else if ((str = pam_str_skip_prefix(*argv, "hash=")) != NULL) { char *ep = NULL; - *hashcount = strtoul(*argv+5,&ep,10); + *hashcount = strtoul(str,&ep,10); if (!ep) { *hashcount = 0; } -- cgit v1.2.3