Skip to content

nspawn populates PATH without sbin directories #8698

Closed

Description

@fgrsnau

Submission type

  • Bug report

systemd version the issue has been seen with

systemd 238
+PAM -AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid

Used distribution

Arch Linux

In case of bug report: Expected behaviour you didn't see

I’m currently trying to use mkosi on Arch Linux. I am hitting a problem where the script fails because the sbin directories are not part of the search path inside the container (when not running a login shell inside the container).

In case of bug report: Unexpected behaviour you saw

This boils down to systemd-nspawn setting PATH=/usr/local/bin:/bin by default which looks incorrect.

Here is a minimal example for reproducing the problem (on Arch Linux!):

# debootstrap stable root
[...]
# systemd-nspawn --directory=root /usr/bin/env
PATH=/usr/local/bin:/usr/bin:/bin

I would expect PATH to be something like /usr/local/sbin:/usr/local/bin/:/usr/sbin:/usr/bin:/sbin/bin. I think this is related to

#if HAVE_SPLIT_BIN
as HAVE_SPLIT_BIN is probably defined on my Arch Linux installation (at least /usr/sbin links to /usr/bin etc.).

Note that systemd-nspawn already tries to set a sane default PATH here:

"PATH=" DEFAULT_PATH_SPLIT_USR,

Unfortunately, DEFAULT_PATH_SPLIT_USR depends on a specific HAVE_SPLIT_BIN definition and introduces a compatibility issue between distributions that have a split bin and ones that have not.

Activity

  1. poettering commented on Apr 10, 2018

    @poettering
    Member

    Hmm, yeah, i figure we should set the most generic PATH for our container payload indeed...

  2. added this to the v239 milestone on Apr 10, 2018
  3. poettering commented on Apr 18, 2018

    @poettering
    Member

    Fix waiting in #8756

  4. added a commit that references this issue on Apr 18, 2018
    4e89704
  5. added a commit that references this issue on Apr 20, 2018
    0c300ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions