Re: Best place for per-daemon log files?

From: Peter Pentchev <roam_at_ringlet.net>
Date: Wed, 17 Sep 2025 18:23:55 +0300

On Tue, Sep 16, 2025 at 11:32:33AM -0400, Steve Litt wrote:
> aitor said on Tue, 16 Sep 2025 16:47:04 +0200
>
> >Hi Steve,
> >
> >On 16/9/25 3:43, Steve Litt wrote:
> >> So where do all of you think the logs belong for a runsvdir run as a
> >> normal user (slitt in this case)?
> >
> >The drawback of using /home is that it may be mounted over network
> >filesystems.
> >
> >I'm aware that you haven't great sympathy for the hipsters of
> >freedesktop, but there is a directory used by the different user
> >services that need a placeĀ for their lock files, pid files, log files
> >and sockets.
> >
> >https://specifications.freedesktop.org/basedir-spec/latest
> >
> >According to the specifications:
> >
> >"There is a single base directory relative to which
> > user-specific runtime files and other file objects should
> > be placed. This directory is defined by the environment
> > variable|$XDG_RUNTIME_DIR"|
>
> Thanks Aitor!
>
> I just echoed XDG_RUNTIME_DIR on my Void Linux machine and got no
> output. So $XDG_RUNTIME_DIR might be a great alternative for
> freedesktopy distros, but it's not universal.
>
> >I thought that "/run/user/$UID" was created by pam-systemd, but this
> >directory already exists in my devuan system.
>
> My Void Linux system has /run/user already, and it would be simple to
> create a /run/user/slitt directory that's owned by slitt. Below that I
> could have /run/user/slitt/fetchmail, /run/user/slitt/pulseaudio,
> /run/user/slitt/pager, etc. This would certainly work and is certainly
> reasonable, always assuming /run is on a partition big enough to
> accommodate growing log files.
>
> >Prior to it, user
> >services typically stored their files in /tmp. Maybe they considered
> >it inappropriate as it's writable by everyone.
>
> /tmp doesn't work because it's often a tmpfs "filesystem", in which
> case all your logs disappear upon reboot. And even if /tmp is a real
> disk partition, it's often not big enough to accommodate lots of log
> files. And yes, it's writeable by anybody, and in certain cases a
> badguy could delete log files or modify them.

There may be a bit of a misconception or miscommunication here.
On Linux systems, /run is practically certaion to be mounted on
a tmpfs of some kind: its explicit purpose is to be volatile,
for this boot only. It is similar to /var/run, but one of its main
advantages is that it will always be cleaned upon boot.
See e.g. https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html

So I don't think $XDG_RUNTIME_DIR (which, according to the spec that
Aitor linked to, if not set, should default to /run/user/<uid>, so
that's most probably why you couldn't find it in your environment -
nothing has seen fit to override it) would be a good place for
logs that may need to survive a reboot.

G'luck,
Peter

-- 
Peter Pentchev  roam_at_ringlet.net roam_at_debian.org peter_at_morpheusly.com
PGP key:        https://www.ringlet.net/roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Received on Wed Sep 17 2025 - 17:23:55 CEST

This archive was generated by hypermail 2.4.0 : Wed Sep 17 2025 - 17:24:28 CEST