#1086843 /etc/profile requires implicit PATH set before setting it

Package:
base-files
Source:
base-files
Description:
Debian base system miscellaneous files
Submitter:
Lee Garrett
Date:
2025-09-03 17:43:02 UTC
Severity:
normal
#1086843#5
Date:
2024-11-06 14:42:56 UTC
From:
To:
Hi,

reproducer for the problem:

$ mkdir tmp
$ sudo debootstrap bookworm tmp/
[...]
$ sudo PATH=not-set-correctly /usr/sbin/chroot tmp/ /bin/bash -l
bash: id: command not found
bash: [: : integer expression expected

PATH is taken from the parent shell, and that's sometimes undefined or
doesn't include /usr/bin/.

As such, the line 4 in /etc/profile should be changed from

if [ "$(id -u)" -eq 0 ]; then

to

if [ "$(/usr/bin/id -u)" -eq 0 ]; then

Thanks in advance!

Greets,
Lee

#1086843#10
Date:
2024-11-06 15:03:58 UTC
From:
To:
El 6/11/24 a las 15:42, Lee Garrett escribió:

Thanks for the report, but I believe this is incompatible
with the existing plan to remove PATH from /etc/profile
(some day, maybe for trixie).

When we removed PATH from /etc/profile, we implicitly take for granted that
the PATH is already sane by the time it's executed.

So, instead of making /etc/profile more complex, which I would consider a step
in the wrong direction, I would try to investigate why in your system
the PATH was not sane to begin with.

Thanks.

#1086843#15
Date:
2025-09-03 17:39:58 UTC
From:
To:
Hello. Given that some distributions (for example, Ubuntu) do not have
any PATH at all in /etc/profile, I consider reasonable to assume that
by the time /etc/profile is read, PATH contains /usr/bin at least.

So, if PATH is undefined or does not include /usr/bin, it's probably a
symptom that there is something wrong somewhere. Modifying /etc/profile
as suggested would just hide the problem and make the file more
complex without a real need.

Thanks.