0

I'm running archlinux and I use the systemd transmission.service for downloading torrents. I have an ext4 hard-disk partition automatically mounted with fstab on /var/lib/transmission. I keep there all the completed downloads and I share that directory with a samba server on the local network.

The problem is that every time the computer boots, I can see /var/lib/transmission doesn't have read permissions for everyone. It means the samba server can't read the full path to that directory and ultimately I can't access the files with a samba client. After boot I can run sudo chmod a+rX /var/lib/transmission and only then the directory is accessible. It seems like transmission rewrites the permissions drwxr-x--- every boot.

Is there an elegant way to edit some systemd files and fix it? Perhaps using sudo systemctl edit transmission.service?

3

The solution is adding to /etc/systemd/system/multi-user.target.wants/transmission.service the following or using sudo systemctl edit transmission.service and write:

[Service]
ExecStartPost=/bin/chmod a+rX /var/lib/transmission

systemctl edit opens a text editor for you to override the entries for the original service file and not changing the original file provided by the package manager.

After adding these, Reboot and Problem fixed.

Note: It might be more pragmatic to use systemctl edit because I guess this command was created so you won't edit the original service files provided by the package manager.

Note: You'll might need to adjust the path to the chmod executable according to your distribution paths.

Edit:

Very much like directories in /var/run, I've found out why systemd is making sure every boot that this directory will have these permissions, it is explained originally here: https://serverfault.com/questions/824393/var-run-directory-creation-even-though-service-is-disabled/824394#824394

quoting:

With systemd, there is a new functionality called tmpfiles.d(5) that can be used to create files or directories on boot outside of the .service file. Openvpn and ejabberd are both using this, so that's why the directories in /var/run are still created even if they are not started on boot.

The tmpfiles configuration files are stored in /usr/lib/tmpfiles.d/

Anyway, another way to solve this problem is editing the umask number on /usr/lib/tmpfiles.d/transmission.conf to something like this:

d /var/lib/transmission 0755 transmission transmission
  • 1
    Note, files in /etc/systemd/system/multi-user.target.wants/ are symbolic links, usually to files in /usr/lib/systemd/system/, so you shouldn't edit them, especially if you accidentally break the symbolic link and create a new file. As you say, systemctl edit is the best. – meuh Oct 25 '16 at 14:43

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.