summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vmd.c
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2019-08-14 07:34:50 +0000
committeranton <anton@cvs.openbsd.org>2019-08-14 07:34:50 +0000
commitfd1e2c3940032086025dddcc3a88bd68b60a78e5 (patch)
treecc7f2ea47b483bcbdde5fbf7ccc3eddd9c5bd448 /usr.sbin/vmd/vmd.c
parentedb34c21723f51d28c4e97cd8762173f7372abed (diff)
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;