From 1180849b44783e0706431e6082a988d17e8d9e6b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 1 Apr 2026 21:05:57 -0400 Subject: [PATCH] Add systemd unit files for malpd and support systemd socket activation --- bin/malpd | 14 +++++++++----- systemd/malpd.service | 10 ++++++++++ systemd/malpd.socket | 10 ++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 systemd/malpd.service create mode 100644 systemd/malpd.socket diff --git a/bin/malpd b/bin/malpd index a018eaa..c196ca6 100755 --- a/bin/malpd +++ b/bin/malpd @@ -62,12 +62,16 @@ if Process.uid != 0 exit(1) end -FileUtils.mkdir_p(File.dirname(SOCKET_PATH)) -FileUtils.rm_f(SOCKET_PATH) +if ENV["LISTEN_FDS"] + server = UNIXServer.for_fd(3) +else + FileUtils.mkdir_p(File.dirname(SOCKET_PATH)) + FileUtils.rm_f(SOCKET_PATH) -server = UNIXServer.new(SOCKET_PATH) -File.chmod(0660, SOCKET_PATH) -FileUtils.chown(nil, "apache", SOCKET_PATH) + server = UNIXServer.new(SOCKET_PATH) + File.chmod(0660, SOCKET_PATH) + FileUtils.chown(nil, "apache", SOCKET_PATH) +end Signal.trap("TERM") { server.close } Signal.trap("INT") { server.close } diff --git a/systemd/malpd.service b/systemd/malpd.service new file mode 100644 index 0000000..978b6e3 --- /dev/null +++ b/systemd/malpd.service @@ -0,0 +1,10 @@ +[Unit] +Description=MALP monitoring daemon +Requires=malpd.socket + +[Service] +Type=simple +ExecStart=/var/www/malp/bin/malpd + +[Install] +WantedBy=multi-user.target diff --git a/systemd/malpd.socket b/systemd/malpd.socket new file mode 100644 index 0000000..295cc77 --- /dev/null +++ b/systemd/malpd.socket @@ -0,0 +1,10 @@ +[Unit] +Description=malpd Unix socket + +[Socket] +ListenStream=/run/malpd/malpd.sock +SocketGroup=apache +SocketMode=0660 + +[Install] +WantedBy=sockets.target