8

Problem

After moving to RHEL 8.5 from 8.4, started having the issue of K8S pods failure.

spec.template.spec.containers[0].env[52].name: Invalid value: "BASH_FUNC_which%%": a valid environment variable name must 
consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name',  or 'MY_ENV.NAME',  or 'MyEnvName1', regex used for validation is '[-._a-zA-Z][-._a-zA-Z0-9]*')

The env command in the login shell shows BASH_FUNC_which%% defined as below.

BASH_FUNC_which%%=() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}

Suggeted that /etc/profile.d/which2.sh is the one that sets up the BASH_FUNC_which%%.

  • /etc/profile.d/which2.sh

# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh

which_declare="declare -f"
which_opt="-f"
which_shell="$(cat /proc/$$/comm)"

if [ "$which_shell" = "ksh" ] || [ "$which_shell" = "mksh" ] || [ "$which_shell" = "zsh" ] ; then
  which_declare="typeset -f"
  which_opt=""
fi
 
which ()
{
(alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}

export which_declare
export ${which_opt} which

By removing it, the issue was fixed.

Question

Please help understand where exactly BASH_FUNC_which%% is setup in RHEL8.5 and what is the purpose of this BASH_FUNC_which%%, why is has been introduced in RHEL.

mon
  • 18,789
  • 22
  • 112
  • 205

1 Answers1

1

Answering the first part:

Output of rpm -q --changes which-2.21-28.el9.x86_64

* Fri Apr 15 14:00:00 2022 Than Ngo <than@redhat.com> - 2.21-28
- Resolves: #2050996, error on login when using ksh as the default shell

* Tue Aug 10 14:00:00 2021 Mohan Boddu <mboddu@redhat.com> - 2.21-27
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
  Related: rhbz#1991688

* Fri May  7 14:00:00 2021 Than Ngo <than@redhat.com> - 2.21-26
- Related: #1940464, fixed unbound variable

* Fri Apr 16 14:00:00 2021 Mohan Boddu <mboddu@redhat.com> - 2.21-25
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

* Tue Mar 23 13:00:00 2021 Than Ngo <than@redhat.com> - 2.21-24
- fix regression in zsh

* Sun Mar 21 13:00:00 2021 Than Ngo <than@redhat.com> - 2.21-23
- improved which2.sh

Possibly, than@redhat.com can elaborate what is going on? Or, since you use RHEL, you could contact RedHat support?

cobexer
  • 147
  • 2
  • 5