From 93424d7421f8a441cb7fb8d7d62cf7a7030b477c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 27 Oct 2024 17:42:49 -0400 Subject: [PATCH] cli: Reset executable name In some cases we re-exec ourselves; seeing the temporary file in there is super ugly. In general ideally in the future we support reliably querying journal logs from bootc; at least this improves things so that one can do `journalctl _COMM=bootc`. Signed-off-by: Colin Walters --- lib/src/cli.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index f7c8347f7..5e19d400e 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -2,6 +2,7 @@ //! //! Command line tool to manage bootable ostree-based containers. +use std::ffi::CString; use std::ffi::OsString; use std::io::Seek; use std::os::unix::process::CommandExt; @@ -796,6 +797,14 @@ async fn usroverlay() -> Result<()> { /// Perform process global initialization. This should be called as early as possible /// in the standard `main` function. pub fn global_init() -> Result<()> { + // In some cases we re-exec with a temporary binary, + // so ensure that the syslog identifier is set. + let name = "bootc"; + ostree::glib::set_prgname(name.into()); + if let Err(e) = rustix::thread::set_name(&CString::new(name).unwrap()) { + // This shouldn't ever happen + eprintln!("failed to set name: {e}"); + } let am_root = rustix::process::getuid().is_root(); // Work around bootc-image-builder not setting HOME, in combination with podman (really c/common) // bombing out if it is unset.