How to disable Ctrl-C during init (initial ramdisk / normal init )

Yoann Allain yallain at avilinks.com
Mon May 29 07:59:54 UTC 2006


Rob Landley a écrit :

>On Tuesday 23 May 2006 11:46 am, Rich Felker wrote:
>  
>
>>While there are some additional semantics, /dev/console is the same as
>>/dev/tty0 which is in turn the same as the currently selected virtual
>>terminal. Unless of course you mean to connect /dev/console to a
>>serial device, which depends on actually having a serial device. All
>>of this sounds incredibly stupid to me. NO device, whether local,
>>remote, connected, unconnected, etc. should unconditionally allow
>>random people to interfere with system processes. It's just bad,
>>insecure system design.
>>    
>>
>
>I note with interest the number of hoops I had to jump through to get ctrl-c 
>to work on an "init=/bin/sh" variant, because /dev/console does _not_ 
>actually provide those signals, and PID 1 has those signals blocked anyway.
>
>What the guy's talking about is his init _script_, a child process of init, 
>being attatched to /dev/tty0 instead of /dev/console, and thus receiving 
>signals generated via ctrl-c or ctrl-s.
>
>According to http://busybox.net/downloads/BusyBox.html#item_init the first 
>field of busybox init lines is the device to run it on (the /dev/ prefix is 
>optional), and the default is tty0, so you might want to change:
>
>::sysinit:/etc/init.d/rcS
>
>into:
>
>console::sysinit:/etc/init.d/rcS
>
>Not that I've tried it...
>
>Rob
>  
>

Well I've tried with

console::sysinit:/etc/init.d/rcS

but I was still able to stop the init with Ctrl-C... But with 

null::sysinit:/etc/init.d/rcS

All the signals seems to be ignored so the init goes till the end, although I have no more messages printed, but in my case this is not a problem.

The next thing was to do the same with /linuxrc file that I use in a initial ramdisk. His purpose is to load a MMC driver which is used to mount the root filesystem during last part of init. I could also stop this script with Ctrl-C. I found one solution by modifying the kernel file do_mount.c : I replace /dev/console by /dev/null in do_linuxrc function. And this way I cannot stop the driver loading.
I was also thinking of replacing /linuxrc script by a small C program which would do something like system("insmod mmc_drv.o") after having disabled signals (SIGINT). But I don't know what solution is best, if there is one enough good...

Yoann







More information about the busybox mailing list