aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_listfile
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
commit09ec054e56b358aac224ea8cb6813365f556ab18 (patch)
tree0f4308d739ba104d1e5dd3eb78744273f80bf85e /modules/pam_listfile
parentb7fbd1ca8eb8f1648a1e36a4c65d10b0f636cc8a (diff)
downloadpam-09ec054e56b358aac224ea8cb6813365f556ab18.tar.gz
pam-09ec054e56b358aac224ea8cb6813365f556ab18.tar.bz2
pam-09ec054e56b358aac224ea8cb6813365f556ab18.zip
modules/pam_listfile: use pam_str_skip_prefix
* modules/pam_listfile/pam_listfile.c: Include "pam_inline.h". (pam_sm_authenticate): Use pam_str_skip_prefix instead of ugly strncmp invocations.
Diffstat (limited to 'modules/pam_listfile')
-rw-r--r--modules/pam_listfile/pam_listfile.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/pam_listfile/pam_listfile.c b/modules/pam_listfile/pam_listfile.c
index 1fe5f495..44e0655c 100644
--- a/modules/pam_listfile/pam_listfile.c
+++ b/modules/pam_listfile/pam_listfile.c
@@ -38,6 +38,7 @@
#include <security/_pam_macros.h>
#include <security/pam_modutil.h>
#include <security/pam_ext.h>
+#include "pam_inline.h"
/* --- authentication management functions (only) --- */
@@ -241,9 +242,9 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
}
if((citem == PAM_TTY) && citemp) {
/* Normalize the TTY name. */
- if(strncmp(citemp, "/dev/", 5) == 0) {
- citemp += 5;
- }
+ const char *str = pam_str_skip_prefix(citemp, "/dev/");
+ if (str != NULL)
+ citemp = str;
}
if(!citemp || (strlen(citemp) == 0)) {
@@ -322,7 +323,7 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
#endif
while((fgets(aline,sizeof(aline),inf) != NULL)
&& retval) {
- char *a = aline;
+ const char *a = aline;
if(strlen(aline) == 0)
continue;
@@ -333,8 +334,9 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
if(aline[strlen(aline) - 1] == '\r')
aline[strlen(aline) - 1] = '\0';
if(citem == PAM_TTY) {
- if(strncmp(a, "/dev/", 5) == 0)
- a += 5;
+ const char *str = pam_str_skip_prefix(a, "/dev/");
+ if (str != NULL)
+ a = str;
}
if (extitem == EI_GROUP) {
retval = !pam_modutil_user_in_group_nam_nam(pamh,