The TTY now only allows session leaders to open it; consoled only called setsid()

too late, it does it now before starting the console.
This fixes bug #1502, and also allows to debug the GUI servers again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22300 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-09-25 10:51:50 +00:00
parent 57cba4584f
commit e0a627c141
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2005, Haiku. All rights reserved. * Copyright 2004-2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Copyright 2002, Travis Geiselbrecht. All rights reserved. * Copyright 2002, Travis Geiselbrecht. All rights reserved.
@ -12,6 +12,7 @@
#include <ctype.h> #include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -206,7 +207,7 @@ start_console(struct console *con)
con->tty_slave_fd = open(name, O_RDWR); con->tty_slave_fd = open(name, O_RDWR);
if (con->tty_slave_fd < 0) { if (con->tty_slave_fd < 0) {
fprintf(stderr, "Could not open tty!\n"); fprintf(stderr, "Could not open tty %s: %s!\n", name, strerror(errno));
close(con->tty_master_fd); close(con->tty_master_fd);
} else { } else {
// set default mode // set default mode
@ -316,15 +317,15 @@ main(int argc, char **argv)
{ {
int err; int err;
// we're a session leader
setsid();
err = start_console(&gConsole); err = start_console(&gConsole);
if (err < 0) { if (err < 0) {
printf("consoled: error %d starting console\n", err); printf("consoled: error %d starting console\n", err);
return err; return err;
} }
// we're a session leader
setsid();
// move our stdin and stdout to the console // move our stdin and stdout to the console
dup2(gConsole.tty_slave_fd, 0); dup2(gConsole.tty_slave_fd, 0);
dup2(gConsole.tty_slave_fd, 1); dup2(gConsole.tty_slave_fd, 1);