mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-30 14:01:57 -09:00
package/audit/S02auditd: fix shellcheck and check-package warnings
Fixup S20audit to pass shellcheck -oall and check-package. The file now
closely resembles package/busybox/S01syslogd.
Tested with qemu_x86_64_defconfig. start, stop, restart, reload, and rotate
all work with busybox ash shell.
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
[Arnout: remove it from .checkpackageignore]
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
(cherry picked from commit cbabeb5077)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
committed by
Thomas Perale
parent
276fc22e66
commit
01296fc5a8
@@ -280,7 +280,6 @@ package/asterisk/0004-install-samples-need-the-data-files.patch lib_patch.Upstre
|
|||||||
package/at/0001-Makefile.in-fix-make-install-for-non-root-don-t-stri.patch lib_patch.Upstream
|
package/at/0001-Makefile.in-fix-make-install-for-non-root-don-t-stri.patch lib_patch.Upstream
|
||||||
package/at/S99at lib_sysv.Indent lib_sysv.Variables
|
package/at/S99at lib_sysv.Indent lib_sysv.Variables
|
||||||
package/attr/0001-build-with-older-GCCs.patch lib_patch.Upstream
|
package/attr/0001-build-with-older-GCCs.patch lib_patch.Upstream
|
||||||
package/audit/S02auditd Shellcheck lib_sysv.Variables
|
|
||||||
package/aufs-util/0001-remove-user-settings.patch lib_patch.Upstream
|
package/aufs-util/0001-remove-user-settings.patch lib_patch.Upstream
|
||||||
package/aufs-util/0002-no-check-ver.patch lib_patch.Upstream
|
package/aufs-util/0002-no-check-ver.patch lib_patch.Upstream
|
||||||
package/aufs-util/0003-no-strip-lib.patch lib_patch.Upstream
|
package/aufs-util/0003-no-strip-lib.patch lib_patch.Upstream
|
||||||
|
|||||||
@@ -8,52 +8,74 @@
|
|||||||
# will be sent to syslog.
|
# will be sent to syslog.
|
||||||
#
|
#
|
||||||
|
|
||||||
NAME=auditd
|
DAEMON="auditd"
|
||||||
DAEMON=/usr/sbin/${NAME}
|
PIDFILE="/var/run/${DAEMON}.pid"
|
||||||
CONFIG=/etc/audit/auditd.conf
|
|
||||||
PIDFILE=/var/run/${NAME}.pid
|
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
printf "Starting ${NAME}: "
|
printf "Starting %s: " "${DAEMON}"
|
||||||
|
|
||||||
# Create dir to store log files in if one doesn't exist. Create
|
# Create dir to store log files in if one doesn't exist. Create
|
||||||
# the directory with SELinux permissions if possible
|
# the directory with SELinux permissions if possible
|
||||||
command -v selabel_lookup >/dev/null 2>&1
|
if command -v selabel_lookup >/dev/null 2>&1; then
|
||||||
if [ $? = 0 ]; then
|
audit_log_selable="$(selabel_lookup -b file -k /var/log/audit | cut -d ' ' -f 3)"
|
||||||
mkdir -p /var/log/audit -Z `selabel_lookup -b file -k /var/log/audit | cut -d ' ' -f 3`
|
mkdir -p /var/log/audit -Z "${audit_log_selable}"
|
||||||
else
|
else
|
||||||
mkdir -p /var/log/audit
|
mkdir -p /var/log/audit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run audit daemon executable
|
start-stop-daemon --start --background --make-pidfile \
|
||||||
start-stop-daemon -S -q -p ${PIDFILE} --exec ${DAEMON}
|
--pidfile "${PIDFILE}" --exec "/usr/sbin/${DAEMON}"
|
||||||
|
status=$?
|
||||||
if [ $? = 0 ]; then
|
if [ "${status}" -eq 0 ]; then
|
||||||
# Load the default rules
|
# Load the default rules
|
||||||
test -f /etc/audit/rules.d/audit.rules && /usr/sbin/auditctl -R /etc/audit/rules.d/audit.rules >/dev/null
|
test -f /etc/audit/rules.d/audit.rules && /usr/sbin/auditctl -R /etc/audit/rules.d/audit.rules >/dev/null
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
|
return "${status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop(){
|
stop(){
|
||||||
printf "Stopping ${NAME}: "
|
printf "Stopping %s: " "${DAEMON}"
|
||||||
|
start-stop-daemon --stop --pidfile "${PIDFILE}" --exec "/usr/sbin/${DAEMON}"
|
||||||
start-stop-daemon -K -q -p ${PIDFILE}
|
status=$?
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
if [ "${status}" -eq 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
return "${status}"
|
||||||
|
fi
|
||||||
|
while start-stop-daemon --stop --test --quiet --pidfile "${PIDFILE}" \
|
||||||
|
--exec "/sbin/${DAEMON}"; do
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
rm -f "${PIDFILE}"
|
||||||
|
return "${status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
reload(){
|
reload(){
|
||||||
printf "Reloading ${NAME} configuration: "
|
printf "Reloading %s configuration: " "${DAEMON}"
|
||||||
start-stop-daemon --stop -s 1 -p ${PIDFILE} 1>/dev/null
|
start-stop-daemon --stop --signal HUP --pidfile "${PIDFILE}" 1>/dev/null
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
status=$?
|
||||||
|
if [ "${status}" -eq 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
|
return "${status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
rotate(){
|
rotate(){
|
||||||
printf "Rotating ${NAME} logs: "
|
printf "Rotating %s logs: " "${DAEMON}"
|
||||||
start-stop-daemon --stop -s 10 -p ${PIDFILE} 1>/dev/null
|
start-stop-daemon --stop --signal SIGUSR1 --pidfile "${PIDFILE}" 1>/dev/null
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
status=$?
|
||||||
|
if [ "${status}" -eq 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
|
return "${status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|||||||
Reference in New Issue
Block a user