lkml.org 
[lkml]   [2000]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
SubjectRe: Booting into /bin/bash
On Tue, 12 Sep 2000, Ion Badulescu wrote:

> Maybe I'll play with main.c and see what happens if I force /dev/console
> to become the controlling tty for init. Hmm... That could be dangerous for
> init. Maybe a better idea would be to hack init so that it gives any
> program started from inittab /dev/console as the controlling tty.
>
> You're the sysvinit maintainer, right? :) What do you think of this idea?

... and init already does the above. :-) Except for one case: the
emergency shell doesn't get a controlling tty. The first mini-patch below
takes care of that problem.

This still doesn't solve the original problem, i.e. init (or whatever you
pass as init) still doesn't get a controlling tty from the kernel.
However, since init appears to be safe from these issues, it it fairly
trivial to fix this in the kernel; the second patch below takes care of
it. The patch is against 2.2.17 but will apply against pretty much any 2.2
and 2.4 kernel. It's is for i386 only, but the fixup for other
architectures is extremely obvious.


Ion

--
It is better to keep your mouth shut and be thought a fool,
than to open it and remove all doubt.
--- sysvinit-2.78/src/init.c.orig Tue Sep 12 04:31:47 2000
+++ sysvinit-2.78/src/init.c Tue Sep 12 04:15:10 2000
@@ -88,7 +88,7 @@
CHILD *newFamily = NULL; /* The list after inittab re-read */

CHILD ch_emerg = { /* Emergency shell */
- 0, 0, 0, 0, 0,
+ WAITING, 0, 0, 0, 0,
"~~",
"S",
3,--- tmp/linux-2.2.17/include/asm-i386/unistd.h Wed Jan 20 11:06:24 1999
+++ linux-2.2.17/include/asm-i386/unistd.h Tue Sep 12 17:56:07 2000
@@ -301,6 +301,7 @@
static inline _syscall1(int,_exit,int,exitcode)
static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
static inline _syscall1(int,delete_module,const char *,name)
+static inline _syscall3(int,ioctl,int,d,int,request,long,argp)

static inline pid_t wait(int * wait_stat)
{
--- tmp/linux-2.2.17/init/main.c Wed Sep 6 12:40:14 2000
+++ linux-2.2.17/init/main.c Tue Sep 12 18:44:02 2000
@@ -1607,6 +1604,7 @@
static int init(void * unused)
{
lock_kernel();
+ setsid();
do_basic_setup();

/*
@@ -1622,7 +1620,9 @@

(void) dup(0);
(void) dup(0);
-
+ if (ioctl(0, TIOCSCTTY, 1) < 0)
+ printk("Error while establishing a controlling tty.\n");
+
/*
* We try each of these until one succeeds.
*
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.111 / U:6.864 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site