summaryrefslogtreecommitdiff
path: root/modules/pam_timestamp/pam_timestamp.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
commit15c568dc2fa87736d3f92b2e89d41ada04f89886 (patch)
tree6b6bf76539c50e24a8d934099846e6f72d17cde7 /modules/pam_timestamp/pam_timestamp.c
parent1e1d27de3d9cc68aa20c4df4ddf46965651359a7 (diff)
modules/pam_timestamp: use pam_str_skip_prefix
* modules/pam_timestamp/pam_timestamp.c: Include "pam_inline.h". (check_tty, get_timestamp_name, pam_sm_authenticate): Use pam_str_skip_prefix instead of ugly strncmp invocations.
Diffstat (limited to 'modules/pam_timestamp/pam_timestamp.c')
-rw-r--r--modules/pam_timestamp/pam_timestamp.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/pam_timestamp/pam_timestamp.c b/modules/pam_timestamp/pam_timestamp.c
index d6a04a50..9790fde0 100644
--- a/modules/pam_timestamp/pam_timestamp.c
+++ b/modules/pam_timestamp/pam_timestamp.c
@@ -65,6 +65,7 @@
#include <security/_pam_macros.h>
#include <security/pam_ext.h>
#include <security/pam_modutil.h>
+#include "pam_inline.h"
/* The default timeout we use is 5 minutes, which matches the sudo default
* for the timestamp_timeout parameter. */
@@ -151,7 +152,7 @@ check_tty(const char *tty)
}
/* Pull out the meaningful part of the tty's name. */
if (strchr(tty, '/') != NULL) {
- if (strncmp(tty, "/dev/", 5) != 0) {
+ if (pam_str_skip_prefix(tty, "/dev/") == NULL) {
/* Make sure the device node is actually in /dev/,
* noted by Michal Zalewski. */
return NULL;
@@ -282,8 +283,10 @@ get_timestamp_name(pam_handle_t *pamh, int argc, const char **argv,
}
}
for (i = 0; i < argc; i++) {
- if (strncmp(argv[i], "timestampdir=", 13) == 0) {
- tdir = argv[i] + 13;
+ const char *str;
+
+ if ((str = pam_str_skip_prefix(argv[i], "timestampdir=")) != NULL) {
+ tdir = str;
if (debug) {
pam_syslog(pamh, LOG_DEBUG,
"storing timestamps in `%s'",
@@ -377,8 +380,10 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv)
}
}
for (i = 0; i < argc; i++) {
- if (strncmp(argv[i], "timestamp_timeout=", 18) == 0) {
- tmp = strtol(argv[i] + 18, &p, 0);
+ const char *str;
+
+ if ((str = pam_str_skip_prefix(argv[i], "timestamp_timeout=")) != NULL) {
+ tmp = strtol(str, &p, 0);
if ((p != NULL) && (*p == '\0')) {
interval = tmp;
if (debug) {