helpThe 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

Submitted by:  Rodrigo Silva <mestrelion>
Submitted on:  Mon 06 Feb 2012 05:27:23 PM UTC  
 
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: OpenOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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 File(s):
   
   
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 (2kB - 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
  • -unavailable- added by mestrelion (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 06 Feb 2012 05:50:12 PM UTCmestrelionAttached 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.1-cleanup