On Wed, Nov 29, 2023 at 08:04:11PM +0100, Michal Schorm wrote:
> I maintain the packages 'mariadb' and 'community-mysql'.
> Sub-packages of each of them need the user 'mysql' to be present prior
> installation.
> Both manually create the user in the %pre section.
>
> I found out a different system should be used nowadays:
> https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/#_dynamic_allocation
> Introduced by this change:
> https://fedoraproject.org/wiki/Changes/Adopting_sysusers.d_format
>
> However while the change talks about the possibility of a setup of
> multiple packages requiring the same user, the packaging guidelines do
> not cover this topic.
>
> I'm not sure how to implement it properly, so I need help with my case,
> and I ask for the guidelines to be extended.
Yeah, there are no guidelines for this case because it didn't really
come up before. I think this case can be used to figure out the best
way to do this and then the guidelines can be informed by the solution.
> The MariaDB upstream ships a simple 'sysusers.conf' file.
> I already pack it, so the resulting RPM already has - thanks to this:
> | Provides:
> | group(mysql)
> | user(mysql)
> Based on the documentation in the guidelines, I guess it's never
> actually applied though, since I always define the user manually,
> before the sysuser file could take effect.
>
> I'd like to move the 'sysusers.conf' file to a separate sub-package,
> and use it by both mariadb-server and community-mysql-server RPMs.
>
> I guess the following code would be for the sub-package shipping the
> 'sysusers.conf' file:
> | %package system-user-mysql
> | Summary: This package provides system user 'mysql'
> | %description system-user-mysql
> | This package provides system user 'mysql'
> |
> | %files system-user-mysql
> | %{_sysusersdir}/%{pkg_name}.conf
>
> And then for the 'mariadb-server', which needs the user, the code would be:
> | Requires(pre): user(mysql)
> | Requires(pre): group(mysql)
This all looks reasonable.
> but I'm not sure whether I'm not missing any of those, and/or where:
> | BuildRequires: systemd-rpm-macros
> | %{?sysusers_requires_compat}
> |
> | %pre
> | %sysusers_create_compat %{SOURCE3}
Those should be attached to the subpackage that has the sysusers file.
> Likely because I don't understand where/when the systemd picks up,
> recognizes the installed file and actually creates the user, if it
> does not exist already.
So actually systemd does _not_ exactly pick up the file. The macro
generates code to create the user in %pre. The systemd-sysusers.service
will also look at this sysusers file, but by the time it gets run,
the user/group already exist to it doesn't do anything.
There's yet another twist to this story: rpm is getting support
for sysusers natively, so %sysusers_create_compat will go away and
the guidelines will need to be updated. But I think it should be
fine to start with %sysusers_create_compat and get the subpackage
working, and then this details of the implementation can be adjusted
later.
Zbyszek
--
_______________________________________________
devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam, report it:
https://pagure.io/fedora-infrastructure/new_issue