Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "machine-id-setup.h"
#include "macro.h"
#include "util.h"
+#include "mkdir.h"
#include "log.h"
#include "virt.h"
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: