Bug 1747493 - Not all utilities are called with full path in /etc/profile ( and /etc/profile.d/colorls.sh)
Summary: Not all utilities are called with full path in /etc/profile ( and /etc/profil...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: setup
Version: rawhide
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Martin Osvald 🛹
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-30 15:07 UTC by Martin Osvald 🛹
Modified: 2019-10-26 17:23 UTC (History)
4 users (show)

Fixed In Version: setup-2.13.6-1.fc30 setup-2.13.6-1.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-25 16:59:51 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Martin Osvald 🛹 2019-08-30 15:07:47 UTC
This bug was initially created as a copy of Bug #1688302

I am copying this bug because: 

This will get fixed in 8, therefore, cloning it for Fedora to prevent regression.


Same issue in rhel8:

# rpm -qa setup
setup-2.12.2-1.el8.noarch
# egrep '(id|tty|tput|dircolors|grep)' -r /etc/profile
# System wide environment and startup programs, for login setup
# It's NOT a good idea to change this file unless you know what you
if [ -x /usr/bin/id ]; then
        EUID=`id -u`
        UID=`id -ru`
    USER="`id -un`"
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
# 

+++ This bug was initially created as a clone of Bug #1228282 +++

==================
This bug has been copied from Bug #1222140 because "/etc/profile" belongs to "setup", "/etc/profile.d/colorls.sh" belongs to "coreutils".
==================


Description of problem:

  Rlative path is used in /etc/profile.d/colorls.sh.
  Those are id, tty, tput, dircolors and grep.
  If NFS is mounted to /usr/local/sbin and NFS is unresponsive, it would take long time for root to login.


Version-Release number of selected component (if applicable):

  setup-2.8.14-20.el6_4.1.noarch

How reproducible:

  Always

Steps to Reproduce:

  # egrep '(id|tty|tput|dircolors|grep)' -r /etc/profile

Actual results:

~~~
# System wide environment and startup programs, for login setup
# It's NOT a good idea to change this file unless you know what you
if [ -x /usr/bin/id ]; then
        EUID=`id -u`
        UID=`id -ru`
    USER="`id -un`"
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
~~~


Expected results:

  All commands are with fullpath.
~~~
        EUID=`/usr/bin/id -u`
        UID=`/usr/bin/ -ru`
    USER="`/usr/bin/ -un`"
...snip...
if [ $UID -gt 199 ] && [ "`/usr/bin/ -gn`" = "`/usr/bin/ -un`" ]; then
~~~

Additional info:
  See also: Bug #1222140

Comment 1 Martin Osvald 🛹 2019-08-30 16:47:48 UTC
some of the needed changes introduced already by:

Bug 1648589 - recursively repeats command until no more processes
https://pagure.io/setup/c/020de8300a7679cc280f672d6262935a42464b19


current results (searched also for hostname, sed and locale):

~~~
$ egrep '(id|tty|tput|dircolors|grep|hostname|sed|locale)' csh.cshrc csh.login lang.csh lang.sh profile | grep -v "#.*"
csh.cshrc:if ($uid > 199 && "`id -gn`" == "`id -un`") then
csh.cshrc:    set prompt=\[$user@`hostname -s`\]\$\ 
csh.login:        if ( $uid == 0 ) then
csh.login:                      if ( $uid == 0 ) then
csh.login:setenv HOSTNAME `/usr/bin/hostname`
lang.csh:set locale_error=`(locale >/dev/null) |& cat`
lang.csh:if ("${locale_error}" != "") then
lang.csh:foreach config (/etc/locale.conf "${HOME}/.i18n")
lang.csh:        eval `sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/setenv \1 \2;/;t;d' ${config}`
lang.csh:unset LANG_backup config locale_error
lang.csh:set in_console=`tty | grep -vc -e '/dev/tty'`
lang.csh:        set utf8_used=`echo ${LANG} | grep -vc -E -i -e '^.+\.utf-?8$'`
lang.csh:        if (${utf8_used} == 0) then
lang.csh:unset in_console utf8_used
lang.sh:if [ -n "$(locale 2>&1 1>/dev/null)" ]; then
lang.sh:for config in /etc/locale.conf "${HOME}/.i18n"; do
lang.sh:        if [ -x /usr/bin/sed ]; then
lang.sh:            eval $(/usr/bin/sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/export \1=\2/;t;d' ${config})
lang.sh:if [ -n "${LANG}" ] && [ "${TERM}" = 'linux' ] && tty | grep --quiet -e '/dev/tty'; then
lang.sh:    if grep --quiet -E -i -e '^.+\.utf-?8$' <<< "${LANG}"; then
profile:if [ -x /usr/bin/id ]; then
profile:        EUID=`/usr/bin/id -u`
profile:        UID=`/usr/bin/id -ru`
profile:    USER="`/usr/bin/id -un`"
profile:HOSTNAME=`/usr/bin/hostname 2>/dev/null`
profile:if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
$
~~~


patch for this:

https://pagure.io/setup/c/c66b84814334be0d7fe82812f0c5312aa36c0bf6?branch=master


results after the patch:

~~~
$ egrep '(id|tty|tput|dircolors|grep|hostname|sed|locale)' csh.cshrc csh.login lang.csh lang.sh profile | grep -v "#.*"
csh.cshrc:if ($uid > 199 && "`/usr/bin/id -gn`" == "`/usr/bin/id -un`") then
csh.cshrc:    set prompt=\[$user@`/usr/bin/hostname -s`\]\$\
csh.login:        if ( $uid == 0 ) then
csh.login:                      if ( $uid == 0 ) then
csh.login:setenv HOSTNAME `/usr/bin/hostname`
lang.csh:set locale_error=`(/usr/bin/locale >/dev/null) |& cat`
lang.csh:if ("${locale_error}" != "") then
lang.csh:foreach config (/etc/locale.conf "${HOME}/.i18n")
lang.csh:        eval `/usr/bin/sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/setenv \1 \2;/;t;d' ${config}`
lang.csh:unset LANG_backup config locale_error
lang.csh:set in_console=`/usr/bin/tty | /usr/bin/grep -vc -e '/dev/tty'`
lang.csh:        set utf8_used=`echo ${LANG} | /usr/bin/grep -vc -E -i -e '^.+\.utf-?8$'`
lang.csh:        if (${utf8_used} == 0) then
lang.csh:unset in_console utf8_used
lang.sh:if [ -n "$(/usr/bin/locale 2>&1 1>/dev/null)" ]; then
lang.sh:for config in /etc/locale.conf "${HOME}/.i18n"; do
lang.sh:        if [ -x /usr/bin/sed ]; then
lang.sh:            eval $(/usr/bin/sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/export \1=\2/;t;d' ${config})
lang.sh:if [ -n "${LANG}" ] && [ "${TERM}" = 'linux' ] && /usr/bin/tty | /usr/bin/grep --quiet -e '/dev/tty'; then
lang.sh:    if /usr/bin/grep --quiet -E -i -e '^.+\.utf-?8$' <<< "${LANG}"; then
profile:if [ -x /usr/bin/id ]; then
profile:        EUID=`/usr/bin/id -u`
profile:        UID=`/usr/bin/id -ru`
profile:    USER="`/usr/bin/id -un`"
profile:HOSTNAME=`/usr/bin/hostname 2>/dev/null`
profile:if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
$
~~~

Comment 2 Martin Osvald 🛹 2019-10-08 14:20:18 UTC
a follow up to comment 1...

with the below commit:

https://pagure.io/setup/c/c66b84814334be0d7fe82812f0c5312aa36c0bf6?branch=master

I introduced a regression and fixed it by:

https://pagure.io/setup/c/55c2a3703fe54eb7333d39fa7f89df323a85656b?branch=master

Comment 4 Martin Osvald 🛹 2019-10-09 08:11:06 UTC
besides the two commits mentioned in comment 2:

https://pagure.io/setup/c/c66b84814334be0d7fe82812f0c5312aa36c0bf6?branch=master
https://pagure.io/setup/c/55c2a3703fe54eb7333d39fa7f89df323a85656b?branch=master

the below one is also needed to fully fix this, /etc/bashrc still called 'id' instead of '/usr/bin/id' like it is on RHEL6, RHEL7 and soon also on RHEL8:

https://pagure.io/setup/c/302a086bf59415a22f5d4435a48e6ab248231719?branch=master

Comment 5 Martin Osvald 🛹 2019-10-09 09:10:28 UTC
CI test:

/CoreOS/setup/Sanity/bz1228282-Not-all-utilities-are-called-with-full-path-in

OLD: setup-2.13.3-1.fc30.noarch
NEW: setup-2.13.6-1.fc30.noarch


failed with affected OLD:

~~~
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Cleanup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

/tmp/tmp.5LXKV3LDXT:
-----------------------
/etc/bashrc:    if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
/etc/csh.cshrc:if ($uid > 199 && "`id -gn`" == "`id -un`") then
/etc/csh.cshrc:    set prompt=\[$user@`hostname -s`\]\$\ 
/etc/profile:if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
/etc/profile.d/lang.csh:set locale_error=`(locale >/dev/null) |& cat`
/etc/profile.d/lang.csh:        eval `sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/setenv \1 \2;/;t;d' ${config}`
/etc/profile.d/lang.csh:set in_console=`tty | grep -vc -e '/dev/tty'`
/etc/profile.d/lang.csh:    set utf8_used=`echo ${LANG} | grep --quiet -E -i -e '^.+\.utf-?8$'; echo $?`
/etc/profile.d/lang.sh:if [ -n "$(locale 2>&1 1>/dev/null)" ]; then
-----------------------
...
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Test for BZ#1688302 on Fedora release 30 (Thirty)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 05:08:38 ] :: [   FAIL   ] :: Command 'grep '`[[:alnum:][:space:][:punct:]]\{1,\}`' $(for Input in $(rpm -ql setup | grep /etc); do [ -f "$Input" ] && echo "$Input"; done) | grep -v /bin &> /tmp/tmp.5LXKV3LDXT' (Expected 1, got 0)
:: [ 05:08:38 ] :: [   FAIL   ] :: Command 'grep '$([[:alnum:][:space:][:punct:]]\{1,\})' $(for Input in $(rpm -ql setup | grep /etc); do [ -f "$Input" ] && echo "$Input"; done) | grep -v /bin >> /tmp/tmp.5LXKV3LDXT' (Expected 1, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Assertions: 0 good, 2 bad
::   RESULT: FAIL (Test for BZ#1688302 on Fedora release 30 (Thirty))
~~~


passed with fixed NEW:

~~~
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Cleanup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

/tmp/tmp.Y6XgBCVPv6:
-----------------------
-----------------------
...
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Test for BZ#1688302 on Fedora release 30 (Thirty)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 05:09:57 ] :: [   PASS   ] :: Command 'grep '`[[:alnum:][:space:][:punct:]]\{1,\}`' $(for Input in $(rpm -ql setup | grep /etc); do [ -f "$Input" ] && echo "$Input"; done) | grep -v /bin &> /tmp/tmp.Y6XgBCVPv6' (Expected 1, got 1)
:: [ 05:09:57 ] :: [   PASS   ] :: Command 'grep '$([[:alnum:][:space:][:punct:]]\{1,\})' $(for Input in $(rpm -ql setup | grep /etc); do [ -f "$Input" ] && echo "$Input"; done) | grep -v /bin >> /tmp/tmp.Y6XgBCVPv6' (Expected 1, got 1)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 0s
::   Assertions: 2 good, 0 bad
::   RESULT: PASS (Test for BZ#1688302 on Fedora release 30 (Thirty))
~~~

Comment 6 Fedora Update System 2019-10-09 09:57:12 UTC
FEDORA-2019-d30f1a7dd4 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-d30f1a7dd4

Comment 7 Fedora Update System 2019-10-09 09:57:13 UTC
FEDORA-2019-c423bdade3 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-c423bdade3

Comment 8 Fedora Update System 2019-10-09 17:40:05 UTC
setup-2.13.6-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-c423bdade3

Comment 9 Fedora Update System 2019-10-09 23:05:31 UTC
setup-2.13.6-1.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-d30f1a7dd4

Comment 10 Fedora Update System 2019-10-25 16:59:51 UTC
setup-2.13.6-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2019-10-26 17:23:59 UTC
setup-2.13.6-1.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.