Same story as with unwind(8); dhclient(8) reads the default config /etc/dhclient.conf if present and must run fine if it does not exist, but if `-c' is used, nonexistent files should fail.
$ doas dhclient -c /nonexistent trunk0 trunk0: 192.168.11.51 lease accepted from 192.168.11.1 (00:0d:b9:4c:ee:bd) $ doas ./obj/dhclient -c /nonexistent trunk0 dhclient: /nonexistent: No such file or directory Parsing code is different but I applied the same logic of telling the parser function when to bail out. Feedback? OK? Index: clparse.c =================================================================== RCS file: /cvs/src/sbin/dhclient/clparse.c,v retrieving revision 1.193 diff -u -p -r1.193 clparse.c --- clparse.c 23 Jul 2019 14:09:47 -0000 1.193 +++ clparse.c 26 Nov 2019 00:02:58 -0000 @@ -152,7 +152,8 @@ init_config(void) * | conf-decls conf-decl */ void -read_conf(char *name, char *ignore_list, struct ether_addr *hwaddr) +read_conf(char *name, char *ignore_list, struct ether_addr *hwaddr, + int require_file) { FILE *cfile; int token; @@ -161,7 +162,13 @@ read_conf(char *name, char *ignore_list, new_parse(path_dhclient_conf); - if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) { + cfile = fopen(path_dhclient_conf, "r"); + if (cfile == NULL) { + /* no config file is fine */ + if (errno == ENOENT && require_file) { + err(1, "%s", path_dhclient_conf); + } + } else { for (;;) { token = peek_token(NULL, cfile); if (token == EOF) Index: dhclient.c =================================================================== RCS file: /cvs/src/sbin/dhclient/dhclient.c,v retrieving revision 1.654 diff -u -p -r1.654 dhclient.c --- dhclient.c 22 Nov 2019 22:45:52 -0000 1.654 +++ dhclient.c 26 Nov 2019 00:08:36 -0000 @@ -463,6 +463,7 @@ main(int argc, char *argv[]) int fd, socket_fd[2]; int rtfilter, ioctlfd, routefd; int ch; + int require_file = 0; if (isatty(STDERR_FILENO) != 0) log_init(1, LOG_DEBUG); /* log to stderr until daemonized */ @@ -475,6 +476,7 @@ main(int argc, char *argv[]) switch (ch) { case 'c': path_dhclient_conf = optarg; + require_file = 1; break; case 'd': cmd_opts |= OPT_FOREGROUND; @@ -579,7 +581,7 @@ main(int argc, char *argv[]) fatal("unpriv_ibuf"); imsg_init(unpriv_ibuf, socket_fd[1]); - read_conf(ifi->name, ignore_list, &ifi->hw_address); + read_conf(ifi->name, ignore_list, &ifi->hw_address, require_file); free(ignore_list); if ((cmd_opts & OPT_NOACTION) != 0) return 0; Index: dhcpd.h =================================================================== RCS file: /cvs/src/sbin/dhclient/dhcpd.h,v retrieving revision 1.284 diff -u -p -r1.284 dhcpd.h --- dhcpd.h 22 Nov 2019 22:45:52 -0000 1.284 +++ dhcpd.h 25 Nov 2019 23:28:39 -0000 @@ -239,7 +239,7 @@ uint32_t wrapsum(uint32_t); /* clparse.c */ void init_config(void); -void read_conf(char *, char *, struct ether_addr *); +void read_conf(char *, char *, struct ether_addr *, int); void read_lease_db(struct client_lease_tq *); /* kroute.c */