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
This commit is contained in:
Panu Matilainen 2023-11-03 12:15:58 +02:00
parent 43cf645fc1
commit a8ec768950
2 changed files with 9 additions and 0 deletions

View File

@ -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
}

View File

@ -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