Skip to content

Commit 39e1399

Browse files
committed
tree-wide: Set argv0 = bootc when doing a re-exec
We have multiple places which are re-executing the current binary; one of those writes a temp file. Ensure that `argv0` in the new binary is `bootc` which means it should be used as e.g. a syslog identifier. Signed-off-by: Colin Walters <[email protected]>
1 parent a092421 commit 39e1399

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

crates/lib/src/cli.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,9 +1215,8 @@ async fn usroverlay() -> Result<()> {
12151215
pub fn global_init() -> Result<()> {
12161216
// In some cases we re-exec with a temporary binary,
12171217
// so ensure that the syslog identifier is set.
1218-
let name = "bootc";
1219-
ostree::glib::set_prgname(name.into());
1220-
if let Err(e) = rustix::thread::set_name(&CString::new(name).unwrap()) {
1218+
ostree::glib::set_prgname(bootc_utils::NAME.into());
1219+
if let Err(e) = rustix::thread::set_name(&CString::new(bootc_utils::NAME).unwrap()) {
12211220
// This shouldn't ever happen
12221221
eprintln!("failed to set name: {e}");
12231222
}

crates/lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ pub(crate) fn exec_in_host_mountns(args: &[std::ffi::OsString]) -> Result<()> {
918918
tracing::debug!("Using supermin workaround");
919919
rustix::process::chroot("/root").context("chroot")?;
920920
}
921-
Err(Command::new(cmd).args(args).exec()).context("exec")?
921+
Err(Command::new(cmd).args(args).arg0(bootc_utils::NAME).exec()).context("exec")?
922922
}
923923

924924
pub(crate) struct RootSetup {

crates/lib/src/lsm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pub(crate) fn selinux_ensure_install() -> Result<bool> {
110110
cmd.env(guardenv, tmpf);
111111
cmd.env(bootc_utils::reexec::ORIG, srcpath);
112112
cmd.args(std::env::args_os().skip(1));
113+
cmd.arg0(bootc_utils::NAME);
113114
cmd.log_debug();
114115
Err(anyhow::Error::msg(cmd.exec()).context("execve"))
115116
}

crates/utils/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ pub mod reexec;
1717
mod result_ext;
1818
pub use result_ext::*;
1919

20+
/// The name of our binary
21+
pub const NAME: &str = "bootc";
22+
2023
/// Intended for use in `main`, calls an inner function and
2124
/// handles errors by printing them.
2225
pub fn run_main<F>(f: F)

crates/utils/src/reexec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub fn reexec_with_guardenv(k: &str, prefix_args: &[&str]) -> Result<()> {
3636
};
3737
cmd.env(k, "1");
3838
cmd.args(std::env::args_os().skip(1));
39+
cmd.arg0(crate::NAME);
3940
tracing::debug!("Re-executing current process for {k}");
4041
Err(cmd.exec().into())
4142
}

0 commit comments

Comments
 (0)