Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bunch of sysusers.d handling fixes #2745

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
7 changes: 5 additions & 2 deletions macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -1325,14 +1325,17 @@ end
prefix = 'Provides: '
end
if #arg < 2 then
error('not enough arguments')
macros.error({'not enough arguments'})
end
if arg[1] == 'g' then
type = 'group'
elseif arg[1] == 'u' then
type = 'user'
elseif arg[1] == 'r' or arg[1] == 'm' then
macros.warn({'ignoring unsupported sysuser type: '..arg[1]})
return
else
error('invalid sysuser type: '..arg[1])
macros.error({'invalid sysuser type: '..arg[1]})
end
name = arg[2]
line = table.concat(arg, ' ')
Expand Down
10 changes: 9 additions & 1 deletion tests/data/SPECS/klang.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Summary: %{SUMMARY} server

%install
mkdir -p ${RPM_BUILD_ROOT}/var/lib/klangd
mkdir -p ${RPM_BUILD_ROOT}/var/lib/plongd
mkdir -p ${RPM_BUILD_ROOT}/usr/bin/
mkdir -p ${RPM_BUILD_ROOT}/etc
mkdir -p ${RPM_BUILD_ROOT}/%{_sysusersdir}
Expand All @@ -44,8 +45,15 @@ 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
EOF

%files common
Expand All @@ -59,5 +67,5 @@ EOF
%{_sysusersdir}/klangd.conf
%{_sysusersdir}/plong.conf
%attr(-,klangd,klangd) /var/lib/klangd
%attr(-,plong,klong) /var/lib/klangd
%attr(-,plong,klong) /var/lib/plongd
/usr/bin/klangd
7 changes: 7 additions & 0 deletions tests/rpmi.at
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,14 @@ AT_SETUP([rpm -i sysusers])
AT_KEYWORDS([install build sysusers])
RPMDB_INIT

RPMTEST_CHECK([
runroot rpmbuild -bb --quiet /data/SPECS/klang.spec
],
[0],
[],
[warning: ignoring unsupported sysuser type: m
warning: ignoring unsupported sysuser type: r
])

RPMTEST_CHECK([
runroot rpm -U /build/RPMS/noarch/klang-client-1.0-1.noarch.rpm
Expand Down