summaryrefslogtreecommitdiff
path: root/modules/pam_selinux
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-03-18 00:03:01 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-03-19 18:40:16 +0000
commitee095e598304d5b251b332f10349f74f6a25e197 (patch)
tree31c0f9a911457706da0573a22a61d86b2c2d5427 /modules/pam_selinux
parenta9781a918441666a25636879801f45538422d475 (diff)
modules/pam_selinux: use pam_str_skip_prefix
* modules/pam_selinux/pam_selinux.c: Include "pam_inline.h". (compute_exec_context, compute_tty_context): Use pam_str_skip_prefix instead of ugly strncmp invocations.
Diffstat (limited to 'modules/pam_selinux')
-rw-r--r--modules/pam_selinux/pam_selinux.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/pam_selinux/pam_selinux.c b/modules/pam_selinux/pam_selinux.c
index 827f5942..6537c735 100644
--- a/modules/pam_selinux/pam_selinux.c
+++ b/modules/pam_selinux/pam_selinux.c
@@ -60,6 +60,7 @@
#include <security/_pam_macros.h>
#include <security/pam_modutil.h>
#include <security/pam_ext.h>
+#include "pam_inline.h"
#include <selinux/selinux.h>
#include <selinux/get_context_list.h>
@@ -518,7 +519,8 @@ compute_tty_context(const pam_handle_t *pamh, module_data_t *data)
{
const char *tty = get_item(pamh, PAM_TTY);
- if (!tty || !*tty || !strcmp(tty, "ssh") || !strncmp(tty, "NODEV", 5)) {
+ if (!tty || !*tty || !strcmp(tty, "ssh")
+ || pam_str_skip_prefix(tty, "NODEV") != NULL) {
tty = ttyname(STDIN_FILENO);
if (!tty || !*tty)
tty = ttyname(STDOUT_FILENO);
@@ -528,7 +530,7 @@ compute_tty_context(const pam_handle_t *pamh, module_data_t *data)
return PAM_SUCCESS;
}
- if (strncmp("/dev/", tty, 5)) {
+ if (pam_str_skip_prefix(tty, "/dev/") == NULL) {
if (asprintf(&data->tty_path, "%s%s", "/dev/", tty) < 0)
data->tty_path = NULL;
} else {