summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd/vmd.c
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2019-08-14 07:34:49 +0000
committeranton <anton@openbsd.org>2019-08-14 07:34:49 +0000
commitbaf88fe32217dde1aa6c9b6edc9c5119a720d6c8 (patch)
treefccc4f518803954d16c188927831b67e9dad9515 /usr.sbin/vmd/vmd.c
parentmove CONFIG_DRM_FBDEV_EMULATION and CONFIG_BACKLIGHT_CLASS_DEVICE (diff)
downloadwireguard-openbsd-baf88fe32217dde1aa6c9b6edc9c5119a720d6c8.tar.xz
wireguard-openbsd-baf88fe32217dde1aa6c9b6edc9c5119a720d6c8.zip
Improve the error message when supplying an invalid template to vmctl
start. Favoring 'invalid template' over 'permission denied' should give the user a better hint on what went wrong. ok kn@ mlarkin@
Diffstat (limited to 'usr.sbin/vmd/vmd.c')
-rw-r--r--usr.sbin/vmd/vmd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
index 23c34dd6dd1..654af5974d3 100644
--- a/usr.sbin/vmd/vmd.c
+++ b/usr.sbin/vmd/vmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.c,v 1.114 2019/06/28 13:32:51 deraadt Exp $ */
+/* $OpenBSD: vmd.c,v 1.115 2019/08/14 07:34:49 anton Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -1373,9 +1373,14 @@ vm_instance(struct privsep *ps, struct vmd_vm **vm_parent,
/* return without error if the parent is NULL (nothing to inherit) */
if ((vmc->vmc_flags & VMOP_CREATE_INSTANCE) == 0 ||
- (*vm_parent = vm_getbyname(vmc->vmc_instance)) == NULL)
+ vmc->vmc_instance[0] == '\0')
return (0);
+ if ((*vm_parent = vm_getbyname(vmc->vmc_instance)) == NULL) {
+ errno = VMD_PARENT_INVALID;
+ return (-1);
+ }
+
errno = 0;
vmcp = &(*vm_parent)->vm_params;
vcpp = &vmcp->vmc_params;