Bug 2095424

Summary: [RFE] httpd use systemd-sysusers
Product: Red Hat Enterprise Linux 9 Reporter: Pat Riehecky <riehecky>
Component: httpdAssignee: Luboš Uhliarik <luhliari>
Status: NEW --- QA Contact: rhel-cs-infra-services-qe <rhel-cs-infra-services-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: bstinson, jonathan, jwboyer, luhliari
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pat Riehecky 2022-06-09 17:25:02 UTC
Description of problem:
httpd is using static useradd scripts

Version-Release number of selected component (if applicable):
httpd-2.4.53-2.el9

How reproducible:
100%

Steps to Reproduce:
1.review %pre
2.
3.

Actual results:
%pre filesystem
getent group apache >/dev/null || groupadd -g 48 -r apache
getent passwd apache >/dev/null || \
  useradd -r -u 48 -g apache -s /sbin/nologin \
    -d %{contentdir} -c "Apache" apache
exit 0

Expected results:
use of system-sysusers 

Additional info:
https://www.freedesktop.org/software/systemd/man/systemd-sysusers.html
https://fedoraproject.org/wiki/Changes/Adopting_sysusers.d_format

Comment 2 Luboš Uhliarik 2022-11-15 20:41:07 UTC
Hi Pat,

Do you have any more knowledge regarding this request?

I was trying to adopt this new format with new macros, but then I found out that it is not so 
easy (or at least I don't know how) to change the content in sysusers.d file before it is 
processed by the RPM macro processor.

It would be nice, if I can in %prep section modify the sysuser file by e.g. sed, but so far 
it looks like that the macro in %pre section (%sysusers_create_compat httpd.sysusers) is expanded 
before %prep.

There is a possibility to hardcode e.g. %{nginx_user} into sysusers.d file or %{contentdir} in case 
of httpd apache, but if you change this variable in the spec file, it won't properly change in 
sysusers.d file.

Comment 3 Pat Riehecky 2022-11-15 20:48:01 UTC
I'll confess I don't have specific detailed knowledge on this front.  I'm mostly going off the fedora guidelines and looking for places to help homoginize the behaviors.

Comment 4 Jonathan Wright 2023-07-05 21:39:00 UTC
@luhliari https://gitlab.com/redhat/centos-stream/rpms/httpd/-/merge_requests/75

Comment 5 Luboš Uhliarik 2023-07-11 09:21:23 UTC
(In reply to Jonathan Wright from comment #4)
> @luhliari
> https://gitlab.com/redhat/centos-stream/rpms/httpd/-/merge_requests/75

Hello Jonathan, I have similar change ready locally, but from what I know there is no option to use vars/params in systemd-sysusers file. I wanted to have in sysusers file something like:

---
g apache 48
u apache 48 "Apache" @CONTENTDIR@ /sbin/nologin
---


Because content dir can vary based on contentdir macro value definition on the top of the httpd.spec file:

define contentdir %{_datadir}/httpd


So far I could not find any way how to process that file before it is processed by %sysusers_create_compat macro.