Re: Booting into /bin/bash

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Wed Sep 13 2000 - 09:29:22 EST


On Wed, 13 Sep 2000, Miquel van Smoorenburg wrote:

> According to Richard B. Johnson:
> > Without patching the kernel, I think I can show that there is something
> > basically wrong. The patch may just hide the problem.
>
> No.

Try it.

>
> > Something seems to be wrong, even with using the first virtual
> > terminal, which is a 'tty' and should (must) be able to become a
> > a controlling terminal.
>
> Only if you're the process group leader.. read drivers/char/tty_io.c
> function tiocsctty()
>
> And that is the cause of you not being process group leader.
> Stick a setsid() before the tty stuff.
>
> Mike.

Well 'init' was supposed to be the process group leader by default.
however, here is a trace with setsid() just to "make sure".

brk(0) = 0x8049fdc
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
mmap(0, 4096, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4000c000
munmap(0x4000c000, 4096) = 0
mmap(0, 644232, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4000c000
mprotect(0x40097000, 74888, PROT_NONE) = 0
mmap(0x40097000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x8b000) = 0x40097000
mmap(0x4009d000, 50312, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|0x20, 4294967295, 0) = 0x4009d000
close(3) = 0
mprotect(0x4000c000, 569344, PROT_READ|PROT_WRITE) = 0
mprotect(0x4000c000, 569344, PROT_READ|PROT_EXEC) = 0
SYS_136(0, 0x1, 0x4009c02c, 0xbffff77c, 0xbffff774) = 0
getpid() = 6
setsid() = 6
open("/dev/tty1", O_RDWR|O_NONBLOCK) = 3
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)
brk(0) = 0x8049fdc
brk(0x804a02c) = 0x804a02c
brk(0x804b000) = 0x804b000

I think I remember, that there was a discussion several years ago that
"The first N processes are supposed to be special...." so there may
be something bogus keeping them from having a controlling terminal.

Like they may be "marked" as having a controlling terminal, but they
don't really have one. This would cause tiocsctty() to return -EPERM
(line 1553 in tty_io.c).

I will make another experiment and attempt to release any 'controlling
terminal' before I make the call again.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.15 on an i686 machine (797.90 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.

-
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/



This archive was generated by hypermail 2b29 : Fri Sep 15 2000 - 21:00:21 EST