From 30382bfcc0f64f451bc084c9657a546cb34492a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= <travier@redhat.com>
Date: Fri, 1 Oct 2021 16:35:57 +0200
Subject: [PATCH 2228/2246] auditd.service: Restart 'on-failure', ignoring some
 exit codes (#217)

Use `Restart=on-failure` to automatically restart `auditd`. Do not
restart for intentional exits. See EXIT CODES section in auditd(8).

See:
- https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
- https://www.freedesktop.org/software/systemd/man/systemd.service.html#RestartPreventExitStatus=

Fixes: https://github.com/linux-audit/audit-userspace/issues/211
---
 init.d/auditd.service | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/init.d/auditd.service b/init.d/auditd.service
index 67cda58..e801281 100644
--- a/init.d/auditd.service
+++ b/init.d/auditd.service
@@ -27,6 +27,9 @@ ExecStartPost=-/sbin/augenrules --load
 # By default we don't clear the rules on exit. To enable this, uncomment
 # the next line after copying the file to /etc/systemd/system/auditd.service
 #ExecStopPost=/sbin/auditctl -R /etc/audit/audit-stop.rules
+Restart=on-failure
+# Do not restart for intentional exits. See EXIT CODES section in auditd(8).
+RestartPreventExitStatus=2 4 6
 
 ### Security Settings ###
 MemoryDenyWriteExecute=true
-- 
1.8.3.1

