Subject: bug#76244: Shepherd does not support UTF-8 in the log output

From: Ludovic Courtès <[email-masked]>
Date: Thu, 13 Feb 2025 10:49:29 +0100

Hi,

Tomas Volf <[email-masked]> skribis:

> $ herd spawn transient -- $(which sh) -c 'echo "猫"'
> Spawning transient service for ("/run/current-system/profile/bin/sh" "-c" "echo \"???\"").

Actually, it’s not logging, it’s the command itself that’s not
interpreted as UTF-8:

--8<---------------cut here---------------start------------->8---
$ cat /tmp/t.sh
#!/bin/sh
echo "猫"
$ sudo herd spawn transient /tmp/t.sh
Spawning transient service for ("/tmp/t.sh").
Service user-homes has been started.
Starting service transient-375...
Service transient-375 started.
Service transient-375 running with value #<<process> id: 12840 command: ("/tmp/t.sh")>.
Service transient-375 has been started.
$ sudo herd status root
● Status of root:
  It is running since Mon 10 Feb 2025 08:38:03 AM CET (3 days ago).
  Main PID: 1
  Command: /gnu/store/n87px1cazqkav83npg80ccp1n777j08s-guile-3.0.9/bin/guile --no-auto-compile /gnu/store/ci2c9iwqaa1zpr38wc58419m9yh8g798-shepherd-1.0.99-git/bin/shepherd --config /gnu/store/6c9xhch8vqddwl81qj28d7c7k6zwr4ms-shepherd.conf
  It is enabled.
  Provides: root shepherd
  Custom actions: help status halt power-off kexec load eval unload reload daemonize restart
  Will not be respawned.

Recent messages (use '-n' to view more or less):
  2025-02-13 10:45:45 Service transient-375 running with value #<<process> id: 12840 command: ("/tmp/t.sh")>.
  2025-02-13 10:45:45 Service transient-375 has been started.
  2025-02-13 10:45:45 [t.sh] 猫
  2025-02-13 10:45:45 Service transient-375 has been disabled.
  2025-02-13 10:45:45 Transient service transient-375 terminated, now unregistered.
--8<---------------cut here---------------end--------------->8---

Well there’s also a problem with logging after all:

--8<---------------cut here---------------start------------->8---
$ sudo tail -4 /var/log/messages
2025-02-13 10:45:45 localhost shepherd[1]: Service transient-375 has been started.
2025-02-13 10:45:45 localhost shepherd[1]: [t.sh] ?
2025-02-13 10:45:45 localhost shepherd[1]: Service transient-375 has been disabled.
2025-02-13 10:45:45 localhost shepherd[1]: Transient service transient-375 terminated, now unregistered.
--8<---------------cut here---------------end--------------->8---

I’m surprised because I’m pretty sure there are tests for that.  I’ll
check later.

Ludo’.