Bug 739991

Summary: Unsure if bug: having exit commands in files in /etc/profile.d may be a bad idea
Product: Red Hat Enterprise Linux 6 Reporter: David Tonhofer <bughunt>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1CC: meyering, prc
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-21 10:08:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Tonhofer 2011-09-20 15:57:09 UTC
Description of problem:

The following standard files:

/etc/profile.d/colorls.csh  from   coreutils-8.4-13.el6.x86_64
/etc/profile.d/qt.csh       from   qt3-3.3.8b-29.el6.x86_64

contain exit statements.

This may be a bad idea. If I understand correctly, the above are sourced by csh on login-to-csh. Execution of the exit will immediately kill the shell, making root access impossible in case a system problem (missing directory etc.) causes the exit statements to be run.

How reproducible:

Didn't try. The problem occurred to me because I had a homegrown script in /etc/profile.d that called exit under obscure circumstances which happened to become true at some point in time, causing grief.

Comment 2 Ondrej Vasik 2011-09-21 10:08:32 UTC
Worksforme without troubles... it just exits from the sourced script and continues with the next one... see the following (I added echo $i to the foreach cycle in csh.cshrc to output sourced .csh scripts):

[root@dhcp-24-196 tests]# echo exit > /etc/profile.d/crashme.csh
[root@dhcp-24-196 tests]# exit
exit
[Reset@dhcp-24-196 tests]$ tcsh
/etc/profile.d/cobbler.csh
/etc/profile.d/colorls.csh
/etc/profile.d/crashme.csh
/etc/profile.d/cvs.csh
/etc/profile.d/glib2.csh
/etc/profile.d/gnome-ssh-askpass.csh
/etc/profile.d/kde.csh
/etc/profile.d/lang.csh
/etc/profile.d/less.csh
/etc/profile.d/mc.csh
/etc/profile.d/qt.csh
/etc/profile.d/rh-env.csh
/etc/profile.d/vim.csh
/etc/profile.d/which2.csh

So it just works just fine for me... I tried the same with ssh connection to tcsh acoount - with no issues.
Closing NOTABUG, please provide more information how to reproduce the error.

Comment 3 David Tonhofer 2011-09-21 11:04:09 UTC
Hi 

That's pretty interesting.

Retested with tcsh, and indeed - no exit. I just assumed that it would do the same as bash, but no.

So tcsh has a special handling of "exit" on sourced scripts: it doesn't actually exit if exit is called via a sourced script.

Or more likely, exit calls are being explicitely trapped... which does not happen with bash. 

Unexpected for sure.