[systemd-devel] Are Pathnames in /tmp/systemd-private-foo predictable?

Lennart Poettering lennart at poettering.net
Mon Jun 14 07:59:24 UTC 2021


On So, 13.06.21 21:04, Marc Haber (mh+systemd-devel at zugschlus.de) wrote:

> Hi,
>
> I am wondering where the 32 xdigit number in pathnames like
>
> systemd-private-27aa635a15cf4da0a7ebda10f25c3950-chrony.service-9DShFi/
>
> comes from. I always had the impression that it's the systemd/dbus
> machine id, but that does not seem to be the case. Is that just an
> arbitrary random number, or can it be predicted in a way?

It's the boot ID, i.e. /proc/sys/kernel/random/boot_id. We include it
in the name so that we can distinguish such dirs of the current boot
from those of earlier boots (which can be retained because of abnormal
shutdown or so). In the latter case we can safely remove them to avoid
collecting left-over directories.

The dirs are not predictable in their name. The 6 char suffix you see
is the mkstemp() randomized suffix to make them safe against collision
attacks.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list