Skip to content

Commit

Permalink
Merge pull request #201 from cgwalters/no-pidhost
Browse files Browse the repository at this point in the history
install: Just check if we're pid1
  • Loading branch information
cgwalters authored Nov 11, 2023
2 parents 46e8f6c + 4c5360b commit d0f07b2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,9 @@ pub(crate) fn finalize_filesystem(fs: &Utf8Path) -> Result<()> {
Ok(())
}

fn require_systemd_pid1() -> Result<()> {
fn require_host_pidns() -> Result<()> {
// We require --pid=host
let pid = std::fs::read_link("/proc/1/exe").context("reading /proc/1/exe")?;
let pid = pid
.to_str()
.ok_or_else(|| anyhow::anyhow!("Non-UTF8 /proc/1/exe"))?;
if !pid.contains("systemd") {
if rustix::process::getpid().is_init() {
anyhow::bail!("This command must be run with --pid=host")
}
Ok(())
Expand Down Expand Up @@ -809,7 +805,7 @@ async fn prepare_install(
) -> Result<Arc<State>> {
// We need full root privileges, i.e. --privileged in podman
crate::cli::require_root()?;
require_systemd_pid1()?;
require_host_pidns()?;

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

0 comments on commit d0f07b2

Please sign in to comment.