tools/console: xenconsole tolerate tty errors

Since 28d386fc43 (XSA-57), libxl writes an empty value for the
console tty node, with read-only permission for the guest, when
setting up pv console "frontends".  (The actual tty value is later set
by xenconsoled.)   Writing an empty node is not strictly necessary to
stop the frontend from writing dangerous values here, but it is a good
belt-and-braces approach.

Unfortunately this confuses xenconsole.  It reads the empty value, and
tries to open it as the tty.  xenconsole then exits.

Fix this by having xenconsole treat an empty value the same way as no
value at all.

Also, make the error opening the tty be nonfatal: we just print a
warning, but do not exit.  I think this is helpful in theoretical
situations where xenconsole is racing with libxl and/or xenconsoled.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>

---
v2: Combine two conditions and move the free
(cherry picked from commit 39ba2989b1)
(cherry picked from commit 7b161be2e5)

Conflicts:
	tools/console/client/main.c
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Ian Jackson authored and Ian Jackson committed 2015-10-20 17:53:54 +01:00
1 parent 998424e33d
commit 2ddcdd96a0
1 file changed
+3 -3
+3 -3
View File
@@ -115,15 +115,15 @@ static int get_pty_fd(struct xs_handle *xs, char *path, int seconds)
/* We only watch for one thing, so no need to
* disambiguate: just read the pty path */
pty_path = xs_read(xs, XBT_NULL, path, &len);
if (pty_path != NULL) {
if (pty_path != NULL && pty_path[0] != '\0') {
if (access(pty_path, R_OK|W_OK) != 0)
continue;
pty_fd = open(pty_path, O_RDWR | O_NOCTTY);
if (pty_fd == -1)
err(errno, "Could not open tty `%s'",
warn(errno, "Could not open tty `%s'",
pty_path);
free(pty_path);
}
free(pty_path);
}
} while (pty_fd == -1 && (now = time(NULL)) < start + seconds);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.