[PATCH v2] stalld: make syslog logging opt-in by default

Wander Lairson Costa <[email protected]> Thu, 30 Apr 2026 08:13:57 -0300
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
Previously, stalld enabled syslog output unconditionally with no
mechanism to disable it. Users running the daemon from the command
line with verbose logging directed to standard error would still
generate unwanted syslog traffic.

Change the default behavior to make syslog logging strictly opt-in via
the existing command line flag, aligning it with the opt-in nature of
other logging destinations. Update the systemd service configuration
to explicitly pass this flag, ensuring that default systemd
deployments retain their current logging behavior. Finally, introduce
a functional test to verify that syslog remains silent when the flag
is omitted.

Signed-off-by: Wander Lairson Costa <[email protected]>
---
 src/stalld.c                                  |  2 +-
 systemd/stalld.conf                           |  2 +-
 tests/functional/test_logging_destinations.sh | 44 ++++++++++++++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/stalld.c b/src/stalld.c
index d95b48f..a6444f5 100644
--- a/src/stalld.c
+++ b/src/stalld.c
@@ -48,7 +48,7 @@ const char *version = VERSION;
  */
 int config_verbose = 0;
 int config_write_kmesg = 0;
-int config_log_syslog = 1;
+int config_log_syslog = 0;
 int config_log_only = 0;
 int config_foreground = 0;
 
diff --git a/systemd/stalld.conf b/systemd/stalld.conf
index a2a6737..a17c360 100644
--- a/systemd/stalld.conf
+++ b/systemd/stalld.conf
@@ -51,7 +51,7 @@ THRESH="-t 20"
 #     --log_syslog
 #     or Nothing (default)
 # ex: LOGONLY=--log_only
-LOGGING=
+LOGGING=--log_syslog
 
 # Run in the foreground
 # ex: FG=--foreground
diff --git a/tests/functional/test_logging_destinations.sh b/tests/functional/test_logging_destinations.sh
index a25e571..9e259b3 100755
--- a/tests/functional/test_logging_destinations.sh
+++ b/tests/functional/test_logging_destinations.sh
@@ -74,7 +74,7 @@ else
 	echo -e "  ${YELLOW}SKIP${NC}: dmesg not available"
 fi
 
-# Test 3: Syslog (-s, default)
+# Test 3: Syslog (-s)
 test_section "Test 3: Syslog (-s, default)"
 
 # Check if syslog is available
@@ -144,4 +144,46 @@ assert_success "combined logging produces output" test -s "${LOG_FILE}"
 
 stop_stalld
 
+# Test 5: No syslog without -s flag
+test_section "Test 5: No syslog without -s flag"
+
+if [ -n "${SYSLOG_FILE}" ]; then
+	SYSLOG_BEFORE=$(wc -l < "${SYSLOG_FILE}")
+
+	start_stalld -f -l -t 5
+	sleep 1
+
+	SYSLOG_AFTER=$(wc -l < "${SYSLOG_FILE}")
+
+	if [ ${SYSLOG_AFTER} -gt ${SYSLOG_BEFORE} ]; then
+		LINES_ADDED=$((SYSLOG_AFTER - SYSLOG_BEFORE))
+		if tail -n "${LINES_ADDED}" "${SYSLOG_FILE}" | has_stalld_log; then
+			fail "stalld messages found in syslog without -s flag"
+		else
+			pass "no stalld messages in syslog without -s flag"
+		fi
+	else
+		pass "no new messages in syslog (stalld stayed quiet)"
+	fi
+
+	stop_stalld
+elif command -v journalctl >/dev/null 2>&1; then
+	log "Using journalctl instead of syslog file"
+
+	START_TIME=$(date '+%Y-%m-%d %H:%M:%S')
+
+	start_stalld -f -l -t 5
+	sleep 1
+
+	if journalctl -t stalld --since "${START_TIME}" 2>/dev/null | has_stalld_log; then
+		fail "stalld messages found in journal without -s flag"
+	else
+		pass "no stalld messages in journal without -s flag"
+	fi
+
+	stop_stalld
+else
+	log "SKIP: neither syslog nor journalctl available"
+fi
+
 end_test
-- 
2.54.0