summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-03-03 19:10:07 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-03-03 19:10:07 +0000
commitb8886ea358afc3903784742f4c3eb31054af0192 (patch)
tree47e9d294e4aa9ae62241736bd65bbef292d7a4c3
parent19143c92472f171b7ba4a5407bca4b10dc1696be (diff)
downloadanaconda-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--ChangeLog8
-rw-r--r--loader2/init.c29
-rw-r--r--rescue.py18
3 files changed, 40 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b917c809..d8ab10c6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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) {
diff --git a/rescue.py b/rescue.py
index a7a8c80ab..e2855aae5 100644
--- a/rescue.py
+++ b/rescue.py
@@ -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)