Skip to content

Commit

Permalink
Fix comment line handling in sysusers.d(8) files
Browse files Browse the repository at this point in the history
sysusers.d(8) format permits empty lines and commits, and so must we.
Add some extra fluff to the test-case for this.

Fixes the second half of
https://bugzilla.redhat.com/show_bug.cgi?id=2246236
  • Loading branch information
pmatilai committed Nov 3, 2023
1 parent 8f89d1f commit 123ea3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fileattrs/sysusers.attr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -14,5 +17,6 @@
table.insert(fields, 1, '-b')
print(macros.add_sysuser(fields))
end
::continue::
end
}
5 changes: 5 additions & 0 deletions tests/data/SPECS/klang.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 123ea3c

Please sign in to comment.