Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem: The if statement in /etc/profile.d/which2.sh is incorrect, it only checks for ksh and not -ksh. So the wrong alias gets set on login shells.
Steps to Reproduce:
1. su to a user with ksh set as the login shell
2. Run $ which cat and error shows.
Actual results:
root@ryan-rhel8 ~ # su - ryan
Last login: Mon Nov 4 10:32:41 EST 2019 on pts/0
$ which cat
-ksh: declare: not found
/usr/bin/cat
$ exit
Expected results:
root@ryan-rhel8 ~ # su - ryan
Last login: Mon Nov 4 10:34:49 EST 2019 on pts/0
$ which cat
/usr/bin/cat
$ exit
Additional info:
- Looks like $0 returns a - in front of every shell, so it should be -ksh not ksh.
root@ryan-rhel8 ~ # echo $0
-bash
root@ryan-rhel8 ~ # su - ryan
Last login: Mon Nov 4 10:34:28 EST 2019 on pts/0
$ echo $0
-ksh
$ exit
- The below patch fixes the issue on my test vm.
root@ryan-rhel8 ~ # diff -up which2.sh.old /etc/profile.d/which2.sh
--- which2.sh.old 2019-11-04 10:29:15.213215270 -0500
+++ /etc/profile.d/which2.sh 2019-11-04 10:32:22.872103846 -0500
@@ -1,6 +1,6 @@
# Initialization script for bash and sh
-if [ "$0" = ksh ] ; then
+if [ "$0" = "-ksh" ] ; then
alias which='(alias; typeset -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
else
alias which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
- Also I checked, and the if statement is the same on the latest F30 released package.
One correction, didn't catch that a non-login shell doesn't have the dash, so I updated the change to the below that works for login and non-login shells.
root@ryan-rhel8 ~ # diff -up which2.sh.old /etc/profile.d/which2.sh
--- which2.sh.old 2019-11-08 11:24:56.981031433 -0500
+++ /etc/profile.d/which2.sh 2019-11-08 11:24:05.206401404 -0500
@@ -1,6 +1,6 @@
# Initialization script for bash and sh
-if [ "$0" = ksh ] ; then
+if [ "$0" = "ksh" ] || [ "$0" = "-ksh" ]; then
alias which='(alias; typeset -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
else
alias which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2020:1851