Skip to main content
Topic: Correct way to add a user in a custom package (PKGBUILD) (Read 391 times) previous topic - next topic
0 Members and 4 Guests are viewing this topic.

Correct way to add a user in a custom package (PKGBUILD)

Hi all :-)

I already created a few *-openrc packages that are currently missing (tftp-hpa-openrc and quassel-core-openrc, simply by stealing the OpenRC init script from Gentoo ;-). Now, I'm working on msmtp-openrc, because I want to migrate a Gentoo machine to Artix which runs msmtpd (btw. can I contribute those packages in some way to support OpenRC on Artix?!).

I did the same, simply took the Gentoo init script and created a package. But when I tried to start the daemon, I noticed that Gentoo runs msmpd with it's own user, and Artix doesn't create one whilst installing msmtp. It seems reasonable to me to run such a service with a dedicated user.

So here's my question: What's the correct way to add a user via a package?

Gentoo pulls two dedicated packages for group and user management when one installs msmpd with the "daemon" use flag set. Those are acct-group/msmtpd, creating /usr/lib/sysusers.d/acct-group-msmtpd.conf with the following content:
Code: [Select]
g       msmtpd  222
and acct-user/msmtpd, creating /usr/lib/sysusers.d/acct-user-msmtpd.conf with:
Code: [Select]
u       msmtpd  222:msmtpd      user\ for\ msmtp\ daemon        /dev/null       -
Does Artix have a similar mechanism? What's the Artix way to create groups and users?

Would I create a file, e.g. /usr/lib/sysusers.d/msmtpd.conf, with
Code: [Select]
g	msmtpd	-
u msmtpd -:msmtpd "User for the msmtp daemon" /dev/null -
?

Thanks for all help, I'd like to do this the correct way!

Re: Correct way to add a user in a custom package (PKGBUILD)

Reply #1
Okay, after messing a bit with this, creating a  /usr/lib/sysusers.d/ file at least seems to be a clean way to solve this. With no additional code or command invocation added, pacman creates the respective group and user after the package is installed.