#include "efivars.h"
#include "emergency-action.h"
#include "env-util.h"
+#include "escape.h"
#include "exit-status.h"
#include "fd-util.h"
#include "fdset.h"
#include "ima-setup.h"
#include "import-creds.h"
#include "initrd-util.h"
+#include "io-util.h"
#include "ipe-setup.h"
#include "killall.h"
#include "kmod-setup.h"
#include "mount-setup.h"
#include "mount-util.h"
#include "os-util.h"
+#include "osc-context.h"
#include "pager.h"
#include "parse-argument.h"
#include "parse-util.h"
*ret_first_boot = first_boot;
}
+static int write_boot_or_shutdown_osc(const char *type) {
+ int r;
+
+ assert(STRPTR_IN_SET(type, "boot", "shutdown"));
+
+ if (getenv_terminal_is_dumb())
+ return 0;
+
+ _cleanup_close_ int fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ if (fd < 0)
+ return log_debug_errno(fd, "Failed to open /dev/console to print %s OSC, ignoring: %m", type);
+
+ _cleanup_free_ char *seq = NULL;
+ if (streq(type, "boot"))
+ r = osc_context_open_boot(&seq);
+ else
+ r = osc_context_close(SD_ID128_ALLF, &seq);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to acquire %s OSC sequence, ignoring: %m", type);
+
+ r = loop_write(fd, seq, SIZE_MAX);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to write %s OSC sequence, ignoring: %m", type);
+
+ if (DEBUG_LOGGING) {
+ _cleanup_free_ char *h = cescape(seq);
+ log_debug("OSC sequence for %s successfully written: %s", type, strna(h));
+ }
+
+ return 0;
+}
+
static int initialize_runtime(
bool skip_setup,
bool first_boot,
write_container_id();
+ (void) write_boot_or_shutdown_osc("boot");
+
/* Copy os-release to the propagate directory, so that we update it for services running
* under RootDirectory=/RootImage= when we do a soft reboot. */
r = setup_os_release(RUNTIME_SCOPE_SYSTEM);
}
#endif
+ (void) write_boot_or_shutdown_osc("shutdown");
+
if (r < 0)
(void) sd_notifyf(/* unset_environment= */ false,
"ERRNO=%i", -r);