Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

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.