lkml.org 
[lkml]   [2000]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Booting into /bin/bash
Date
There are two ways for a tty to become a controlling terminal:

1. First tty opened after a successful setsid() call.
2. using the TIOCSCTTY ioctl after a successful setsid() call.

Both will only suceed if the current process does not already have a
controlling terminal.

(Note that TIOCSCTTY takes an argument which means "steal the controlling
tty from another session leader, if any" which only works if the calling
process is UID0).

Therefore...

Richard B. Johnson writes:
> setsid() = 6
> open("/dev/tty1", O_RDWR|O_NONBLOCK) = 3

at this point, tty1 is your controlling terminal (by condition 1 above),
and

> fcntl(3, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
> fcntl(3, F_SETFL, O_RDWR) = 0
> dup2(3, 0) = 0
> dup2(3, 1) = 1
> dup2(3, 2) = 2
> ioctl(3, TIOCSCTTY) = -1 EPERM (Operation not permitted)

fails because you already have a controlling terminal.

Read:
drivers/char/tty_io.c:tiocsctty
drivers/char/tty_io.c:tty_open
kernel/sys.c:sys_setsid

for more information and enlightenment.
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/personal/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:38    [from the cache]
©2003-2011 Jasper Spaans