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

RHEL 7: /etc/profile.d/tmout.sh throws "TMOUT: readonly variable" when /etc/bashrc is sourced multiple times

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • None
    • Low
    • rhel-se-cs-infra-services
    • 3
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      On RHEL 7 systems with a TMOUT policy defined via /etc/profile.d/tmout.sh, sourcing /etc/bashrc may trigger a readonly variable warning:

       

      /etc/profile.d/tmout.sh: line 1: TMOUT: readonly variable

       

      Observed during SSH invocation:

       

      ssh root@<host> ". /etc/bashrc" -q

       

      The TMOUT policy is defined as:

       

      # /etc/profile.d/tmout.sh
      export TMOUT=900
      readonly TMOUT
       
      

      Behavior indicates that the script is executed more than once within the same shell lifecycle. Since TMOUT is already marked readonly, subsequent assignments fail.

      Later RHEL releases include double-sourcing protection inside /etc/bashrc (for example BASHRCSOURCED guard), which prevents this condition. RHEL 7 lacks equivalent logic.

      Steps to Reproduce

      1. Configure TMOUT policy:

       

      cat /etc/profile.d/tmout.sh
      export TMOUT=900
      readonly TMOUT
       
      

      2. Start SSH session that explicitly sources bashrc:

       

      ssh root@<host> ". /etc/bashrc"

       

      Observe warning:

       

      TMOUT: readonly variable

       

      Expected Result

      Shell initialization should not attempt to reassign readonly variables during repeated sourcing paths.

      Actual Result

      Readonly variable warning appears when initialization scripts are executed multiple times.

      Impact

      Cosmetic warning. No functional impact. TMOUT enforcement remains correct.

              rhn-support-bjmason Bryan Mason
              rhn-support-prjagtap Pradeep Jagtap
              se-cs-infra-services se-cs-infra-services se-cs-infra-services se-cs-infra-services
              se-cs-infra-services se-cs-infra-services se-cs-infra-services se-cs-infra-services
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: