You are not logged in.

#1 2023-05-21 06:45:35

tachtler
Member
Registered: 2020-08-23
Posts: 25

[solved] PKGBUILD create user with systemd-sysuser and chown directory

Hi,

I'm new to building Archlinux AUR packages and have the following problem.

I create a user in package() using systemd-sysuser and then I would like to give a directory, created while the installation, the file permissions of this user.

But a

chown -R user:user /directory

does not work because the user is not yet created?

How can I do something like this?

Many thanks in advance!


Greetings
Klaus.

Last edited by tachtler (2023-05-21 07:52:39)

Offline

#2 2023-05-21 07:08:31

3beb6e7c46a615a
Member
Registered: 2021-03-27
Posts: 165

Re: [solved] PKGBUILD create user with systemd-sysuser and chown directory

With systemd you'd install a tmpfiles fragment to have systemd create this directory with appropriate permissions, especially if you already use a sysusers fragment to create the user.

More traditionally, you could add an install script to your package to create the user and adapt the permissions of the directory.

Offline

#3 2023-05-21 07:51:41

tachtler
Member
Registered: 2020-08-23
Posts: 25

Re: [solved] PKGBUILD create user with systemd-sysuser and chown directory

Hi lunaryorn,

thank you for your answer. I did it the way you suggested!


Thank you!
Klaus.

Offline

#4 2023-05-21 21:15:42

loqs
Member
Registered: 2014-03-06
Posts: 18,140

Re: [solved] PKGBUILD create user with systemd-sysuser and chown directory

Note there is no need in the case of https://aur.archlinux.org/packages/graylog to change the ownership of /etc/graylog as the service file contains ConfigurationDirectory=graylog so starting the service will fix the ownership and before that the files will be owned root:root.
The tmpfiles snippet is also rendered redundant by the service file.  You should not delete users on package removal,  they can still own files.  Also removing /run/graylog is not required as the directory will be removed when the service is stopped.

Offline

Board footer

Powered by FluxBB