manager: add taint flag "support-ended"
In the welcome line, use NAME= as the fallback for PRETTY_NAME=. PRETTY_NAME= doesn't have to be set, but NAME= should. Example output: --- Welcome to Fedora Linux 37 (Rawhide Prerelease)! [ !! ] This OS version (Fedora Linux 37 (Rawhide Prerelease)) is past its end-of-support date (1999-01-01) Queued start job for default target graphical.target. [ OK ] Created slice system-getty.slice. ---
This commit is contained in:
+35
-18
@@ -1312,29 +1312,46 @@ static int enforce_syscall_archs(Set *archs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int status_welcome(void) {
|
||||
_cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL;
|
||||
static int os_release_status(void) {
|
||||
_cleanup_free_ char *pretty_name = NULL, *name = NULL, *version = NULL,
|
||||
*ansi_color = NULL, *support_end = NULL;
|
||||
int r;
|
||||
|
||||
if (!show_status_on(arg_show_status))
|
||||
return 0;
|
||||
|
||||
r = parse_os_release(NULL,
|
||||
"PRETTY_NAME", &pretty_name,
|
||||
"ANSI_COLOR", &ansi_color);
|
||||
"NAME", &name,
|
||||
"VERSION", &version,
|
||||
"ANSI_COLOR", &ansi_color,
|
||||
"SUPPORT_END", &support_end);
|
||||
if (r < 0)
|
||||
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
|
||||
"Failed to read os-release file, ignoring: %m");
|
||||
return log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
|
||||
"Failed to read os-release file, ignoring: %m");
|
||||
|
||||
if (log_get_show_color())
|
||||
return status_printf(NULL, 0,
|
||||
"\nWelcome to \x1B[%sm%s\x1B[0m!\n",
|
||||
isempty(ansi_color) ? "1" : ansi_color,
|
||||
isempty(pretty_name) ? "Linux" : pretty_name);
|
||||
else
|
||||
return status_printf(NULL, 0,
|
||||
"\nWelcome to %s!\n",
|
||||
isempty(pretty_name) ? "Linux" : pretty_name);
|
||||
const char *label = empty_to_null(pretty_name) ?: empty_to_null(name) ?: "Linux";
|
||||
|
||||
if (show_status_on(arg_show_status)) {
|
||||
if (log_get_show_color())
|
||||
status_printf(NULL, 0,
|
||||
"\nWelcome to \x1B[%sm%s\x1B[0m!\n",
|
||||
empty_to_null(ansi_color) ?: "1",
|
||||
label);
|
||||
else
|
||||
status_printf(NULL, 0,
|
||||
"\nWelcome to %s!\n",
|
||||
label);
|
||||
}
|
||||
|
||||
if (support_end && os_release_support_ended(support_end, false) > 0)
|
||||
/* pretty_name may include the version already, so we'll print the version only if we
|
||||
* have it and we're not using pretty_name. */
|
||||
status_printf(ANSI_HIGHLIGHT_RED " !! " ANSI_NORMAL, 0,
|
||||
"This OS version (%s%s%s) is past its end-of-support date (%s)",
|
||||
label,
|
||||
(pretty_name || !version) ? "" : " version ",
|
||||
(pretty_name || !version) ? "" : version,
|
||||
support_end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int write_container_id(void) {
|
||||
@@ -2100,7 +2117,7 @@ static int initialize_runtime(
|
||||
return r;
|
||||
}
|
||||
|
||||
status_welcome();
|
||||
(void) os_release_status();
|
||||
(void) hostname_setup(true);
|
||||
/* Force transient machine-id on first boot. */
|
||||
machine_id_setup(NULL, first_boot, arg_machine_id, NULL);
|
||||
|
||||
+5
-1
@@ -61,6 +61,7 @@
|
||||
#include "manager-serialize.h"
|
||||
#include "memory-util.h"
|
||||
#include "mkdir-label.h"
|
||||
#include "os-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-lookup.h"
|
||||
#include "path-util.h"
|
||||
@@ -4475,7 +4476,7 @@ char* manager_taint_string(const Manager *m) {
|
||||
|
||||
assert(m);
|
||||
|
||||
const char* stage[12] = {};
|
||||
const char* stage[13] = {};
|
||||
size_t n = 0;
|
||||
|
||||
if (m->taint_usr)
|
||||
@@ -4494,6 +4495,9 @@ char* manager_taint_string(const Manager *m) {
|
||||
if (clock_is_localtime(NULL) > 0)
|
||||
stage[n++] = "local-hwclock";
|
||||
|
||||
if (os_release_support_ended(NULL, true) > 0)
|
||||
stage[n++] = "support-ended";
|
||||
|
||||
_cleanup_free_ char *destination = NULL;
|
||||
if (readlink_malloc("/var/run", &destination) < 0 ||
|
||||
!PATH_IN_SET(destination, "../run", "/run"))
|
||||
|
||||
Reference in New Issue
Block a user