Skip to content

Set PATH in preamble - #541

Open
amousset wants to merge 1 commit into
trailofbits:mainfrom
amousset:set-path-in-scripts
Open

amousset wants to merge 1 commit into
trailofbits:mainfrom
amousset:set-path-in-scripts

Conversation

@amousset

@amousset amousset commented Oct 5, 2026

Copy link
Copy Markdown

On ArchLinux coop setup fails with:

  [guest] Configuring DNS (static resolv.conf)...
  [guest] Configuring Docker daemon...
  [guest] Ensuring ubuntu user exists (uid 1000)...
bash: line 133: usermod: command not found
Error: Guest package installation failed

Caused by:
    sudo chroot /home/amousset/.coop/rootfs-mount bash -c set -euo pipefail
    export DEBIAN_FRONTEND=noninteractive
    export DPKG_OPTIONS='--force-confnew'
    APT_OPTS=(-o Dpkg::Options::=--force-confnew)

as the PATH comes from the system, and /usr/sbin is not present in all system's default PATH.

Comment thread scripts/guest/preamble.sh
# The chroot inherits the host's PATH. Hosts with a merged sbin (e.g. Arch)
# omit /usr/sbin and /sbin, where Ubuntu keeps usermod, useradd, ldconfig, etc.
# that dpkg and package maintainer scripts expect to find.
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a regression test that runs the provisioning script with a host PATH lacking /usr/sbin and /sbin, and verifies that usermod is found? The existing setup coverage uses a normal PATH, so it would still pass if this export were removed. Thank you!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Should've said that the first time around.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants