Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running svnserve on a Fedora 17 machine with the following systemd service file:

Description=Subversion Server
After=syslog.target network.target

ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid -r /repos/svn


This works fine as long as /var/run/svnserve is owned by svn:svn, but breaks on reboot when that ownership is reset to root:root. What I want is to add a pre-launch step that chowns the directory.

Unfortunately I can't find any real documentation on systemd unit files, but I saw that some were using 'ExecStartPre', so I tried this:

ExecStartPre=/bin/chown svn:svn /run/svnserve

Sadly this fails with an 'operation not permitted' error, so it looks like ExecStartPre also runs as the user specified in the unit file.

I also tried having the unit file run as root, then starting svnserve as the svn user via su, but that produced a vague error about the command-line being invalid.

How can systemd units perform actions as root prior to executing as a specific user?

share|improve this question

closed as too localized by Michael Hampton, Ward, Jacob, Khaled, mdpc Feb 26 '13 at 20:13

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

You report this as a bug. The permissions should already be correct on the /run directory and the pid file, but lots of these broke with the switch to systemd and the /usr move. –  Michael Hampton Feb 25 '13 at 21:14
@MichaelHampton I don't believe this is how it came out of the box. IIRC (this was set up a while back) svnserve doesn't come with a service wrapper, so this was something that we wrote ourselves. –  DNS Feb 25 '13 at 21:24
Subversion on Fedora certainly does come with this. It looks fairly similar to yours, though I would recommend you use the original. yum reinstall subversion –  Michael Hampton Feb 25 '13 at 21:28
If you gave your su command line we may be able to solve that problem. –  Hauke Laging Feb 26 '13 at 3:48
add comment

2 Answers

up vote 3 down vote accepted

The subversion package in Fedora is using systemd's tmpfiles mechanism to create /run/svnserve at boot with root ownership (since the packaged .service file apparently runs the daemon as root). You could copy /usr/lib/tmpfiles.d/svnserve.conf to /etc/tmpfiles.d/svnserve.conf and change the owner. See man tmpfiles.d for details.

share|improve this answer
Aha; I had no idea that tmpfiles mechanism existed. Thank you! –  DNS Feb 26 '13 at 12:33
add comment

You could make ExecStartPre a sudo call to a script and configure the user svn for this script.

share|improve this answer
Can't use sudo; there is no TTY when running systemd units. –  DNS Feb 26 '13 at 12:32
Why should sudo need a tty if no password is needed? –  Hauke Laging Feb 26 '13 at 15:26
I don't know exactly, but I had tried that idea, and the system logged an error stating that sudo requires a TTY. –  DNS Feb 26 '13 at 17:12
@DNS screen may be a solution in such cases. –  Hauke Laging Feb 26 '13 at 20:23
add comment

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