mainThe GNU Bourne-Again SHell - Support: sr #107950, When SYS_BASHRC is set,...

 
 

sr #107950: When SYS_BASHRC is set, /etc/bash.bashrc is being executed even when --rcfile is chosen

Submitter:  Rodrigo Silva <mestrelion>
Submitted:  Mon 06 Feb 2012 05:27:23 PM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 12 Nov 2015 11:35:21 PM UTC, comment #2: 

Debian made that documentation error.  If you compile with -DSYS_BASHRC, it's always executed, as is ~/.bashrc (or the file specified with --rcfile)

Chet Ramey <chet>
Group administrator
Mon 06 Feb 2012 05:30:48 PM UTC, comment #1: 

This was also reported since 2006 in Debian BTS #516152, #343673 and Ubuntu LP: #589496

Rodrigo Silva <mestrelion>
Mon 06 Feb 2012 05:27:23 PM UTC, original submission:  

Debian's bash (compiled with -DSYS_BASHRC) documentation says
"--rcfile file: Execute commands from file instead of the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive."

But testing shows that /etc/bash.bashrc is being executed even when a --rcfile is set.

So the only way for the user to disable the system-wide rc is to use the --norc option, which also disables both ~/.bashrc and any custom rc specified in --rcfile

User should be able to prevent system rc and selecting a custom rc by using the --rcfile option, as per the documentation.

from any terminal:
$ sudo echo "echo systemrc" > /etc/bash.bashrc
$ echo "echo customrc" > ~/customrc
$ echo "echo bashrc" > ~/.bashrc
$ bash
systemrc
bashrc
$ bash --rcfile ~/customrc --norc
$

Current behavior:
$ bash --rcfile ~/customrc
systemrc
customrc
$

Expected behavior:
$ bash --rcfile ~/customrc
customrc
$

To fix the behavior so it matches the documentation, SYS_BASHRC should only be executed if --rcfile is NOT used.

Also, documentation should be updated to clarify that --norc option disables --rcfile option.

Last but not least, -DSYS_BASHRC compile option should be properly documented, or at least included in configure options (suggestion: --enable-system-bashrc)

Rodrigo Silva <mestrelion>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #24995:  0000-SYS_BASHRC-enabled-in-config-top.h.patch added by mestrelion (716B - text/x-patch - 1st patch enables SYS_BASHRC so bug can be reproduced and the fix can be tested, 2nd actually fixes the bug. Only the 2nd is meant for merge.)
file #24996:  0001-SYS_BASHRC:-do-not-execute-etc-bash.bashrc-if-rcfile-is-set.patch added by mestrelion (2KiB - text/x-patch - 1st patch enables SYS_BASHRC so bug can be reproduced and the fix can be tested, 2nd actually fixes the bug. Only the 2nd is meant for merge.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by mestrelion (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-12 chet StatusNone Invalid
    2012-02-06 mestrelion Attached File- Added 0000-SYS_BASHRC-enabled-in-config-top.h.patch, #24995
        Attached File- Added 0001-SYS_BASHRC:-do-not-execute-etc-bash.bashrc-if-rcfile-is-set.patch, #24996

    Back to the top

    Powered by Savane 3.13-5190.
    Corresponding source code