Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-5653

.bashrc bash subshells causing infinite recursion

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Normal Normal
    • None
    • rhel-9.1.0
    • bash
    • None
    • Moderate
    • rhel-sst-cs-plumbers
    • ssg_core_services
    • 5
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • If docs needed, set a value
    • None

      Description of problem:

      During any ssh sessions (ssh user@host), any .bashrc lines that call `bash -c` in a subshell will cause an infinite process generation loop via sourcing .bashrc.

      ssh user@host
      /etc/profile is sourced and completes successfully
      ~/.bashrc is sourced
      /etc/bashrc is sourced and completes successfully
      ... $(bash -c ls) ... # Subshell to bash is called from .bashrc
      /etc/profile # sourced, completes successfully
      ~/.bashrc # infinite recursion
      /etc/bashrc # sourced, completes successfully
      ... $(bash -c ls) ... # Subshell to bash is called from .bashrc

      Workaround is known (bash -c --norc) but this behavior is not present in RHEL 7 or 8 nor Fedora 37 so it seems there may have been an unintentional regression or a new bug introduced.

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

      RHEL 9 with:
      openssh-8.7p1-8.el9 (first available for rhel 9)
      (and intermittent testing in between)
      openssh-8.7p1-29.el9 (latest available for rhel 9)

      How reproducible:

      Easily, every time.

      Steps to Reproduce:
      1. Open a console or ssh session to a host for backup purposes (this process requires host reboot a small percentage of the time in the best case, more in the "CTRL-C doesnt stop the loop" case)

      2. Add a `$(bash -c)` call to any user's ~/.bashrc

      echo 'echo $(bash -c ls)' >> ~/.bashrc

      3. SSH to the host (remote to host or localhost to localhost) OR source the ~/.bashrc (but not from console, see below)

      1. BELOW WILL CAUSE THE LOOP
        [from remote] ssh user@host
        [from remote] ssh user@host "ls"
        [from localhost] ssh user@localhost
        [from localhost] ssh user@localhost "ls"
        [in any ssh session] source ~/.bashrc
      1. BELOW WILL NOT CAUSE THE LOOP
        [in console or direct session] source ~/.bashrc

      4. CTRL-C
      Most times, CTRL-C will stop the infinite recursion but leave you in the ssh session
      Sometimes, the recursion continues in the background and you will need to manually kill the parent pid or reboot the host

      Actual results:

      The ssh session hangs while infinite procs are created that source .bashrc and recurse

      Expected results:

      The ssh session does not infinitely recurse (acts like other test environments eg. RHEL 7, 8 and Fedora 37)

      Additional info:

      I'm happy to help by answering questions or jumping into a call to describe further.
      Chat/Meet/Slack: rerickso@redhat.com
      Thanks!

              rhn-support-svashish Siteshwar Vashisht
              rh-ee-rerickso Ryan Erickson
              Siteshwar Vashisht Siteshwar Vashisht
              Karel Volný Karel Volný
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: