diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2023-07-03 08:32:21 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2023-07-03 08:32:21 +0000 |
commit | 09582826dbf74b0a7c8e5a47d00aaf7636344d28 (patch) | |
tree | 66da32a8345a6183bfd9b1fc1fbf05823c37af04 /usr.sbin/vmd/vmd.c | |
parent | 35c2bf23ca7fa52a64e076235a093905e3c8f600 (diff) |
when shutting down a vm, handle the VM id in the same way as a VM name argument
ok dv@
Diffstat (limited to 'usr.sbin/vmd/vmd.c')
-rw-r--r-- | usr.sbin/vmd/vmd.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 3ba9c6792fd..1b7cc3270c5 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.150 2023/06/18 11:45:11 op Exp $ */ +/* $OpenBSD: vmd.c,v 1.151 2023/07/03 08:32:20 jasper Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -159,20 +159,22 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg) if ((vm = vm_getbyname(vid.vid_name)) == NULL) { res = ENOENT; break; - } else if ((vm->vm_state & VM_STATE_SHUTDOWN) && - (flags & VMOP_FORCE) == 0) { - res = EALREADY; - break; - } else if (!(vm->vm_state & VM_STATE_RUNNING)) { - res = EINVAL; - break; } id = vm->vm_vmid; } else if ((vm = vm_getbyvmid(id)) == NULL) { res = ENOENT; break; } - if (vm_checkperm(vm, &vm->vm_params.vmc_owner, vid.vid_uid)) { + + /* Validate curent state of vm */ + if ((vm->vm_state & VM_STATE_SHUTDOWN) && + (flags & VMOP_FORCE) == 0) { + res = EALREADY; + break; + } else if (!(vm->vm_state & VM_STATE_RUNNING)) { + res = EINVAL; + break; + } else if (vm_checkperm(vm, &vm->vm_params.vmc_owner, vid.vid_uid)) { res = EPERM; break; } |