sd-daemon: escape special characters in notification logging text

Follow-up for 21eb636aaa

Our sd_notify() protocol uses newline as separator, which
is not suitable for direct logging.
This commit is contained in:
Mike Yuan
2026-02-10 21:53:39 +01:00
parent 14af94428a
commit f9e0a62392
+6 -1
View File
@@ -13,6 +13,7 @@
#include "alloc-util.h"
#include "errno-util.h"
#include "escape.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fs-util.h"
@@ -633,7 +634,11 @@ static int pid_notify_with_fds_internal(
return log_debug_errno(SYNTHETIC_ERRNO(EPROTO), "Unexpectedly received data on notify socket.");
}
log_debug("Notify message sent to '%s': \"%s\"", e, state);
if (DEBUG_LOGGING) {
_cleanup_free_ char *escaped = xescape_full(state, "\"", /* console_width = */ SIZE_MAX, XESCAPE_8_BIT);
log_debug("Notify message sent to '%s': \"%s\"", e, escaped ?: state);
}
return 1;
}