43ff24c
From 59afe82145260430e426cf4ac999e8fc69e2a288 Mon Sep 17 00:00:00 2001
43ff24c
From: Lennart Poettering <lennart@poettering.net>
43ff24c
Date: Fri, 4 Jul 2014 03:13:05 +0200
43ff24c
Subject: [PATCH] main: change check whether /etc is unpopulated to look for
43ff24c
 /etc/machine-id
43ff24c
43ff24c
Previously, we checked whether /etc was completely empty. This makes it
43ff24c
difficult though for container managers such as nspawn to install a
43ff24c
small number of files (such as /etc/timezone), and have the system
43ff24c
otherwise populate its own tree.
43ff24c
43ff24c
Hence, change this by looking for /etc/machine-id, which should be a
43ff24c
good sign whether /etc is populated or not.
43ff24c
43ff24c
(cherry picked from commit baa1bdf70f21848fbe01d3f383ae0f59d86a9bf3)
43ff24c
---
43ff24c
 src/core/main.c | 2 +-
43ff24c
 1 file changed, 1 insertion(+), 1 deletion(-)
43ff24c
43ff24c
diff --git a/src/core/main.c b/src/core/main.c
43ff24c
index 38835fc620..1ca899998e 100644
43ff24c
--- a/src/core/main.c
43ff24c
+++ b/src/core/main.c
43ff24c
@@ -1543,7 +1543,7 @@ int main(int argc, char *argv[]) {
43ff24c
                 if (in_initrd())
43ff24c
                         log_info("Running in initial RAM disk.");
43ff24c
 
43ff24c
-                empty_etc = dir_is_empty("/etc") > 0;
43ff24c
+                empty_etc = access("/etc/machine-id", F_OK) < 0;
43ff24c
                 if (empty_etc)
43ff24c
                         log_info("Running with unpopulated /etc.");
43ff24c
         } else {