Skip to content

Commit d0f07b2

Browse files
authored
Merge pull request #201 from cgwalters/no-pidhost
install: Just check if we're pid1
2 parents 46e8f6c + 4c5360b commit d0f07b2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/src/install.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,9 @@ pub(crate) fn finalize_filesystem(fs: &Utf8Path) -> Result<()> {
722722
Ok(())
723723
}
724724

725-
fn require_systemd_pid1() -> Result<()> {
725+
fn require_host_pidns() -> Result<()> {
726726
// We require --pid=host
727-
let pid = std::fs::read_link("/proc/1/exe").context("reading /proc/1/exe")?;
728-
let pid = pid
729-
.to_str()
730-
.ok_or_else(|| anyhow::anyhow!("Non-UTF8 /proc/1/exe"))?;
731-
if !pid.contains("systemd") {
727+
if rustix::process::getpid().is_init() {
732728
anyhow::bail!("This command must be run with --pid=host")
733729
}
734730
Ok(())
@@ -809,7 +805,7 @@ async fn prepare_install(
809805
) -> Result<Arc<State>> {
810806
// We need full root privileges, i.e. --privileged in podman
811807
crate::cli::require_root()?;
812-
require_systemd_pid1()?;
808+
require_host_pidns()?;
813809

814810
if cfg!(target_arch = "s390x") {
815811
anyhow::bail!("Installation is not supported on this architecture yet");

0 commit comments

Comments
 (0)