]> err.no Git - systemd/commitdiff
machine-id: don't delete runtime machine-id, and place it in /run
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Apr 2012 10:49:52 +0000 (12:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Apr 2012 11:20:33 +0000 (13:20 +0200)
src/machine-id-setup.c

index 0ee3cd7ae1ef447359d78d1f6e0e10b20b033e1e..94198cb83bba4de4ed6d3b8ac74589064bc8e6f2 100644 (file)
@@ -235,28 +235,25 @@ int machine_id_setup(void) {
         fd = -1;
 
         /* Hmm, we couldn't write it? So let's write it to
-         * /run/systemd/machine-id as a replacement */
-
-        mkdir_p("/run/systemd", 0755);
+         * /run/machine-id as a replacement */
 
         m = umask(0022);
-        r = write_one_line_file("/run/systemd/machine-id", id);
+        r = write_one_line_file("/run/machine-id", id);
         umask(m);
 
         if (r < 0) {
-                log_error("Cannot write /run/systemd/machine-id: %s", strerror(-r));
+                log_error("Cannot write /run/machine-id: %s", strerror(-r));
 
-                unlink("/run/systemd/machine-id");
+                unlink("/run/machine-id");
                 goto finish;
         }
 
         /* And now, let's mount it over */
-        r = mount("/run/systemd/machine-id", "/etc/machine-id", "bind", MS_BIND|MS_RDONLY, NULL) < 0 ? -errno : 0;
-        unlink("/run/systemd/machine-id");
-
-        if (r < 0)
+        r = mount("/run/machine-id", "/etc/machine-id", "bind", MS_BIND|MS_RDONLY, NULL) < 0 ? -errno : 0;
+        if (r < 0) {
+                unlink("/run/machine-id");
                 log_error("Failed to mount /etc/machine-id: %s", strerror(-r));
-        else
+        else
                 log_info("Installed transient /etc/machine-id file.");
 
 finish: