Bug 433283 - /etc/profile.d/script
Summary: /etc/profile.d/script
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: openssh
Version: 5.1
Hardware: i386
OS: Linux
Target Milestone: rc
: ---
Assignee: Tomas Mraz
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2008-02-18 11:51 UTC by Per Lindahl
Modified: 2008-02-25 09:38 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2008-02-18 12:13:58 UTC

Attachments (Terms of Use)

Description Per Lindahl 2008-02-18 11:51:51 UTC
Description of problem:
On all our test servers running Redhat EL we have a script that gets executed
upon login to warn if the system is in use and currently running tests.

This script echo's a warning to all users login in including root and this works
flawlessly on all the other systems not running RHEL 3u9, 4.6 and 5u1. Since we
distribute our maintenance scripts via scp and that output interrupts the scp
transfer without the files being copied this is a major problem.  

Version-Release number of selected component (if applicable):
RHEL 3u9, 4u6 and 5.1 on ia32, x86_64 and ia64

How reproducible:
Every time

Steps to Reproduce:
1.create a script that does "cat /etc/fstab | tail -n 3"
2.put it in /etc/profile.d/testscript.sh ; chmod a+x /etc/profile.d/testscript.sh
3. logout from the system and login again if it runs and give you any output on
the screen then logout and try to scp a file to the system. It'll fail. The next
time you login you'll see that the file has not been copied 

rsync also fails when doing it over ssh
Actual results:
The file one tried to copy doesn't exist on the target system

Expected results:
That the file can be found on the target system.

Additional info:

Comment 1 Tomas Mraz 2008-02-18 12:13:58 UTC
This is not a bug. You shouldn't print anything in profile.d script when the
shell is non-interactive. You can use for example the following code to test
whether the shell is interactive or not.

if [ ! -z "$PS1" ] ; then
echo "You are running an interactive shell!"

Comment 2 Johan Walles 2008-02-25 08:47:59 UTC
(In reply to comment #1)
> You shouldn't print anything in profile.d script when the
> shell is non-interactive.

Tomas, that seems to make sense, but is it documented anywhere?

I have been looking, but I haven't found any documentation saying that profile.d
scripts shouldn't print stuff in non-interactive shells.

Comment 3 Tomas Mraz 2008-02-25 09:38:14 UTC
I don't know whether it is explicitely mentioned somewhere but it seems logical
that non-interactive shells should not print anything themselves. When you do
for example 'ssh user@host ls' it will run the ls in non-interactive shell which
means that things printed from profile.d scripts would be concatenated with the
ls output. Even from the definition of the non-interactivity it seems logical to
not put any messages from the shell/profile scripts itself to output as they
won't be possibly getting to the user anyway.

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