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