-/* $OpenBSD: dhcpleased.c,v 1.23 2022/01/04 06:20:37 florian Exp $ */
+/* $OpenBSD: dhcpleased.c,v 1.24 2022/03/21 04:35:41 dlg Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
#ifndef SMALL
struct dhcpleased_conf *main_conf;
#endif
-char *conffile;
+const char default_conffile[] = _PATH_CONF_FILE;
+const char *conffile = default_conffile;
pid_t frontend_pid;
pid_t engine_pid;
warnx("control socket setup failed");
#endif /* SMALL */
- if (conffile != NULL) {
- if (unveil(conffile, "r") == -1)
- fatal("unveil %s", conffile);
- } else {
- if (unveil(_PATH_CONF_FILE, "r") == -1)
- fatal("unveil %s", _PATH_CONF_FILE);
- }
+ if (unveil(conffile, "r") == -1)
+ fatal("unveil %s", conffile);
if (unveil("/dev/bpf", "rw") == -1)
fatal("unveil /dev/bpf");
-/* $OpenBSD: dhcpleased.h,v 1.13 2022/01/04 06:20:37 florian Exp $ */
+/* $OpenBSD: dhcpleased.h,v 1.14 2022/03/21 04:35:41 dlg Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
void print_config(struct dhcpleased_conf *);
/* parse.y */
-struct dhcpleased_conf *parse_config(char *);
+struct dhcpleased_conf *parse_config(const char *);
int cmdline_symset(char *);
#else
#define sin_to_str(x...) ""
-/* $OpenBSD: parse.y,v 1.6 2022/01/04 06:20:37 florian Exp $ */
+/* $OpenBSD: parse.y,v 1.7 2022/03/21 04:35:41 dlg Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
}
struct dhcpleased_conf *
-parse_config(char *filename)
+parse_config(const char *filename)
{
+ extern const char default_conffile[];
struct sym *sym, *next;
conf = config_new_empty();
- file = pushfile(filename != NULL ? filename : _PATH_CONF_FILE, 0);
+ file = pushfile(filename, 0);
if (file == NULL) {
/* no default config file is fine */
- if (errno == ENOENT && filename == NULL)
+ if (errno == ENOENT && filename == default_conffile)
return (conf);
log_warn("%s", filename);
free(conf);