From: Rahul Sandhu <nvraxn@gmail.com>
To: selinux@vger.kernel.org
Cc: Rahul Sandhu <nvraxn@gmail.com>
Subject: [PATCH] default_contexts: introduce PAM stacks
Date: Tue, 7 Oct 2025 20:28:08 +0100 [thread overview]
Message-ID: <20251007192808.514297-1-nvraxn@gmail.com> (raw)
This allows a default_contexts entry to only be matched for a given PAM
stack. This feature isn't implemented by us in this commit, though it
may be in the future should it prove useful for `pam_selinux`.
Signed-off-by: Rahul Sandhu <nvraxn@gmail.com>
---
libselinux/man/man5/default_contexts.5 | 8 +++++++-
libselinux/src/get_context_list.c | 6 ++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/libselinux/man/man5/default_contexts.5 b/libselinux/man/man5/default_contexts.5
index f63d24a0..49ebbd25 100644
--- a/libselinux/man/man5/default_contexts.5
+++ b/libselinux/man/man5/default_contexts.5
@@ -35,7 +35,7 @@ Where \fI{SELINUXTYPE}\fR is the entry from the selinux configuration file \fIco
.SH "FILE FORMAT"
Each line in the default configuration file consists of the following:
.RS
-.I login_process user_login_process [user_login_process] ...
+.I login_process user_login_process [user_login_process] ... <pam_stack>
.RE
.sp
Where:
@@ -48,6 +48,10 @@ This consists of a \fIrole\fB:\fItype\fR[\fB:\fIrange\fR] entry that represents
.RS
This consists of one or more \fIrole\fB:\fItype\fR[\fB:\fIrange\fR] entries that represent the user login process context defined in the policy.
.RE
+.I pam_stack
+.RS
+This consists of a name for a PAM stack required for a match. All PAM stacks must be enclosed in quotes, else they will be treated as a \fIuser_login_process\fR.
+.RE
.RE
.
.SH "EXAMPLE"
@@ -64,6 +68,8 @@ system_r:sshd_t:s0 user_r:user_t:s0
system_r:sulogin_t:s0 sysadm_r:sysadm_t:s0
.br
system_r:xdm_t:s0 user_r:user_t:s0
+.br
+system_r:xdm_t:s0 user_r:user_t:s0 "login"
.
.SH "SEE ALSO"
.ad l
diff --git a/libselinux/src/get_context_list.c b/libselinux/src/get_context_list.c
index 0f3bdc5c..8e9c5bc2 100644
--- a/libselinux/src/get_context_list.c
+++ b/libselinux/src/get_context_list.c
@@ -165,6 +165,12 @@ static int get_context_user(FILE * fp,
if (line[len - 1] == '\n')
line[len - 1] = 0;
+ /* This line requires a pam stack to be matched, which we don't handle. */
+ if (strchr(line, '"')) {
+ found = 0;
+ continue;
+ }
+
/* Skip leading whitespace. */
start = line;
while (*start && isspace((unsigned char)*start))
--
2.50.1
next reply other threads:[~2025-10-07 19:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 19:28 Rahul Sandhu [this message]
2025-10-08 0:05 ` [PATCH v2] default_contexts: introduce PAM stacks Rahul Sandhu
2025-10-08 13:26 ` Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251007192808.514297-1-nvraxn@gmail.com \
--to=nvraxn@gmail.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).