From 5d39640420b21265c258ed1d79c101e08d9276f4 Mon Sep 17 00:00:00 2001 From: kn Date: Mon, 24 Apr 2023 15:12:14 +0000 Subject: [PATCH] Missing the optional default config is not an error /var/log/{messages,daemon} logs ENOENT as error on default configless vmd. Only complain on explicitly passed files and print a debug hint under `-vv' in case someone forgot to populate their /etc/vm.conf. OK dv mlarkin --- usr.sbin/vmd/parse.y | 10 ++++++++-- usr.sbin/vmd/vmd.c | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y index 76c214048dd..e5ede6e70ff 100644 --- a/usr.sbin/vmd/parse.y +++ b/usr.sbin/vmd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.63 2023/01/28 14:40:53 dv Exp $ */ +/* $OpenBSD: parse.y,v 1.64 2023/04/24 15:12:14 kn Exp $ */ /* * Copyright (c) 2007-2016 Reyk Floeter @@ -1181,9 +1181,15 @@ popfile(void) int parse_config(const char *filename) { - struct sym *sym, *next; + extern const char default_conffile[]; + struct sym *sym, *next; if ((file = pushfile(filename, 0)) == NULL) { + /* no default config file is fine */ + if (errno == ENOENT && filename == default_conffile) { + log_debug("%s: missing", filename); + return (0); + } log_warn("failed to open %s", filename); if (errno == ENOENT) return (0); diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index f188e55066e..4d6f4a9a439 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.142 2023/04/23 12:11:37 dv Exp $ */ +/* $OpenBSD: vmd.c,v 1.143 2023/04/24 15:12:14 kn Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -89,6 +89,9 @@ static struct privsep_proc *proc_priv = &procs[0]; static struct passwd proc_privpw; static const uint8_t zero_mac[ETHER_ADDR_LEN]; +const char default_conffile[] = VMD_CONF; +const char *conffile = default_conffile; + int vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg) { @@ -767,7 +770,6 @@ main(int argc, char **argv) { struct privsep *ps; int ch; - const char *conffile = VMD_CONF; enum privsep_procid proc_id = PROC_PARENT; int proc_instance = 0, vm_launch = 0, vm_fd = -1; const char *errp, *title = NULL; -- 2.20.1