F42 Change Proposal: Unify /usr/bin and /usr/sbin (System-Wide)

I first observed this issue in our CI that uses Testing Farm where a fresh system image is used for every run. When I install a Fedora Rawhide VM without a desktop environment, I see the same behavior. I do not see this problem on updated systems because the folders are not merged. I ran the commands in a Testing Farm machine and in a fresh Fedora 42 VM (so the /usr/sbin/ is a symlink in my case) and got a similar result as you.

Testing Farm:

# systemd-run -t env | grep PATH
PATH=/usr/local/bin:/usr/bin
# systemd-run --user -t env | grep PATH
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
# env | grep PATH
PATH=/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

Freshly installed Fedora 42 VM:

# systemd-run -t env | grep PATH
PATH=/usr/local/bin:/usr/bin
# systemd-run --user -t env | grep PATH
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
# env | grep PATH
PATH=/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

The reason why I brought up shadow-utils is that I and my colleague determined that is who might be setting $PATH initially. I had a look at https://src.fedoraproject.org/rpms/shadow-utils/blob/7b5d11c4b7d0d91c4d879b18facaefd7975544a5/f/shadow-utils.login.defs#_88 which documents that the default path for all users contains /usr/sbin. The actual default path is then contained in the shadow-utils source and I didn’t see any patches in the dist-git repo for that. I’m not quite sure how PATH is actually set, it was just something that we found and thought could be the issue… Is that completely irrelevant?

From the files that you suggested, .bashrc and .bash_profile do not modify the $PATH on these systems, I checked. However, /etc/profile that belongs to the setup package could add some sbin locations:

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

This would suggest that for root, /usr/local/sbin:/usr/sbin should be added at the start of the $PATH if the folders are not already there. For other users, /usr/local/sbin:/usr/sbin should be added at the end if the folders are not already there.

I don’t think that this file modifies the $PATH in this case since the $PATH from our reproducers ends with /usr/local/sbin:/usr/bin:/usr/sbin and not /usr/local/sbin:/usr/sbin. I think the $PATH looks suspiciously similar to what I saw in shadow-utils, I am just not sure if that is the case. What do you think?