
Originally Posted by
JulinaB
If I kill the daemon started by systemd and then manually start it as follows (using the same command arguments), but do so by sudoing to the same fetchmail user:
Code:
skylab:~ # ps -ef | grep fetch
fetchma+ 1492 1 0 12:48 ? 00:00:00 /usr/bin/fetchmail -d 60 -a -L /var/log/fetchmail -f /etc/fetchmailrc
root 7951 7902 0 14:06 pts/0 00:00:00 grep --color=auto fetch
skylab:~ # kill 1492
skylab:~ # ps -ef | grep fetch
root 7977 7902 0 14:06 pts/0 00:00:00 grep --color=auto fetch
skylab:~ # sudo -u fetchmail /usr/bin/fetchmail -d 60 -a -L /var/log/fetchmail -f /etc/fetchmailrc
fetchmail: warning: multidrop for 192.168.100.1 requires envelope option!
fetchmail: warning: Do not ask for support if all mail goes to postmaster!
skylab:~ # ps -ef | grep fetch
fetchma+ 7981 1 0 14:07 ? 00:00:00 /usr/bin/fetchmail -d 60 -a -L /var/log/fetchmail -f /etc/fetchmailrc
root 7983 7902 0 14:07 pts/0 00:00:00 grep --color=auto fetch
It works! So there is something about the service that is started by systemd that prevents sudo working.
This is the /etc/systemd/system/multi-user.target.wants/fetchmail.service file.
Code:
[Unit]
Description=A remote-mail retrieval utility
After=network.target
[Service]
# added automatically, for details please see
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
PrivateDevices=true
ProtectHostname=true
ProtectClock=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
RestrictRealtime=true
# end of automatic additions
EnvironmentFile=-/etc/sysconfig/fetchmail
User=fetchmail
ExecStart=/usr/lib/fetchmail-systemd-exec
RestartSec=1
[Install]
WantedBy=multi-user.target
FYI: I am using fetchmail.service for many years and it never showed unexpected behavior you are claiming to observe.
Code:
erlangen:~ # systemctl cat fetchmail.service
# /usr/lib/systemd/system/fetchmail.service
[Unit]
Description=A remote-mail retrieval utility
After=network.target
[Service]
# added automatically, for details please see
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
PrivateDevices=true
ProtectHostname=true
ProtectClock=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
RestrictRealtime=true
# end of automatic additions
EnvironmentFile=-/etc/sysconfig/fetchmail
User=fetchmail
ExecStart=/usr/libexec/fetchmail-systemd-exec
RestartSec=1
[Install]
WantedBy=multi-user.target
erlangen:~ #
I suggest you first check whether a direct invocation works:
Code:
erlangen:~ # systemctl stop fetchmail.service
Warning: Stopping fetchmail.service, but it can still be activated by:
fetchmail.timer
erlangen:~ # systemctl status fetchmail.service
× fetchmail.service - A remote-mail retrieval utility
Loaded: loaded (/etc/systemd/system/fetchmail.service; static)
Active: failed (Result: exit-code) since Wed 2022-05-18 16:05:37 CEST; 13s ago
TriggeredBy: ● fetchmail.timer
Process: 26340 ExecStart=/usr/libexec/fetchmail-systemd-exec (code=exited, status=1/FAILURE)
Main PID: 26340 (code=exited, status=1/FAILURE)
CPU: 209ms
May 18 16:01:05 erlangen systemd[1]: Started A remote-mail retrieval utility.
May 18 16:01:05 erlangen fetchmail[26340]: fetchmail 6.4.30 Dämon wird gestartet
May 18 16:05:37 erlangen systemd[1]: Stopping A remote-mail retrieval utility...
May 18 16:05:37 erlangen fetchmail[26340]: beendet mit Signal 15
May 18 16:05:37 erlangen systemd[1]: fetchmail.service: Main process exited, code=exited, status=1/FAILURE
May 18 16:05:37 erlangen systemd[1]: fetchmail.service: Failed with result 'exit-code'.
May 18 16:05:37 erlangen systemd[1]: Stopped A remote-mail retrieval utility.
erlangen:~ #