Fix parsing of /usr/lib/tmpfiles.d/provision.conf

resolves: rhbz#2155136
This commit is contained in:
Richard W.M. Jones 2023-04-04 11:38:17 +01:00
parent 9a9230ffa3
commit b839415c5d
5 changed files with 176 additions and 4 deletions

View File

@ -1,7 +1,7 @@
From 08101c754aafab4d0f79367839bbd0d6012c31cf Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed, 2 Mar 2022 14:54:39 +0100
Subject: [PATCH 1/3] Chrony: add new directives and options (#745)
Subject: [PATCH 1/4] Chrony: add new directives and options (#745)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

View File

@ -1,7 +1,7 @@
From e0bce2e8c21ccc69729676e8dc6fa1e541aedee2 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@users.noreply.github.com>
Date: Wed, 20 Apr 2022 10:13:06 +0200
Subject: [PATCH 2/3] Kdump: parse "auto_reset_crashkernel" (#754)
Subject: [PATCH 2/4] Kdump: parse "auto_reset_crashkernel" (#754)
The "auto_reset_crashkernel" keyword was introduced in the following
kexec-tools patch set:

View File

@ -1,7 +1,7 @@
From aca3def462ab141c3991a2d27c44341b809cf970 Mon Sep 17 00:00:00 2001
From: rwmjones <rjones@redhat.com>
Date: Thu, 6 Oct 2022 12:15:56 +0100
Subject: [PATCH 3/3] semanage: Fix parsing of ignoredirs (#758)
Subject: [PATCH 3/4] semanage: Fix parsing of ignoredirs (#758)
From /etc/selinux/semanage.conf from a RHEL 9.1 system, this line
caused problems:

View File

@ -0,0 +1,164 @@
From 34749f9ea1af8e3fad9e60891beda0fe786cb0f2 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Fri, 24 Mar 2023 11:26:46 +0100
Subject: [PATCH 4/4] Tmpfiles: allow '=', '~', '^' for letter types, allow ":"
as prefix for the mode
* Tmpfiles: allow '=', '~', '^' for letter types
Allow an equal sign, a tilde character and/or a caret for the type
specification:
- equal: strict file type enforcing
- tilde: base64-encoded content in the argument
- caret: credential name in the argument
Fixes: #795
* Tmpfiles: allow ":" as prefix for the mode
Represents a mode to be set only for new inodes.
(cherry picked from commit 41b2a33ff02687fa53d69a012a1d47141b196a86)
---
lenses/tests/test_tmpfiles.aug | 78 ++++++++++++++++++++++++++++++++++
lenses/tmpfiles.aug | 9 ++--
2 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/lenses/tests/test_tmpfiles.aug b/lenses/tests/test_tmpfiles.aug
index 6ced069f..4bbd06a2 100644
--- a/lenses/tests/test_tmpfiles.aug
+++ b/lenses/tests/test_tmpfiles.aug
@@ -97,6 +97,60 @@ Tree for <minus_tree> *)
{ "argument" = "-" }
}
+ (* Variable: equal
+Example with an equal sign in the type *)
+ let equal = "d= /tmp/foo 0755 root root - -\n"
+
+ (* Variable: equal_tree
+Tree for <equal> *)
+ let equal_tree =
+ {
+ "1"
+ { "type" = "d=" }
+ { "path" = "/tmp/foo" }
+ { "mode" = "0755" }
+ { "uid" = "root" }
+ { "gid" = "root" }
+ { "age" = "-" }
+ { "argument" = "-" }
+ }
+
+ (* Variable: tilde
+Example with a tilde character in the type *)
+ let tilde = "w~ /tmp/foo 0755 root root - dGVzdAo=\n"
+
+ (* Variable: tilde_tree
+Tree for <tilde> *)
+ let tilde_tree =
+ {
+ "1"
+ { "type" = "w~" }
+ { "path" = "/tmp/foo" }
+ { "mode" = "0755" }
+ { "uid" = "root" }
+ { "gid" = "root" }
+ { "age" = "-" }
+ { "argument" = "dGVzdAo=" }
+ }
+
+ (* Variable: caret
+Example with a caret in the type *)
+ let caret = "f^ /etc/motd.d/50-provision.conf - - - - login.motd\n"
+
+ (* Variable: caret_tree
+Tree for <caret> *)
+ let caret_tree =
+ {
+ "1"
+ { "type" = "f^" }
+ { "path" = "/etc/motd.d/50-provision.conf" }
+ { "mode" = "-" }
+ { "uid" = "-" }
+ { "gid" = "-" }
+ { "age" = "-" }
+ { "argument" = "login.motd" }
+ }
+
(* Variable: short
Example with only type and path *)
let short = "A+ /tmp/foo\n"
@@ -337,6 +391,22 @@ Tree for <mode3> *)
{ "mode" = "755" }
}
+ (* Variable: mode_colon
+Mode field with colon prefix *)
+ let mode_colon = "d- /root :0700 root :root\n"
+
+ (* Variable: mode_colon_tree
+Tree for <mode_colon> *)
+ let mode_colon_tree =
+ {
+ "1"
+ { "type" = "d-" }
+ { "path" = "/root" }
+ { "mode" = ":0700" }
+ { "uid" = "root" }
+ { "gid" = ":root" }
+ }
+
(************************************************************************
* Group: INVALID EXAMPLES
*************************************************************************)
@@ -377,6 +447,12 @@ Invalid example that contain invalid mode (letter) *)
test Tmpfiles.lns get minus = minus_tree
+ test Tmpfiles.lns get equal = equal_tree
+
+ test Tmpfiles.lns get tilde = tilde_tree
+
+ test Tmpfiles.lns get caret = caret_tree
+
test Tmpfiles.lns get short = short_tree
test Tmpfiles.lns get short_mode = short_mode_tree
@@ -405,6 +481,8 @@ Invalid example that contain invalid mode (letter) *)
test Tmpfiles.lns get mode3 = mode3_tree
+ test Tmpfiles.lns get mode_colon = mode_colon_tree
+
(* failure cases *)
diff --git a/lenses/tmpfiles.aug b/lenses/tmpfiles.aug
index 01b3003a..1163c84a 100644
--- a/lenses/tmpfiles.aug
+++ b/lenses/tmpfiles.aug
@@ -50,15 +50,16 @@ Empty lines *)
(* View: type
One letter. Some of them can have a "+" and all can have an
-exclamation mark ("!") and/or minus sign ("-").
+exclamation mark ("!"), a minus sign ("-"), an equal sign ("="),
+a tilde character ("~") and/or a caret ("^").
Not all letters are valid.
*)
- let type = /([fFwdDevqQpLcbCxXrRzZtThHaAm]|[fFwpLcbaA]\+)!?-?/
+ let type = /([fFwdDevqQpLcbCxXrRzZtThHaAm]|[fFwpLcbaA]\+)[-!=~^]*/
(* View: mode
-"-", or 3-4 bytes. Optionally starts with a "~". *)
- let mode = /(-|~?[0-7]{3,4})/
+"-", or 3-4 bytes. Optionally starts with a "~" or a ":". *)
+ let mode = /(-|(~|:)?[0-7]{3,4})/
(* View: age
"-", or one of the formats seen in the manpage: 10d, 5seconds, 1y5days.
--
2.31.1

View File

@ -1,6 +1,6 @@
Name: augeas
Version: 1.13.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: A library for changing configuration files
License: LGPLv2+
@ -26,6 +26,10 @@ Patch2: 0002-Kdump-parse-auto_reset_crashkernel-754.patch
# Upstream commit a3ba6e2d32b95507e2474a219e788ac3d54bc4a1
Patch3: 0003-semanage-Fix-parsing-of-ignoredirs-758.patch
# Fix parsing of /usr/lib/tmpfiles.d/provision.conf
# Upstream commit 41b2a33ff02687fa53d69a012a1d47141b196a86
Patch4: 0004-Tmpfiles-allow-for-letter-types-allow-as-prefix-for-.patch
Provides: bundled(gnulib)
BuildRequires: make
@ -142,6 +146,10 @@ rm -f $RPM_BUILD_ROOT/usr/bin/dump
%{_libdir}/libfa.a
%changelog
* Tue Apr 04 2023 Richard W.M. Jones <rjones@redhat.com> - 1.13.0-4
- Fix parsing of /usr/lib/tmpfiles.d/provision.conf
resolves: rhbz#2155136
* Thu Oct 06 2022 Richard W.M. Jones <rjones@redhat.com> - 1.13.0-3
- Fix parsing of /etc/selinux/semanage.conf in RHEL 9
resolves: rhbz#2077120