Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.4.5 - ??? ?? ????
===================
Changed:
* check config before reload/start will be done (#364) (ccztux)


1.4.4 - Jun 03 2025
===================
Features:
Expand Down
24 changes: 24 additions & 0 deletions daemon-init.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ status() {
}

start() {
check_config
test -x $exec || exit 5
test -f $config || exit 6
echo -n "Starting $prog: "
Expand Down Expand Up @@ -118,6 +119,7 @@ restart() {
}

reload() {
check_config
echo -n "Reloading $prog: "
if [ -e $pidfile ]; then
PID=`cat $pidfile`;
Expand All @@ -133,6 +135,27 @@ force_reload() {
restart
}

check_config() {
echo -n "Running configuration check... "

if type runuser >/dev/null 2>&1; then
runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $exec -vp $config" >/dev/null 2>&1;
else
/bin/su - -s /bin/sh $user -c "$corelimit >/dev/null 2>&1 ; $exec -vp $config" >/dev/null 2>&1;
fi

retval=$?

if [ $retval == 0 ] ;then
echo "OK"
return $retval
else
echo "CONFIG ERROR!"
echo "Reload/start aborted. Check your Naemon configuration."
exit $retval
fi
}

case "$1" in
start)
$1
Expand Down Expand Up @@ -168,6 +191,7 @@ case "$1" in
restart
;;
configtest|check|checkconfig)
check_config
if command -v runuser >/dev/null 2>&1; then
runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $exec -vp $config"
else
Expand Down
1 change: 1 addition & 0 deletions daemon-systemd.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PIDFile=@lockfile@
PermissionsStartOnly=true
ExecStartPre=/bin/su naemon --login --shell=/bin/sh "--command=@bindir@/naemon --verify-config @pkgconfdir@/naemon.cfg"
ExecStart=@bindir@/naemon --daemon @pkgconfdir@/naemon.cfg
ExecReload=/bin/su naemon --login --shell=/bin/sh "--command=@bindir@/naemon --verify-config @pkgconfdir@/naemon.cfg"
ExecReload=/bin/kill -HUP $MAINPID
User=naemon
Group=naemon
Expand Down