}
if (unlink("/etc/nologin") < 0 && errno != ENOENT) {
- log_error("Failed to remove /etc/nologin file: %m");
- q = -errno;
+
+ /* If the file doesn't exist and /etc simply
+ * was read-only (in which case unlink()
+ * returns EROFS even if the file doesn't
+ * exist), don't complain */
+
+ if (errno != EROFS || access("/etc/nologin", F_OK) >= 0) {
+ log_error("Failed to remove /etc/nologin file: %m");
+ q = -errno;
+ }
}
if (r < 0 || q < 0)
int r, q;
char *cgroup_user_tree = NULL;
- if ((r = write_one_line_file("/run/nologin", "System is going down.")) < 0)
+ if ((r = write_one_line_file_atomic("/run/nologin", "System is going down.")) < 0)
log_error("Failed to create /run/nologin: %s", strerror(-r));
if ((q = cg_get_user_path(&cgroup_user_tree)) < 0) {