diff options
author | David Cantrell <dcantrell@redhat.com> | 2006-03-03 19:10:07 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2006-03-03 19:10:07 +0000 |
commit | b8886ea358afc3903784742f4c3eb31054af0192 (patch) | |
tree | 47e9d294e4aa9ae62241736bd65bbef292d7a4c3 | |
parent | 19143c92472f171b7ba4a5407bca4b10dc1696be (diff) | |
download | anaconda-b8886ea358afc3903784742f4c3eb31054af0192.tar.gz anaconda-b8886ea358afc3903784742f4c3eb31054af0192.tar.xz anaconda-b8886ea358afc3903784742f4c3eb31054af0192.zip |
* rescue.py: Added runShell() to handle spawning the tty1 shell for
rescue mode and set the controlling tty (#182222).
* loader2/init.c: Do not disable Ctrl+C, Ctrl+Z, and friends if we're
starting in rescue mode. Set controlling tty before dup2() calls.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | loader2/init.c | 29 | ||||
-rw-r--r-- | rescue.py | 18 |
3 files changed, 40 insertions, 15 deletions
@@ -1,3 +1,11 @@ +2006-03-03 David Cantrell <dcantrell@redhat.com> + + * rescue.py: Added runShell() to handle spawning the tty1 shell for + rescue mode and set the controlling tty (#182222). + + * loader2/init.c: Do not disable Ctrl+C, Ctrl+Z, and friends if we're + starting in rescue mode. Set controlling tty before dup2() calls. + 2006-03-03 Jeremy Katz <katzj@redhat.com> * anaconda.spec: Bump version. diff --git a/loader2/init.c b/loader2/init.c index 275c178bb..13843a07d 100644 --- a/loader2/init.c +++ b/loader2/init.c @@ -519,7 +519,7 @@ int main(int argc, char **argv) { char ** argvp = argvc; char twelve = 12; struct serial_struct si; - int i; + int i, disable_keys; if (!strncmp(basename(argv[0]), "poweroff", 8)) { printf("Running poweroff...\n"); @@ -691,6 +691,11 @@ int main(int argc, char **argv) { if (testing) exit(0); + setsid(); + if (ioctl(0, TIOCSCTTY, NULL)) { + printf("could not set new controlling tty\n"); + } + dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); @@ -701,16 +706,18 @@ int main(int argc, char **argv) { dup2(0, 2); #endif - /* disable Ctrl+Z, Ctrl+C, etc */ - tcgetattr(0, &ts); - ts.c_iflag &= ~BRKINT; - ts.c_iflag |= IGNBRK; - ts.c_iflag &= ~ISIG; - tcsetattr(0, TCSANOW, &ts); - - setsid(); - if (ioctl(0, TIOCSCTTY, NULL)) { - printf("could not set new controlling tty\n"); + /* disable Ctrl+Z, Ctrl+C, etc ... but not in rescue mode */ + disable_keys = 1; + if (argc > 1) + if (mystrstr(argv[1], "rescue")) + disable_keys = 0; + + if (disable_keys) { + tcgetattr(0, &ts); + ts.c_iflag &= ~BRKINT; + ts.c_iflag |= IGNBRK; + ts.c_iflag &= ~ISIG; + tcsetattr(0, TCSANOW, &ts); } if (!testing) { @@ -24,6 +24,8 @@ import isys import iutil import fsset import shutil +import fcntl +import termios from rhpl.translate import _ @@ -162,7 +164,15 @@ def startNetworking(network, intf): f.close() - +def runShell(): + shpid = os.fork() + if shpid == 0: + os.setsid() + fcntl.ioctl(0, termios.TIOCSCTTY) + os.execv("/bin/sh", ["-/bin/sh"]) + else: + os.waitpid(shpid, 0) + def runRescue(instPath, mountroot, id): for file in [ "services", "protocols", "group", "joe", "man.config", @@ -245,7 +255,7 @@ def runRescue(instPath, mountroot, id): print _("When finished please exit from the shell and your " "system will reboot.") print - os.system("/bin/sh") + runShell() sys.exit(0) # lets create some devices @@ -281,7 +291,7 @@ def runRescue(instPath, mountroot, id): print _("When finished please exit from the shell and your " "system will reboot.") print - os.execv("/bin/sh", [ "-/bin/sh" ]) + runShell() elif rc == string.lower(_("Read-Only")): readOnly = 1 else: @@ -449,5 +459,5 @@ def runRescue(instPath, mountroot, id): print _("When finished please exit from the shell and your " "system will reboot.") print - os.system("/bin/sh") + runShell() sys.exit(0) |