From a8ec768950f0adb9fb0c264596350fc929437ac8 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 3 Nov 2023 12:15:58 +0200 Subject: [PATCH] Fix comment line handling in sysusers.d(8) files sysusers.d(8) format permits empty lines and commits, and so must we. Add some extra fluff to the test-case for this. This is the second half of https://bugzilla.redhat.com/show_bug.cgi?id=2246236 Fixes: #2741 --- fileattrs/sysusers.attr | 4 ++++ tests/data/SPECS/klang.spec | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/fileattrs/sysusers.attr b/fileattrs/sysusers.attr index f7a3e838d1..48d4caede9 100644 --- a/fileattrs/sysusers.attr +++ b/fileattrs/sysusers.attr @@ -6,6 +6,9 @@ # For groups created as a side-effect, only provide the group. %__sysusers_provides() %{lua: for line in io.lines(macros["1"]) do + if line:sub(1, 1) == '#' then + goto continue + end fields = {} for w in line:gmatch("%S+") do table.insert(fields, w) @@ -14,5 +17,6 @@ table.insert(fields, 1, '-b') print(macros.add_sysuser(fields)) end + ::continue:: end } diff --git a/tests/data/SPECS/klang.spec b/tests/data/SPECS/klang.spec index e7c03cd7f8..64bd90c104 100644 --- a/tests/data/SPECS/klang.spec +++ b/tests/data/SPECS/klang.spec @@ -45,7 +45,12 @@ cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/klangd.conf u klangd - "Klang server" /var/lib/klangd /sbin/nologin EOF cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/plong.conf + +# Real life files have all sorts of anomalies u plong - "Plong fu" /var/lib/plong /sbin/nologin +#...such as empty lines + +# and comments comments g klong - m ding dong r - 123-321