]> git.ipfire.org Git - thirdparty/systemd.git/commit
Use paths specified from environment variables for /etc configuration files
authorValentin David <valentin.david@canonical.com>
Mon, 10 Mar 2025 09:53:41 +0000 (10:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Jun 2025 13:32:11 +0000 (15:32 +0200)
commit0dc39dffbd4525e79d7a1537b5c95780ba4f9727
tree231388a7410cea5139bb2128206d2f82226a0d4f
parentfa34fda2eb6629f55c183ad64fa8f9ba445d6f52
Use paths specified from environment variables for /etc configuration files

Some configuration files that need updates are directly under in /etc. To
update them atomically, we need write access to /etc. For Ubuntu Core this is
an issue as /etc is not writable. Only a selection of subdirectories can be
writable. The general solution is symlinks or bind mounts to writable places.
But for atomic writes in /etc, that does not work. So Ubuntu has had a patch
for that that did not age well.

Instead we would like to introduce some environment variables for alternate
paths.

 * SYSTEMD_ETC_HOSTNAME: /etc/hostname
 * SYSTEMD_ETC_MACHINE_INFO: /etc/machine-info
 * SYSTEMD_ETC_LOCALTIME: /etc/localtime
 * SYSTEMD_ETC_LOCALE_CONF: /etc/locale.conf
 * SYSTEMD_ETC_VCONSOLE_CONF: /etc/vconsole.conf
 * SYSTEMD_ETC_ADJTIME: /etc/adjtime

While it is for now expected that there is a symlink from the standard, we
still try to read them from that alternate path. This is important for
`/etc/localtime`, which is a symlink, so we cannot have an indirect symlink or
bind mount for it.

Since machine-id is typically written only once and not updated. This commit
does not cover it. An initrd can properly create it and bind mount it.
19 files changed:
docs/ENVIRONMENT.md
src/basic/hostname-util.c
src/basic/hostname-util.h
src/basic/time-util.c
src/basic/time-util.h
src/core/manager.c
src/firstboot/firstboot.c
src/hostname/hostnamed.c
src/locale/localed-util.c
src/shared/env-file-label.c [new file with mode: 0644]
src/shared/hostname-setup.c
src/shared/locale-setup.c
src/shared/locale-setup.h
src/timedate/timedated.c
test/units/TEST-30-ONCLOCKCHANGE.sh
test/units/TEST-45-TIMEDATE.sh
test/units/TEST-71-HOSTNAME.sh
test/units/TEST-73-LOCALE.sh
test/units/TEST-74-AUX-UTILS.firstboot.sh