summaryrefslogtreecommitdiff
path: root/sysutils/xentools3/patches/patch-ca
blob: 002ce9c80789e05f7effff9e5514d1f4e8f90a6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$NetBSD: patch-ca,v 1.1 2008/03/08 13:59:39 bouyer Exp $

--- console/daemon/io.c.orig	2008-03-08 14:24:52.000000000 +0100
+++ console/daemon/io.c	2008-03-08 14:41:23.000000000 +0100
@@ -56,6 +56,7 @@
 {
 	int domid;
 	int tty_fd;
+	int stty_fd;
 	bool is_dead;
 	struct buffer buffer;
 	struct domain *next;
@@ -160,6 +161,12 @@
 		char *data;
 		unsigned int len;
 
+		if ((dom->stty_fd = open(slave, O_RDONLY, 0)) == -1) {
+			dolog(LOG_ERR, "Failed to open slave tty %s for "
+			    "domain-%d", slave, dom->domid);
+			goto out;
+		}
+
 		if (tcgetattr(master, &term) != -1) {
 			cfmakeraw(&term);
 			tcsetattr(master, TCSAFLUSH, &term);
@@ -444,6 +451,7 @@
 {
 	if (d->tty_fd != -1) {
 		close(d->tty_fd);
+		close(d->stty_fd);
 		d->tty_fd = -1;
 	}
 
@@ -527,6 +535,7 @@
 	len = read(dom->tty_fd, msg, len);
 	if (len < 1) {
 		close(dom->tty_fd);
+		close(dom->stty_fd);
 		dom->tty_fd = -1;
 
 		if (domain_is_valid(dom->domid)) {
@@ -545,6 +554,7 @@
 		xc_evtchn_notify(dom->xce_handle, dom->local_port);
 	} else {
 		close(dom->tty_fd);
+		close(dom->stty_fd);
 		dom->tty_fd = -1;
 		shutdown_domain(dom);
 	}
@@ -564,6 +574,7 @@
 		      dom->domid, len, errno);
 
 		close(dom->tty_fd);
+		close(dom->stty_fd);
 		dom->tty_fd = -1;
 
 		if (domain_is_valid(dom->domid)) {