From: Rahul Sandhu <nvraxn@gmail.com>
To: nvraxn@gmail.com
Cc: selinux@vger.kernel.org
Subject: [PATCH v2] default_contexts: introduce PAM stacks
Date: Wed, 8 Oct 2025 01:05:49 +0100 [thread overview]
Message-ID: <20251008000549.539392-1-nvraxn@gmail.com> (raw)
In-Reply-To: <20251007192808.514297-1-nvraxn@gmail.com>
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 | 4 ++++
2 files changed, 11 insertions(+), 1 deletion(-)
v2: no need to set found to 0, it's already initalised as that. not
sure what I was thinking...
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..331a26d8 100644
--- a/libselinux/src/get_context_list.c
+++ b/libselinux/src/get_context_list.c
@@ -165,6 +165,10 @@ 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, '"'))
+ continue;
+
/* Skip leading whitespace. */
start = line;
while (*start && isspace((unsigned char)*start))
--
2.50.1
next prev parent reply other threads:[~2025-10-08 0:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 19:28 [PATCH] default_contexts: introduce PAM stacks Rahul Sandhu
2025-10-08 0:05 ` Rahul Sandhu [this message]
2025-10-08 13:26 ` [PATCH v2] " Stephen Smalley
[not found] <CAEjxPJ5 P23pREOYr7nz0OyFQb04Pz1fNaNB0_9Qn52aLQqrAQ@mail.gmail.com>
2025-10-14 8:44 ` Rahul Sandhu
2025-10-14 12:36 ` 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=20251008000549.539392-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).