How to Run ASSP As A Systemd Service With Systemctl

Running the Anti-Spam SMTP Proxy (ASSP) reliably on a modern Linux server requires a proper service manager. By default, ASSP needs to start as root to bind to privileged mail ports (like port 25), after which it forks and spawns its main worker processes under a non-privileged user like nobody.

Using a custom systemd service file allows Linux to seamlessly handle this handoff, manage automatic restarts on failure, and handle process tracking without dealing with legacy PID files.


The Complete systemd Service File

Create a new service unit configuration file using your preferred text editor:

sudo nano /etc/systemd/system/assp.service

Paste the following optimized configuration into the file:

[Unit]
Description=ASSP (Anti-Spam SMTP Proxy)
After=network.target

[Service]
Type=forking
WorkingDirectory=/usr/local/assp
ExecStart=/usr/bin/perl /usr/local/assp/assp.pl
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Why This Configuration Works

  • Type=forking: Crucial for ASSP. It tells systemd that the initial process (started as root) will spawn a child process and then exit. systemd will wait for this handoff to complete rather than assuming the application crashed.
  • Root Execution: By omitting a User= directive in the service file, systemd launches the Perl script as root. This gives ASSP the authority to bind to port 25 before it internally drops its own privileges down to the nobody process.
  • No PID File Required: Modern systemd uses Linux control groups (cgroups) to track process trees. It will automatically detect and monitor the spawned nobody worker process without needing a legacy PIDFile directive.
  • Automatic Restarts: The Restart=always and RestartSec=5 directives ensure that if ASSP experiences a memory leak or crash, the system will automatically spin it back up after 5 seconds.

Activating and Managing ASSP

Once your service file is saved, run the following sequence to notify the system manager, enable the boot hook, and launch the proxy:

# 1. Reload systemd to detect the new service file
sudo systemctl daemon-reload

# 2. Enable ASSP to start automatically on system boot
sudo systemctl enable assp

# 3. Start the ASSP proxy service immediately
sudo systemctl start assp

Verifying the Service Status

To ensure that systemd is accurately tracking the background process tree, check the service status:

sudo systemctl status assp

You should see an active (running) status, and the CGroup section at the bottom will display the active Perl processes running under the nobody user.

Monitoring Real-Time Logs

Because systemd manages the execution environment, all standard output from ASSP is sent straight to the system journal. You can follow live spam-filtering logs using journalctl:

sudo journalctl -u assp -f

ASSP mod_inst.pl Error After Upgrading Fedora 42 to 43

I recently upgraded my system from Fedora 42 to Fedora 43 after Fedora 42 reached end-of-life.

When I started ASSP, I received errors indicating that the required Perl modules were incorrect or missing, so I decided to run mod_inst.pl again to reinstall the necessary modules.

I downloaded the latest mod_inst.pl from the ASSP website and ran it, but it immediately failed with the following error:

error calling required module LWP::Simple - Proxy must be specified as absolute URI; 'proxyuser' is not at /usr/local/share/perl5/5.42/LWP/Simple.pm line 30.

After spending quite a while searching for solutions, most references pointed towards issues with the proxy settings. However, my assp.cfg file had blank values for proxyserver, proxyuser, and proxypass, and this configuration had worked fine before the Fedora upgrade.

While debugging mod_inst.pl and mod_inst_ocr.pl, I noticed the following commented-out section around line 722:

###########################################
# please change the following to your needs
#
# uncomment and change the following line(s) if you use a HTTP-Proxy and ENV is not set
#$ENV{HTTP_proxy} = 'http://yourproxy:port';
#$ENV{HTTP_proxy_user} = 'proxy-user';
#$ENV{HTTP_proxy_pass} = 'proxy-user-password';
###########################################

To resolve the issue, I uncommented the HTTP_proxy line and set it to my proxy server:

$ENV{HTTP_proxy} = 'http://10.0.0.1:765';

After making this change, mod_inst.pl ran successfully and installed the required modules without any further errors.

This information may already exist somewhere in the documentation, but I couldn’t find it. Hopefully this helps anyone else who encounters the same issue after upgrading Fedora or Perl.