Bug 50680 - anti-social to run tty-less scripts with "exec -l"
anti-social to run tty-less scripts with "exec -l"
Product: Red Hat Raw Hide
Classification: Retired
Component: xinitrc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Mike A. Harris
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2001-08-01 20:54 EDT by Jonathan Kamens
Modified: 2007-04-18 12:35 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-08-01 21:48:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jonathan Kamens 2001-08-01 20:54:48 EDT
The recent changes to xinitrc to use "exec -l" instead of "exec" to start
the user's session are problematic.

In particular, it is reasonable for a user to assume, when writing his
.login or .profile file, that it will be executed in a terminal, since how
can you log in without a terminal?  But the commands run in
/etc/X11/xdm/Xsession are not, in fact, run in a terminal.  This causes all
kinds of grief from my .login file.  Here's my ~/.xsession-errors file from
just logging in:

Enter SSH passphrase: 
Entering port-forwarding mode: P4PORT=1666, PID=21293
jik:~!1> cat ~/.xsession-errors 
Enter SSH passphrase: stty: impossible in this context
are you disconnected or in a batch, at, or cron script?stty: ioctl(user):
bad file number

    while executing
"stty -echo"
    ("while" body line 4)
    invoked from within
"while {1} {
    send_user "Enter SSH passphrase: "

    stty -echo

    set old_timeout $timeout
    set timeout -1
    expect_user {
        -re "(.+..."
    (file "/home/jik/scripts/ssh-add-both" line 8)
Could not open a connection to your authentication agent.
Agent pid 21177
stderr is not a tty - where are you?
stderr is not a tty - where are you?

It's prompting me for my passphrase because my .login does that, which is
quite reasonable because it's supposed to be running inside a tty.  All of
the stty you see are from an expect script which has the same problem.

Basically, I'm not at all convinced this change is appropriate.
Comment 1 Havoc Pennington 2001-08-01 22:16:25 EDT
> how can you log in without a terminal? 

Well, the answer is "using xdm/gdm/kdm", basically ;-)

An X session is a login session. Read the "INVOCATION" section in the bash man
page - there are interactive shells and login shells. Login shells may or may
not be interactive shells.

So in your .profile you would do something like: 

if test -n "$PS1"; then 
  echo "This is an interactive shell"
  ## etc.

But X session login shells could also be interactive I suppose, e.g. if you use
startx instead of *dm.

Actually my bash help probably isn't so useful - since you are using .login I
assume you're using tcsh. Xsession has always run a bash as a login shell; we
changed it to make tcsh, etc. consistent. So bash users will already be seeing
the no-tty-login-shell behavior and have dealt with this... but tcsh users were
not getting their session set up properly (/etc/csh.login did not affect the
entire X session).

Quickly scanning the tcsh man page I don't see how to check whether you have an
interactive shell, but there must be a way to do that in tcsh.

We definitely need a mention of this change in the release notes...

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