X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshutdownd%2Fshutdownd.c;h=0464c891878fc8b12f952521facf62f570ee3f68;hb=b9bf7e2be93fe25e0e96e06ad436d43a1e589ed5;hp=0497cd41a05ee8ed90c6042e22da3528dde3778a;hpb=dce818b390a857a11f7dd634684500675cf79833;p=elogind.git diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c index 0497cd41a..0464c8918 100644 --- a/src/shutdownd/shutdownd.c +++ b/src/shutdownd/shutdownd.c @@ -38,6 +38,7 @@ #include "util.h" #include "utmp-wtmp.h" #include "mkdir.h" +#include "fileio.h" union shutdown_buffer { struct sd_shutdown_command command; @@ -136,6 +137,8 @@ static void warn_wall(usec_t n, struct sd_shutdown_command *c) { prefix = "The system is going down for reboot at "; else if (c->mode == SD_SHUTDOWN_KEXEC) prefix = "The system is going down for kexec reboot at "; + else if (c->mode == SD_SHUTDOWN_NONE) + prefix = "The system shutdown has been cancelled at "; else assert_not_reached("Unknown mode!"); @@ -205,17 +208,15 @@ static int update_schedule_file(struct sd_shutdown_command *c) { assert(c); - r = safe_mkdir("/run/systemd/shutdown", 0755, 0, 0); + r = mkdir_safe_label("/run/systemd/shutdown", 0755, 0, 0); if (r < 0) { log_error("Failed to create shutdown subdirectory: %s", strerror(-r)); return r; } t = cescape(c->wall_message); - if (!t) { - log_error("Out of memory"); - return -ENOMEM; - } + if (!t) + return log_oom(); r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path); if (r < 0) { @@ -356,6 +357,8 @@ int main(int argc, char *argv[]) { if (!scheduled(&b.command)) { log_info("Shutdown canceled."); + if (b.command.warn_wall) + warn_wall(0, &b.command); break; }