It will be printed even if a prompt is blocking other messages.
#include "special.h"
#include "failure-action.h"
#include "special.h"
#include "failure-action.h"
+static void log_and_status(Manager *m, const char *message) {
+ log_warning("%s", message);
+ manager_status_printf(m, STATUS_TYPE_EMERGENCY,
+ ANSI_HIGHLIGHT_RED_ON " !! " ANSI_HIGHLIGHT_OFF,
+ "%s", message);
+}
+
int failure_action(
Manager *m,
FailureAction action,
int failure_action(
Manager *m,
FailureAction action,
case FAILURE_ACTION_REBOOT: {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
case FAILURE_ACTION_REBOOT: {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
- log_warning("Rebooting as result of failure.");
+ log_and_status(m, "Rebooting as result of failure.");
update_reboot_param_file(reboot_arg);
r = manager_add_job_by_name(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL);
update_reboot_param_file(reboot_arg);
r = manager_add_job_by_name(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL);
}
case FAILURE_ACTION_REBOOT_FORCE:
}
case FAILURE_ACTION_REBOOT_FORCE:
- log_warning("Forcibly rebooting as result of failure.");
+ log_and_status(m, "Forcibly rebooting as result of failure.");
+
update_reboot_param_file(reboot_arg);
m->exit_code = MANAGER_REBOOT;
break;
case FAILURE_ACTION_REBOOT_IMMEDIATE:
update_reboot_param_file(reboot_arg);
m->exit_code = MANAGER_REBOOT;
break;
case FAILURE_ACTION_REBOOT_IMMEDIATE:
- log_warning("Rebooting immediately as result of failure.");
+ log_and_status(m, "Rebooting immediately as result of failure.");
case FAILURE_ACTION_POWEROFF: {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
case FAILURE_ACTION_POWEROFF: {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
- log_warning("Powering off as result of failure.");
+ log_and_status(m, "Powering off as result of failure.");
r = manager_add_job_by_name(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE, true, &error, NULL);
if (r < 0)
r = manager_add_job_by_name(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE, true, &error, NULL);
if (r < 0)
}
case FAILURE_ACTION_POWEROFF_FORCE:
}
case FAILURE_ACTION_POWEROFF_FORCE:
- log_warning("Forcibly powering off as result of failure.");
+ log_and_status(m, "Forcibly powering off as result of failure.");
m->exit_code = MANAGER_POWEROFF;
break;
case FAILURE_ACTION_POWEROFF_IMMEDIATE:
m->exit_code = MANAGER_POWEROFF;
break;
case FAILURE_ACTION_POWEROFF_IMMEDIATE:
- log_warning("Powering off immediately as result of failure.");
+ log_and_status(m, "Powering off immediately as result of failure.");
return false;
/* If we cannot find out the status properly, just proceed. */
return false;
/* If we cannot find out the status properly, just proceed. */
- if (manager_check_ask_password(m) > 0)
+ if (type != STATUS_TYPE_EMERGENCY && manager_check_ask_password(m) > 0)
return false;
if (m->show_status > 0)
return false;
if (m->show_status > 0)
typedef enum StatusType {
STATUS_TYPE_EPHEMERAL,
STATUS_TYPE_NORMAL,
typedef enum StatusType {
STATUS_TYPE_EPHEMERAL,
STATUS_TYPE_NORMAL,
} StatusType;
#include "unit.h"
} StatusType;
#include "unit.h"