summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormlarkin <mlarkin@openbsd.org>2018-03-14 07:29:34 +0000
committermlarkin <mlarkin@openbsd.org>2018-03-14 07:29:34 +0000
commit8c340e5d284cfddd80cf8e87565aeeab48e60970 (patch)
tree33924578c3ca3e15a7d8faa83c1dcaef6baa8338
parentknf (diff)
downloadwireguard-openbsd-8c340e5d284cfddd80cf8e87565aeeab48e60970.tar.xz
wireguard-openbsd-8c340e5d284cfddd80cf8e87565aeeab48e60970.zip
block two VMs from using the same disk image file at the same time.
Also changes an error message in vmctl to reflect same.
-rw-r--r--usr.sbin/vmctl/vmctl.c4
-rw-r--r--usr.sbin/vmd/config.c5
-rw-r--r--usr.sbin/vmd/vmd.c5
3 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/vmctl/vmctl.c b/usr.sbin/vmctl/vmctl.c
index 580a39a0e12..9912e6bbc15 100644
--- a/usr.sbin/vmctl/vmctl.c
+++ b/usr.sbin/vmctl/vmctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmctl.c,v 1.47 2018/03/14 07:07:44 mlarkin Exp $ */
+/* $OpenBSD: vmctl.c,v 1.48 2018/03/14 07:29:34 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
@@ -207,7 +207,7 @@ vm_start_complete(struct imsg *imsg, int *ret, int autoconnect)
*ret = ENOENT;
break;
case VMD_DISK_MISSING:
- warnx("could not find specified disk image(s)");
+ warnx("could not open specified disk image(s)");
*ret = ENOENT;
break;
case VMD_DISK_INVALID:
diff --git a/usr.sbin/vmd/config.c b/usr.sbin/vmd/config.c
index ae3fbebc2b4..b316bb7dcfe 100644
--- a/usr.sbin/vmd/config.c
+++ b/usr.sbin/vmd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.41 2018/01/26 05:34:41 ccardenas Exp $ */
+/* $OpenBSD: config.c,v 1.42 2018/03/14 07:29:34 mlarkin Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -263,7 +263,8 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, uint32_t peerid, uid_t uid)
for (i = 0 ; i < vcp->vcp_ndisks; i++) {
/* Stat disk[i] to ensure it is a regular file */
if ((diskfds[i] =
- open(vcp->vcp_disks[i], O_RDWR)) == -1) {
+ open(vcp->vcp_disks[i], O_RDWR | O_EXLOCK | O_NONBLOCK)) ==
+ -1) {
log_warn("%s: can't open disk %s", __func__,
vcp->vcp_disks[i]);
errno = VMD_DISK_MISSING;
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
index b987b1bd92f..354630401cd 100644
--- a/usr.sbin/vmd/vmd.c
+++ b/usr.sbin/vmd/vmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.c,v 1.80 2018/02/18 01:00:25 pd Exp $ */
+/* $OpenBSD: vmd.c,v 1.81 2018/03/14 07:29:34 mlarkin Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -811,9 +811,10 @@ vmd_configure(void)
* recvfd - for send and receive.
* getpw - lookup user or group id by name.
* chown, fattr - change tty ownership
+ * flock - locking disk files
*/
if (pledge("stdio rpath wpath proc tty recvfd sendfd getpw"
- " chown fattr", NULL) == -1)
+ " chown fattr flock", NULL) == -1)
fatal("pledge");
if (parse_config(env->vmd_conffile) == -1) {