diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-12-06 01:16:23 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-12-06 01:16:23 +0000 |
commit | d5d4daedcd59e86686b9eb74f78039bae423b84c (patch) | |
tree | da81fb749351e0b9c496fe61ed00685a9f01b093 | |
parent | e6119262679d899647ea4cd0bcc1a87d53b2b00e (diff) |
Check errno from config_getvm() correctly
-rw-r--r-- | usr.sbin/vmd/parse.y | 16 | ||||
-rw-r--r-- | usr.sbin/vmd/vmd.c | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y index 165f23a2a4f..651f0dad768 100644 --- a/usr.sbin/vmd/parse.y +++ b/usr.sbin/vmd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.1 2015/12/03 16:11:32 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.2 2015/12/06 01:16:22 reyk Exp $ */ /* * Copyright (c) 2007-2015 Reyk Floeter <reyk@openbsd.org> @@ -143,6 +143,8 @@ main : VM STRING { YYERROR; } } '{' optnl vm_opts_l '}' { + int ret; + if (vcp_disable) { log_debug("%s:%d: vm \"%s\" disabled (skipped)", file->name, yylval.lineno, vcp.vcp_name); @@ -152,15 +154,17 @@ main : VM STRING { * XXX this should be done after parsing * XXX the configuration. */ - if (config_getvm(&env->vmd_ps, &vcp, - -1, -1) == -1) { - log_warnx("%s:%d: vm \"%s\" failed", + ret = config_getvm(&env->vmd_ps, &vcp, -1, -1); + if (ret == -1) { + log_warn("%s:%d: vm \"%s\" failed", file->name, yylval.lineno, vcp.vcp_name); YYERROR; + } else { + log_debug("%s:%d: vm \"%s\" enabled", + file->name, yylval.lineno, + vcp.vcp_name); } - log_debug("%s:%d: vm \"%s\" enabled", - file->name, yylval.lineno, vcp.vcp_name); } } ; diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 22546e2b183..74a63e860f5 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.17 2015/12/05 20:33:51 reyk Exp $ */ +/* $OpenBSD: vmd.c,v 1.18 2015/12/06 01:16:22 reyk Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -67,7 +67,7 @@ vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg) memcpy(&vcp, imsg->data, sizeof(vcp)); res = config_getvm(ps, &vcp, -1, imsg->hdr.peerid); if (res == -1) { - res = EINVAL; + res = errno; cmd = IMSG_VMDOP_START_VM_RESPONSE; } break; |