|
|
5501fb |
From f1480aa0c228107a22664e6302c6f2b388536ece Mon Sep 17 00:00:00 2001
|
|
|
5501fb |
From: rwmjones <rjones@redhat.com>
|
|
|
5501fb |
Date: Thu, 6 Oct 2022 12:15:56 +0100
|
|
|
5501fb |
Subject: [PATCH 9/9] semanage: Fix parsing of ignoredirs (#758)
|
|
|
5501fb |
|
|
|
5501fb |
From /etc/selinux/semanage.conf from a RHEL 9.1 system, this line
|
|
|
5501fb |
caused problems:
|
|
|
5501fb |
|
|
|
5501fb |
ignoredirs=/root;/bin;/boot;/dev;/etc [...]
|
|
|
5501fb |
|
|
|
5501fb |
Parse this as a list of modified Rx.fspath, generating a tree like:
|
|
|
5501fb |
|
|
|
5501fb |
/files/etc/selinux/semanage.conf/ignoredirs/1 = /root
|
|
|
5501fb |
/files/etc/selinux/semanage.conf/ignoredirs/2 = /bin
|
|
|
5501fb |
/files/etc/selinux/semanage.conf/ignoredirs/3 = /dev
|
|
|
5501fb |
/files/etc/selinux/semanage.conf/ignoredirs/4 = /etc
|
|
|
5501fb |
[...]
|
|
|
5501fb |
|
|
|
5501fb |
Also this adds the RHEL 9 file as another test case and adjusts the
|
|
|
5501fb |
output of the existing test case.
|
|
|
5501fb |
|
|
|
5501fb |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2077120
|
|
|
5501fb |
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
5501fb |
|
|
|
5501fb |
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
5501fb |
(cherry picked from commit a3ba6e2d32b95507e2474a219e788ac3d54bc4a1)
|
|
|
5501fb |
---
|
|
|
5501fb |
lenses/semanage.aug | 7 +++-
|
|
|
5501fb |
lenses/tests/test_semanage.aug | 4 +-
|
|
|
5501fb |
tests/root/etc/selinux/semanage.conf | 60 ++++++++++++++++++++++++++++
|
|
|
5501fb |
tests/xpath.tests | 1 +
|
|
|
5501fb |
4 files changed, 70 insertions(+), 2 deletions(-)
|
|
|
5501fb |
create mode 100644 tests/root/etc/selinux/semanage.conf
|
|
|
5501fb |
|
|
|
5501fb |
diff --git a/lenses/semanage.aug b/lenses/semanage.aug
|
|
|
5501fb |
index 46f93b32..edd97131 100644
|
|
|
5501fb |
--- a/lenses/semanage.aug
|
|
|
5501fb |
+++ b/lenses/semanage.aug
|
|
|
5501fb |
@@ -23,7 +23,12 @@ let sep = IniFile.sep "=" "="
|
|
|
5501fb |
let empty = IniFile.empty
|
|
|
5501fb |
let eol = IniFile.eol
|
|
|
5501fb |
|
|
|
5501fb |
-let entry = IniFile.entry IniFile.entry_re sep comment
|
|
|
5501fb |
+let list_keys = "ignoredirs"
|
|
|
5501fb |
+let scl = del ";" ";"
|
|
|
5501fb |
+let fspath = /[^ \t\n;#]+/ (* Rx.fspath without ; or # *)
|
|
|
5501fb |
+
|
|
|
5501fb |
+let entry = IniFile.entry_list list_keys sep fspath scl comment
|
|
|
5501fb |
+ | IniFile.entry (IniFile.entry_re - list_keys) sep comment
|
|
|
5501fb |
| empty
|
|
|
5501fb |
|
|
|
5501fb |
let title = IniFile.title_label "@group" (IniFile.record_re - /^end$/)
|
|
|
5501fb |
diff --git a/lenses/tests/test_semanage.aug b/lenses/tests/test_semanage.aug
|
|
|
5501fb |
index a6ceaca0..f76b95f3 100644
|
|
|
5501fb |
--- a/lenses/tests/test_semanage.aug
|
|
|
5501fb |
+++ b/lenses/tests/test_semanage.aug
|
|
|
5501fb |
@@ -68,7 +68,9 @@ test Semanage.lns get conf =
|
|
|
5501fb |
{ "usepasswd" = "False" }
|
|
|
5501fb |
{ "bzip-small" = "true" }
|
|
|
5501fb |
{ "bzip-blocksize" = "5" }
|
|
|
5501fb |
- { "ignoredirs" = "/root" }
|
|
|
5501fb |
+ { "ignoredirs"
|
|
|
5501fb |
+ { "1" = "/root" }
|
|
|
5501fb |
+ }
|
|
|
5501fb |
{ }
|
|
|
5501fb |
{ "@group" = "sefcontext_compile"
|
|
|
5501fb |
{ "path" = "/usr/sbin/sefcontext_compile" }
|
|
|
5501fb |
diff --git a/tests/root/etc/selinux/semanage.conf b/tests/root/etc/selinux/semanage.conf
|
|
|
5501fb |
new file mode 100644
|
|
|
5501fb |
index 00000000..406f16f1
|
|
|
5501fb |
--- /dev/null
|
|
|
5501fb |
+++ b/tests/root/etc/selinux/semanage.conf
|
|
|
5501fb |
@@ -0,0 +1,60 @@
|
|
|
5501fb |
+# Authors: Jason Tang <jtang@tresys.com>
|
|
|
5501fb |
+#
|
|
|
5501fb |
+# Copyright (C) 2004-2005 Tresys Technology, LLC
|
|
|
5501fb |
+#
|
|
|
5501fb |
+# This library is free software; you can redistribute it and/or
|
|
|
5501fb |
+# modify it under the terms of the GNU Lesser General Public
|
|
|
5501fb |
+# License as published by the Free Software Foundation; either
|
|
|
5501fb |
+# version 2.1 of the License, or (at your option) any later version.
|
|
|
5501fb |
+#
|
|
|
5501fb |
+# This library is distributed in the hope that it will be useful,
|
|
|
5501fb |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
5501fb |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
5501fb |
+# Lesser General Public License for more details.
|
|
|
5501fb |
+#
|
|
|
5501fb |
+# You should have received a copy of the GNU Lesser General Public
|
|
|
5501fb |
+# License along with this library; if not, write to the Free Software
|
|
|
5501fb |
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
5501fb |
+#
|
|
|
5501fb |
+# Specify how libsemanage will interact with a SELinux policy manager.
|
|
|
5501fb |
+# The four options are:
|
|
|
5501fb |
+#
|
|
|
5501fb |
+# "source" - libsemanage manipulates a source SELinux policy
|
|
|
5501fb |
+# "direct" - libsemanage will write directly to a module store.
|
|
|
5501fb |
+# /foo/bar - Write by way of a policy management server, whose
|
|
|
5501fb |
+# named socket is at /foo/bar. The path must begin
|
|
|
5501fb |
+# with a '/'.
|
|
|
5501fb |
+# foo.com:4242 - Establish a TCP connection to a remote policy
|
|
|
5501fb |
+# management server at foo.com. If there is a colon
|
|
|
5501fb |
+# then the remainder is interpreted as a port number;
|
|
|
5501fb |
+# otherwise default to port 4242.
|
|
|
5501fb |
+module-store = direct
|
|
|
5501fb |
+
|
|
|
5501fb |
+# When generating the final linked and expanded policy, by default
|
|
|
5501fb |
+# semanage will set the policy version to POLICYDB_VERSION_MAX, as
|
|
|
5501fb |
+# given in <sepol/policydb.h>. Change this setting if a different
|
|
|
5501fb |
+# version is necessary.
|
|
|
5501fb |
+#policy-version = 19
|
|
|
5501fb |
+
|
|
|
5501fb |
+# expand-check check neverallow rules when executing all semanage
|
|
|
5501fb |
+# commands. There might be a penalty in execution time if this
|
|
|
5501fb |
+# option is enabled.
|
|
|
5501fb |
+expand-check=0
|
|
|
5501fb |
+
|
|
|
5501fb |
+# usepasswd check tells semanage to scan all pass word records for home directories
|
|
|
5501fb |
+# and setup the labeling correctly. If this is turned off, SELinux will label only /home
|
|
|
5501fb |
+# and home directories of users with SELinux login mappings defined, see
|
|
|
5501fb |
+# semanage login -l for the list of such users.
|
|
|
5501fb |
+# If you want to use a different home directory, you will need to use semanage fcontext command.
|
|
|
5501fb |
+# For example, if you had home dirs in /althome directory you would have to execute
|
|
|
5501fb |
+# semanage fcontext -a -e /home /althome
|
|
|
5501fb |
+usepasswd=False
|
|
|
5501fb |
+bzip-small=true
|
|
|
5501fb |
+bzip-blocksize=5
|
|
|
5501fb |
+ignoredirs=/root;/bin;/boot;/dev;/etc;/lib;/lib64;/proc;/run;/sbin;/sys;/tmp;/usr;/var
|
|
|
5501fb |
+optimize-policy=true
|
|
|
5501fb |
+
|
|
|
5501fb |
+[sefcontext_compile]
|
|
|
5501fb |
+path = /usr/sbin/sefcontext_compile
|
|
|
5501fb |
+args = -r $@
|
|
|
5501fb |
+[end]
|
|
|
5501fb |
diff --git a/tests/xpath.tests b/tests/xpath.tests
|
|
|
5501fb |
index a7db8d83..feab7584 100644
|
|
|
5501fb |
--- a/tests/xpath.tests
|
|
|
5501fb |
+++ b/tests/xpath.tests
|
|
|
5501fb |
@@ -109,6 +109,7 @@ test descendant-or-self /files/descendant-or-self :: 4
|
|
|
5501fb |
/files/etc/ssh/ssh_config/Host/SendEnv[1]/4 = LC_TIME
|
|
|
5501fb |
/files/etc/ssh/ssh_config/Host/SendEnv[2]/4 = LC_TELEPHONE
|
|
|
5501fb |
/files/etc/aliases/4
|
|
|
5501fb |
+ /files/etc/selinux/semanage.conf/ignoredirs/4 = /dev
|
|
|
5501fb |
/files/etc/fstab/4
|
|
|
5501fb |
/files/etc/pam.d/login/4
|
|
|
5501fb |
/files/etc/pam.d/newrole/4
|
|
|
5501fb |
--
|
|
|
5501fb |
2.31.1
|
|
|
5501fb |
|