X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fuser-sessions.c;h=df46b76c872842597597e1661da4b7e29ec1a329;hp=4518d953ed7bebc80b3f110d2981ee3961391278;hb=ad293f5a94d8124ece7d1cb860952a87b1c8d98f;hpb=db019b8dd206844dcf5fde661256dc71fcc06fef diff --git a/src/user-sessions.c b/src/user-sessions.c index 4518d953e..df46b76c8 100644 --- a/src/user-sessions.c +++ b/src/user-sessions.c @@ -39,6 +39,8 @@ int main(int argc, char*argv[]) { log_parse_environment(); log_open(); + umask(0022); + if (streq(argv[1], "start")) { int q = 0, r = 0; @@ -48,8 +50,16 @@ int main(int argc, char*argv[]) { } 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) @@ -59,7 +69,7 @@ int main(int argc, char*argv[]) { 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) {