Closed anfoe1111 closed 6 years ago
found a solution today: due to some special quoting rules inside systemd (see man systemd.service), the quotes need to include the whole "--command="-option of the su-command. The following line is working fine:
ExecStartPre=/bin/su naemon --login --shell=/bin/sh "--command=/usr/bin/naemon --verify-config /etc/naemon/naemon.cfg"
I will write a pull request for this. Does anyone have a chance to test this on non-centos systemd-systems?
Regards, Andreas
Can you put that into a Pull Request, then i can test it against our build servers.
Looks good, works with all other systemd systems too.
Hi all,
upgrading our naemon packages always results in start-errors of systemd naemon.service on Centos 7.x. The reason for the startup-failure is the systemd ExecStartPre command verifying the naemon-config. This line is generated by using the file "naemon-core/daemon-systemd.in":
ExecStartPre=/bin/su naemon --login --shell=/bin/sh --command="/usr/bin/naemon --verify-config /etc/naemon/naemon.cfg"
The quoting seems to be wrong, see /var/log/messages: ... Sep 14 11:34:15 de01asr0053 systemd: Starting Cluster Controlled naemon... Sep 14 11:34:15 de01asr0053 mkdir: /usr/bin/mkdir: cannot create directory ‘/var/run/naemon’: File exists Sep 14 11:34:15 de01asr0053 su: /usr/bin/su: unrecognized option '--verify-config' Sep 14 11:34:15 de01asr0053 systemd: naemon.service: control process exited, code=exited status=1 Sep 14 11:34:15 de01asr0053 su: Usage: Sep 14 11:34:15 de01asr0053 su: su [options] [-] [USER [arg]...] Sep 14 11:34:15 de01asr0053 su: Change the effective user id and group id to that of USER. Sep 14 11:34:15 de01asr0053 su: A mere - implies -l. If USER not given, assume root. Sep 14 11:34:15 de01asr0053 su: Options: Sep 14 11:34:15 de01asr0053 su: -m, -p, --preserve-environment do not reset environment variables Sep 14 11:34:15 de01asr0053 su: -g, --group specify the primary group
Sep 14 11:34:15 de01asr0053 su: -G, --supp-group specify a supplemental group
Sep 14 11:34:15 de01asr0053 su: -, -l, --login make the shell a login shell
Sep 14 11:34:15 de01asr0053 su: -c, --command pass a single command to the shell with -c
Sep 14 11:34:15 de01asr0053 su: --session-command pass a single command to the shell with -c
Sep 14 11:34:15 de01asr0053 su: and do not create a new session
Sep 14 11:34:15 de01asr0053 su: -f, --fast pass -f to the shell (for csh or tcsh)
Sep 14 11:34:15 de01asr0053 su: -s, --shell run shell if /etc/shells allows it
Sep 14 11:34:15 de01asr0053 su: -h, --help display this help and exit
Sep 14 11:34:15 de01asr0053 su: -V, --version output version information and exit
Sep 14 11:34:15 de01asr0053 su: For more details see su(1).
Sep 14 11:34:15 de01asr0053 systemd: Failed to start Cluster Controlled naemon.
Sep 14 11:34:15 de01asr0053 systemd: Unit naemon.service entered failed state.
Sep 14 11:34:15 de01asr0053 systemd: naemon.service failed.
...
Regards, Andreas