summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd/vmd.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-01-08 11:58:27 +0000
committermpi <mpi@openbsd.org>2018-01-08 11:58:27 +0000
commit0077bcdf4243c5c43b9eb460ead1664bc507ea53 (patch)
treeedbc4da267eb8ca44065e377330981ac831701ab /usr.sbin/vmd/vmd.c
parentAllow TIOCUCNTL issued on a pty(4) master in promise "tty". (diff)
downloadwireguard-openbsd-0077bcdf4243c5c43b9eb460ead1664bc507ea53.tar.xz
wireguard-openbsd-0077bcdf4243c5c43b9eb460ead1664bc507ea53.zip
Enable TIOCUCNTL to be able to set ns8250's break detected condition.
It is now possible to send BREAK commands to vmd(8) independently of the serial terminal emulator. Happy virtual ddb(4) hacking! No objection from mlarkin@, ok nicm@, ccardenas@, deraadt@
Diffstat (limited to 'usr.sbin/vmd/vmd.c')
-rw-r--r--usr.sbin/vmd/vmd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
index f0ca84709d2..450e8f8babd 100644
--- a/usr.sbin/vmd/vmd.c
+++ b/usr.sbin/vmd/vmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.c,v 1.77 2018/01/03 05:39:56 ccardenas Exp $ */
+/* $OpenBSD: vmd.c,v 1.78 2018/01/08 11:58:27 mpi Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -22,6 +22,7 @@
#include <sys/cdefs.h>
#include <sys/stat.h>
#include <sys/tty.h>
+#include <sys/ttycom.h>
#include <sys/ioctl.h>
#include <stdio.h>
@@ -800,7 +801,7 @@ vmd_configure(void)
* stdio - for malloc and basic I/O including events.
* rpath - for reload to open and read the configuration files.
* wpath - for opening disk images and tap devices.
- * tty - for openpty.
+ * tty - for openpty and TIOCUCNTL.
* proc - run kill to terminate its children safely.
* sendfd - for disks, interfaces and other fds.
* recvfd - for send and receive.
@@ -1273,6 +1274,7 @@ vm_opentty(struct vmd_vm *vm)
uid_t uid;
gid_t gid;
mode_t mode;
+ int on;
/*
* Open tty with pre-opened PTM fd
@@ -1280,6 +1282,13 @@ vm_opentty(struct vmd_vm *vm)
if ((ioctl(env->vmd_ptmfd, PTMGET, &ptm) == -1))
return (-1);
+ /*
+ * We use user ioctl(2) mode to pass break commands.
+ */
+ on = 1;
+ if (ioctl(ptm.cfd, TIOCUCNTL, &on))
+ fatal("could not enable user ioctl mode");
+
vm->vm_tty = ptm.cfd;
close(ptm.sfd);
if ((vm->vm_ttyname = strdup(ptm.sn)) == NULL)