nologin: extend the /run/nologin descriptions a bit (#8244)

This is an attempt to improve #8228 a bit, by extending the /run/nologin
a bit, but still keeping it somewhat brief.

On purpose I used the vague wording "unprivileged user" rather than
"non-root user" so that pam_nologin can be updated to disable its
behaviour for members of the "wheel" group one day, and our messages
would still make sense.

See #8228.
This commit is contained in:
Lennart Poettering
2018-02-22 14:21:30 +01:00
committed by Zbigniew Jędrzejewski-Szmek
parent c5c07649c2
commit 6e11e7e67d
5 changed files with 25 additions and 15 deletions

View File

@@ -67,3 +67,19 @@ int fopen_temporary_label(const char *target,
return r;
}
int create_shutdown_run_nologin_or_warn(void) {
int r;
/* This is used twice: once in systemd-user-sessions.service, in order to block logins when we actually go
* down, and once in systemd-logind.service when shutdowns are scheduled, and logins are to be turned off a bit
* in advance. We use the same wording of the message in both cases. */
r = write_string_file_atomic_label("/run/nologin",
"System is going down. Unprivileged users are not permitted to log in anymore. "
"For technical details, see pam_nologin(8).");
if (r < 0)
return log_error_errno(r, "Failed to create /run/nologin: %m");
return 0;
}

View File

@@ -34,5 +34,6 @@ static inline int write_string_file_atomic_label(const char *fn, const char *lin
return write_string_file_atomic_label_ts(fn, line, NULL);
}
int write_env_file_label(const char *fname, char **l);
int fopen_temporary_label(const char *target,
const char *path, FILE **f, char **temp_path);
int fopen_temporary_label(const char *target, const char *path, FILE **f, char **temp_path);
int create_shutdown_run_nologin_or_warn(void);