summaryrefslogtreecommitdiff
path: root/modules/pam_nologin/pam_nologin.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-03-16 21:02:18 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-03-19 18:40:16 +0000
commit83d378e6cc1635621803d2adc613378bd3847dd0 (patch)
tree955cb843f4044cc074cb7451de76a6e5f88b1dab /modules/pam_nologin/pam_nologin.c
parenteeeb5519f8e475fe9b32805a7ea0e610fef67fbe (diff)
modules/pam_nologin: use pam_str_skip_prefix
* modules/pam_nologin/pam_nologin.c: Include "pam_inline.h". (parse_args): Use pam_str_skip_prefix instead of ugly strncmp invocations.
Diffstat (limited to 'modules/pam_nologin/pam_nologin.c')
-rw-r--r--modules/pam_nologin/pam_nologin.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/pam_nologin/pam_nologin.c b/modules/pam_nologin/pam_nologin.c
index 56897670..775dda87 100644
--- a/modules/pam_nologin/pam_nologin.c
+++ b/modules/pam_nologin/pam_nologin.c
@@ -32,6 +32,7 @@
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
#include <security/pam_ext.h>
+#include "pam_inline.h"
#define DEFAULT_NOLOGIN_PATH "/var/run/nologin"
#define COMPAT_NOLOGIN_PATH "/etc/nologin"
@@ -54,10 +55,12 @@ parse_args(pam_handle_t *pamh, int argc, const char **argv, struct opt_s *opts)
opts->retval_when_nofile = PAM_IGNORE;
for (i=0; i<argc; ++i) {
+ const char *str;
+
if (!strcmp("successok", argv[i])) {
opts->retval_when_nofile = PAM_SUCCESS;
- } else if (!strncmp("file=", argv[i], 5)) {
- opts->nologin_file = argv[i] + 5;
+ } else if ((str = pam_str_skip_prefix(argv[i], "file=")) != NULL) {
+ opts->nologin_file = str;
} else {
pam_syslog(pamh, LOG_ERR, "unknown option: %s", argv[i]);
}