3

I am trying to determine which Linux user/group runs systemd jobs so that I can set D-Bus permissions accordingly.

When I do this:

sudo systemctl start myservice

That ultimately calls an executable which attempts to register itself on D-Bus, however for that to work I need to provide the user permissions in D-Bus config. How can I tell which Linux user/group is associated with the above?

1
  • By default I would assume it runs as root unless you explicitly define User and Group in the unit file. Aug 21, 2015 at 22:29

1 Answer 1

3

You can use User= and Group= directives in your unit file.

http://www.freedesktop.org/software/systemd/man/systemd.exec.html

Systemd unit files are pretty well documented (compared to lot of other open source software). The directives you can use in unit files are spread out over many man pages, so information might not be so easy to find and understand, especially if systemd concepts are not so clear to the reader.

But there is an index page for all directives:

http://www.freedesktop.org/software/systemd/man/systemd.directives.html

There is more documentation available:

http://www.freedesktop.org/wiki/Software/systemd/

It's a while I have been reading it, but if I remember correctly the Systemd for Administrators blog series gives a reasonable background on the concepts.

For all questions of type

How can I tell...

Just a add ExecStartPre= directives with the commands suitable for testing/querying the desired items.

E.g.

ExecStartPre=/usr/bin/whoami

Note that systemd does not use a shell by default, but you can always do so manually

ExecStartPre=/bin/sh -c "if true;then echo true;fi"

You can see the output of such commands using systemctl status <myunit> or by looking into the journal using the journalctl command (as root!).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.