Fix parsing /etc/fstab

Resolves: RHEL-35873
This commit is contained in:
Cosmin Tupangiu 2024-07-19 11:12:41 +02:00
parent 7c881b1a3e
commit c3f08fe3d5
No known key found for this signature in database
GPG Key ID: 049AEEF00B57643F
7 changed files with 90 additions and 17 deletions

View File

@ -1,7 +1,7 @@
From 08101c754aafab4d0f79367839bbd0d6012c31cf Mon Sep 17 00:00:00 2001
From 1a68d8afa2b23b3133a605d5fdf994139e60682f 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/5] Chrony: add new directives and options (#745)
Subject: [PATCH 1/6] Chrony: add new directives and options (#745)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -105,5 +105,5 @@ index 0c86cde7..691e63f7 100644
(* Local Variables: *)
--
2.31.1
2.45.2

View File

@ -1,7 +1,7 @@
From e0bce2e8c21ccc69729676e8dc6fa1e541aedee2 Mon Sep 17 00:00:00 2001
From 5cc865803bd62df17e732c360787fbc263a9942a 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/5] Kdump: parse "auto_reset_crashkernel" (#754)
Subject: [PATCH 2/6] Kdump: parse "auto_reset_crashkernel" (#754)
The "auto_reset_crashkernel" keyword was introduced in the following
kexec-tools patch set:
@ -272,5 +272,5 @@ index 00000000..d4fc78b0
+#fence_kdump_args -p 7410 -f auto -c 0 -i 10
+#fence_kdump_nodes node1 node2
--
2.31.1
2.45.2

View File

@ -1,7 +1,7 @@
From aca3def462ab141c3991a2d27c44341b809cf970 Mon Sep 17 00:00:00 2001
From 864ca7e256a3cf7236bf4d096e265672baed2fbb Mon Sep 17 00:00:00 2001
From: rwmjones <rjones@redhat.com>
Date: Thu, 6 Oct 2022 12:15:56 +0100
Subject: [PATCH 3/5] semanage: Fix parsing of ignoredirs (#758)
Subject: [PATCH 3/6] semanage: Fix parsing of ignoredirs (#758)
From /etc/selinux/semanage.conf from a RHEL 9.1 system, this line
caused problems:
@ -132,7 +132,7 @@ index 00000000..406f16f1
+args = -r $@
+[end]
diff --git a/tests/xpath.tests b/tests/xpath.tests
index 4278e433..71c998b8 100644
index a7db8d83..feab7584 100644
--- a/tests/xpath.tests
+++ b/tests/xpath.tests
@@ -109,6 +109,7 @@ test descendant-or-self /files/descendant-or-self :: 4
@ -144,5 +144,5 @@ index 4278e433..71c998b8 100644
/files/etc/pam.d/login/4
/files/etc/pam.d/newrole/4
--
2.31.1
2.45.2

View File

@ -1,7 +1,7 @@
From 34749f9ea1af8e3fad9e60891beda0fe786cb0f2 Mon Sep 17 00:00:00 2001
From c696b4851f057a0340ce6d445bac22078d333a61 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/5] Tmpfiles: allow '=', '~', '^' for letter types, allow ":"
Subject: [PATCH 4/6] Tmpfiles: allow '=', '~', '^' for letter types, allow ":"
as prefix for the mode
* Tmpfiles: allow '=', '~', '^' for letter types
@ -160,5 +160,5 @@ index 01b3003a..1163c84a 100644
(* View: age
"-", or one of the formats seen in the manpage: 10d, 5seconds, 1y5days.
--
2.31.1
2.45.2

View File

@ -1,7 +1,7 @@
From f4a9ca77e5dba3659cfadd9e12ba96b32befdaab Mon Sep 17 00:00:00 2001
From 61a489a7c9f276be8bb717c4d532beebc2b64fef Mon Sep 17 00:00:00 2001
From: rwmjones <rjones@redhat.com>
Date: Sun, 5 Mar 2023 10:30:43 +0000
Subject: [PATCH 5/5] lenses: Allow whitespace at the end of kernel commnd line
Subject: [PATCH 5/6] lenses: Allow whitespace at the end of kernel commnd line
(#798)
Reported-by: Yongkui Guo
@ -40,5 +40,5 @@ index 0624a0b2..77a429d8 100644
test lns get "foo bar" = { "foo" } { "bar" }
test lns get "foo bar" = { "foo" } { "bar" }
--
2.31.1
2.45.2

View File

@ -0,0 +1,65 @@
From ac6c3962d38c14d887fe7486330c19d477ab034d Mon Sep 17 00:00:00 2001
From: Cosmin Tupangiu <cosmin@redhat.com>
Date: Thu, 18 Jul 2024 13:02:20 +0200
Subject: [PATCH 6/6] lenses/fstab.aug: Allow comma after the last option
(#838)
This PR adds a new lens that allows a comma after the last option:
/dev/mapper/foo-bar / xfs defaults, 0 0
Fixes: https://issues.redhat.com/browse/RHEL-35873
Signed-off-by: Cosmin Tupangiu <cosmin@redhat.com>
(cherry picked from commit 5246ef07381033a9b20426370156dae9f8f97a2c)
---
lenses/fstab.aug | 3 ++-
lenses/tests/test_fstab.aug | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/lenses/fstab.aug b/lenses/fstab.aug
index 2e549557..c653c489 100644
--- a/lenses/fstab.aug
+++ b/lenses/fstab.aug
@@ -5,6 +5,7 @@ module Fstab =
let sep_tab = Sep.tab
let sep_spc = Sep.space
+ let sep_comma_tab = del /,?[ \t]+/ "\t"
let comma = Sep.comma
let eol = Util.eol
@@ -28,7 +29,7 @@ module Fstab =
[ label "file" . store file ] . sep_tab .
comma_sep_list "vfstype" .
(sep_tab . comma_sep_list "opt" .
- (sep_tab . [ label "dump" . store /[0-9]+/ ] .
+ (sep_comma_tab . [ label "dump" . store /[0-9]+/ ] .
( sep_spc . [ label "passno" . store /[0-9]+/ ])? )? )?
. Util.comment_or_eol ]
diff --git a/lenses/tests/test_fstab.aug b/lenses/tests/test_fstab.aug
index 438f619a..4a912e59 100644
--- a/lenses/tests/test_fstab.aug
+++ b/lenses/tests/test_fstab.aug
@@ -156,6 +156,17 @@ module Test_fstab =
{ "#comment" = "device at install: /dev/sda3" }
}
+ (* Bug #832 - Allow comma after the last option *)
+ test Fstab.lns get "/dev/mapper/foo-bar / xfs defaults, 0 0\n" =
+ { "1"
+ { "spec" = "/dev/mapper/foo-bar" }
+ { "file" = "/" }
+ { "vfstype" = "xfs" }
+ { "opt" = "defaults" }
+ { "dump" = "0" }
+ { "passno" = "0" }
+ }
+
(* Local Variables: *)
(* mode: caml *)
(* End: *)
--
2.45.2

View File

@ -1,6 +1,6 @@
Name: augeas
Version: 1.13.0
Release: 5%{?dist}
Release: 6%{?dist}
Summary: A library for changing configuration files
License: LGPLv2+
@ -34,6 +34,10 @@ Patch4: 0004-Tmpfiles-allow-for-letter-types-allow-as-prefix-for-.patch
# Upstream commit 801aa73db3c356378467622a7e02dea21ccf4332
Patch5: 0005-lenses-Allow-whitespace-at-the-end-of-kernel-commnd-.patch
# Fix parsing of /etc/fstab
# Upstream commit 5246ef07381033a9b20426370156dae9f8f97a2c
Patch6: 0006-lenses-fstab.aug-Allow-comma-after-the-last-option-8.patch
Provides: bundled(gnulib)
BuildRequires: make
@ -150,6 +154,10 @@ rm -f $RPM_BUILD_ROOT/usr/bin/dump
%{_libdir}/libfa.a
%changelog
* Fri Jul 19 2024 Cosmin Tupangiu <cosmin@redhat.com> - 1.13.0-5
- Fix parsing /etc/fstab by allowing comma after last option
resolves: RHEL-35873
* Tue Apr 04 2023 Richard W.M. Jones <rjones@redhat.com> - 1.13.0-4
- Fix parsing of /usr/lib/tmpfiles.d/provision.conf
- Fix parsing of /etc/kernel/cmdline