Summary: | MSG: improve error message when dir specified in RuntimeDirectory= already exists but has differing access mode | ||
---|---|---|---|
Product: | systemd | Reporter: | Fireball <ao> |
Component: | general | Assignee: | systemd-bugs |
Status: | RESOLVED FIXED | QA Contact: | systemd-bugs |
Severity: | normal | ||
Priority: | medium | ||
Version: | unspecified | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: |
Description
Fireball
2015-03-16 08:45:43 UTC
The directory is copied with rsync first. Then systemd tries to create it before executing ExecStart and fails. RuntimeDirectory applies to the main part of the service and systemd expects to be able to create it. Replacing it with WorkingDirectory=%t/co2mon and ExecStartPost=/bin/rm -rf %t/co2mon (untested) might do what you want. No, this does not seem to be the case. I moved rsync to the main part: [Unit] Description=Log Data From CO2Mon PartOf=co2mon.service [Service] User=co2mon Group=co2mon RuntimeDirectory=co2mon RuntimeDirectoryMode=0755 WorkingDirectory=/run/co2mon StandardOutput=null ExecStart=/bin/bash -c "/usr/bin/rsync -a /var/lib/co2mon/ /run/co2mon ; ./update_data.sh" ExecStopPost=-/bin/cp -p /run/co2mon/graph.rrd /var/lib/co2mon/ [Install] WantedBy=multi-user.target Check that the directory is not there before start: # ls -ld /run/co2mon ls: cannot access /run/co2mon: No such file or directory Still fails: # systemctl start co2mon-log # systemctl status co2mon-log ● co2mon-log.service - Log Data From CO2Mon Loaded: loaded (/etc/systemd/system/co2mon-log.service; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since 月 2015-03-16 16:37:49 MSK; 3s ago Process: 9069 ExecStopPost=/bin/cp -p /run/co2mon/graph.rrd /var/lib/co2mon/ (code=exited, status=233/RUNTIME_DIRECTORY) Process: 9066 ExecStart=/bin/bash -c /usr/bin/rsync -a /var/lib/co2mon/ /run/co2mon ; ./update_data.sh (code=exited, status=233/RUNTIME_DIRECTORY) Main PID: 9066 (code=exited, status=233/RUNTIME_DIRECTORY) 3月 16 16:37:49 melforce systemd[1]: Started Log Data From CO2Mon. 3月 16 16:37:49 melforce systemd[1]: Starting Log Data From CO2Mon... 3月 16 16:37:49 melforce systemd[1]: co2mon-log.service: main process exited, code=exited, status=233/RUNTIME_DIRECTORY 3月 16 16:37:49 melforce systemd[1]: Unit co2mon-log.service entered failed state. 3月 16 16:37:49 melforce systemd[1]: co2mon-log.service failed. The other strange thing is that "cp" which is in ExecStopPost= (not the main part) also fails on runtime directory step and we see systemd's exit status 223, not cp's itself. cp is prefixed with minus sign. It can't fail. Doesn't this contradict what you said? Oops, sorry, I was wrong, rsync has insufficient permissions. Still, this behaviour is not documented. man page says runtime directory is created when units starts and removed when it stops without the details. You're right, the directory is created before ExecStartPre commands are run. I'll update the documentation to be more explicit. Returning to your original unit: looking at the code, the failure is most likely caused by the permissions on the directory being too broad. What is the mode of of /var/lib/co2mon? That wat right. drwxrwxr-x 1 root co2mon 132 3月 16 19:34 /var/lib/co2mon Changing RuntimeDirectoryMode to 0775 fixed the error. So I guess systemd's error message is not specific enough... |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.