Bug 739991 - Unsure if bug: having exit commands in files in /etc/profile.d may be a bad idea
Summary: Unsure if bug: having exit commands in files in /etc/profile.d may be a bad idea
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: coreutils
Version: 6.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Ondrej Vasik
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-09-20 15:57 UTC by David Tonhofer
Modified: 2011-09-21 11:04 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-09-21 10:08:32 UTC


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.