]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine-id-setup: use isempty() instead of empty_or_root()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 24 May 2024 16:45:07 +0000 (01:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 24 May 2024 16:45:10 +0000 (01:45 +0900)
This effectively reverts ba540e9f1c29b430ac916918410c27171d14ab95.

https://github.com/systemd/systemd/pull/32915#discussion_r1608258136
> In many cases we allow --root=/ as a mechanism for forcing an "offline" mode,
> while still operating on the root dir. if we do the getenv_for_pid() thing
> below I'd claim this is very much an "online" operation, and hence --root=/
> should really disable that.

src/shared/machine-id-setup.c

index 48ee2dd3061c79afc08a18b049cbbb69fa5b97ad..66d2f300dff70b22b40015554e783d52ffe73c26 100644 (file)
@@ -57,7 +57,7 @@ static int acquire_machine_id(const char *root, sd_id128_t *ret) {
         /* First, try reading the machine ID from /run/machine-id, which may not be mounted on
          * /etc/machine-id yet. This is important on switching root, Otherwise, machine ID may be changed
          * after the transition. */
-        if (empty_or_root(root) && running_in_chroot() <= 0 &&
+        if (isempty(root) && running_in_chroot() <= 0 &&
             id128_read("/run/machine-id", ID128_FORMAT_PLAIN, ret) >= 0) {
                 log_info("Reusing machine ID stored in /run/machine-id.");
                 return 1; /* Indicate that the machine ID is reused. */
@@ -70,7 +70,7 @@ static int acquire_machine_id(const char *root, sd_id128_t *ret) {
                 return 0;
         }
 
-        if (empty_or_root(root) && running_in_chroot() <= 0) {
+        if (isempty(root) && running_in_chroot() <= 0) {
                 /* Let's use a system credential for the machine ID if we can */
                 if (acquire_machine_id_from_credential(ret) >= 0)
                         return 0;