Controlling terminal related changes:

* It is possible to acquire a tty that is already open, iff it is not a
  controlling terminal yet and the process is a session leader.
* Also set the terminal process group when acquiring a controlling
  terminal.

telnetd/login and sshd are a lot happier now (and so am I :-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-04-24 21:16:57 +00:00
parent e225a906d2
commit 719f971dea
+17 -7
View File
@@ -70,8 +70,16 @@ slave_open(const char *name, uint32 flags, void **_cookie)
// If already open, we allow only processes from the same session
// to open the tty again.
pid_t ttySession = gSlaveTTYs[index].settings->session_id;
if (ttySession < 0 || ttySession != sessionID)
return B_NOT_ALLOWED;
if (ttySession >= 0) {
if (ttySession != sessionID)
return B_NOT_ALLOWED;
makeControllingTTY = false;
} else {
// The tty is not associated with a session yet. The process needs
// to be a session leader.
if (makeControllingTTY && processID != sessionID)
return B_NOT_ALLOWED;
}
}
slave_cookie *cookie = (slave_cookie *)malloc(sizeof(struct slave_cookie));
@@ -95,12 +103,14 @@ slave_open(const char *name, uint32 flags, void **_cookie)
if (gSlaveTTYs[index].open_count == 0) {
gSlaveTTYs[index].lock = gMasterTTYs[index].lock;
gSlaveTTYs[index].settings->session_id = -1;
gSlaveTTYs[index].settings->pgrp_id = -1;
}
if (makeControllingTTY) {
gSlaveTTYs[index].settings->session_id = sessionID;
team_set_controlling_tty(gSlaveTTYs[index].index);
} else
gSlaveTTYs[index].settings->session_id = -1;
if (makeControllingTTY) {
gSlaveTTYs[index].settings->session_id = sessionID;
gSlaveTTYs[index].settings->pgrp_id = sessionID;
team_set_controlling_tty(gSlaveTTYs[index].index);
}
add_tty_cookie(cookie);