user-sessions: ignore EROFS when unlinking /etc/nologin if the file doesn't exist anyway

This commit is contained in:
Lennart Poettering 2011-05-10 18:55:39 +02:00
parent e4c1d706bd
commit bd118f8e22
1 changed files with 10 additions and 2 deletions

View File

@ -48,8 +48,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)