diff options
author | reyk <reyk@openbsd.org> | 2017-05-04 16:54:41 +0000 |
---|---|---|
committer | reyk <reyk@openbsd.org> | 2017-05-04 16:54:41 +0000 |
commit | b55cbc1d207326ae9d0454d138ec80d9a2e1b7d7 (patch) | |
tree | 9ebb5c95b63bcdaa38bd8bba37df7890e690106d /usr.sbin | |
parent | Document that -u wants to read from /dev/mem, so it needs kern.allowkmem=1. (diff) | |
download | wireguard-openbsd-b55cbc1d207326ae9d0454d138ec80d9a2e1b7d7.tar.xz wireguard-openbsd-b55cbc1d207326ae9d0454d138ec80d9a2e1b7d7.zip |
Report error for vmctl commands that need root privileges.
specifically: vmctl (load|reload|reset|log)
Reported by Christian Barthel
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/vmctl/main.c | 15 | ||||
-rw-r--r-- | usr.sbin/vmd/control.c | 15 |
2 files changed, 13 insertions, 17 deletions
diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index 20ced9884e7..5c4b53c8b5d 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.26 2017/04/19 15:38:32 reyk Exp $ */ +/* $OpenBSD: main.c,v 1.27 2017/05/04 16:54:41 reyk Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -213,21 +213,17 @@ vmmaction(struct parse_result *res) case CMD_LOAD: imsg_compose(ibuf, IMSG_VMDOP_LOAD, 0, 0, -1, res->path, strlen(res->path) + 1); - done = 1; break; case CMD_LOG: imsg_compose(ibuf, IMSG_CTL_VERBOSE, 0, 0, -1, &res->verbose, sizeof(res->verbose)); - done = 1; break; case CMD_RELOAD: imsg_compose(ibuf, IMSG_VMDOP_RELOAD, 0, 0, -1, NULL, 0); - done = 1; break; case CMD_RESET: imsg_compose(ibuf, IMSG_CTL_RESET, 0, 0, -1, &res->mode, sizeof(res->mode)); - done = 1; break; case CMD_CREATE: case NONE: @@ -257,12 +253,9 @@ vmmaction(struct parse_result *res) if (IMSG_DATA_SIZE(&imsg) == sizeof(ret)) { memcpy(&ret, imsg.data, sizeof(ret)); errno = ret; - warn("command failed"); - } else { - warnx("command failed"); - } - done = 1; - break; + err(1, "command failed"); + } else + errx(1, "command failed"); } ret = 0; diff --git a/usr.sbin/vmd/control.c b/usr.sbin/vmd/control.c index cb890ca6826..d67b19001ed 100644 --- a/usr.sbin/vmd/control.c +++ b/usr.sbin/vmd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.17 2017/04/21 07:03:26 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.18 2017/05/04 16:54:41 reyk Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org> @@ -363,7 +363,15 @@ control_dispatch_imsg(int fd, short event, void *arg) memcpy(&v, imsg.data, sizeof(v)); log_setverbose(v); + /* FALLTHROUGH */ + case IMSG_VMDOP_LOAD: + case IMSG_VMDOP_RELOAD: + case IMSG_CTL_RESET: proc_forward_imsg(ps, &imsg, PROC_PARENT, -1); + + /* Report success to the control client */ + imsg_compose_event(&c->iev, IMSG_CTL_OK, + 0, 0, -1, NULL, 0); break; case IMSG_VMDOP_START_VM_REQUEST: if (IMSG_DATA_SIZE(&imsg) < sizeof(vmc)) @@ -399,11 +407,6 @@ control_dispatch_imsg(int fd, short event, void *arg) return; } break; - case IMSG_VMDOP_LOAD: - case IMSG_VMDOP_RELOAD: - case IMSG_CTL_RESET: - proc_forward_imsg(ps, &imsg, PROC_PARENT, -1); - break; default: log_debug("%s: error handling imsg %d", __func__, imsg.hdr.type); |