summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2020-12-06 17:40:44 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2020-12-06 17:40:44 +0000
commitbb1a3dce6989616699f0968724571acf3cc884bd (patch)
tree4ec34ff59ae5a80ae307e2bdceecb0eeb84e536f /sbin
parentaf272d5a5f17abca1abcfac1e13ceb1f4db33366 (diff)
fatal() immediately whem parsing command line option '-c' reveals a non-existant
file. Original diff, tweaks & ok kn@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.87
-rw-r--r--sbin/dhclient/dhclient.c28
-rw-r--r--sbin/dhclient/dhcpd.h3
3 files changed, 17 insertions, 21 deletions
diff --git a/sbin/dhclient/dhclient.8 b/sbin/dhclient/dhclient.8
index 875a6e7dcce..17cd6f2bc64 100644
--- a/sbin/dhclient/dhclient.8
+++ b/sbin/dhclient/dhclient.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: dhclient.8,v 1.44 2020/11/06 21:53:55 krw Exp $
+.\" $OpenBSD: dhclient.8,v 1.45 2020/12/06 17:40:43 krw Exp $
.\"
.\" Copyright (c) 1997 The Internet Software Consortium.
.\" All rights reserved.
@@ -35,7 +35,7 @@
.\" Enterprises. To learn more about the Internet Software Consortium,
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
-.Dd $Mdocdate: November 6 2020 $
+.Dd $Mdocdate: December 6 2020 $
.Dt DHCLIENT 8
.Os
.Sh NAME
@@ -81,6 +81,9 @@ The options are as follows:
Specify an alternate location to
.Pa /etc/dhclient.conf
for the configuration file.
+If
+.Ar file
+is the empty string then no configuration file is read.
.It Fl d
Do not daemonize.
If this option is specified,
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 3238da5a7b2..c9c0c2133b8 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.688 2020/12/01 14:55:40 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.689 2020/12/06 17:40:43 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -95,7 +95,7 @@
#include "log.h"
#include "privsep.h"
-char *path_dhclient_conf = _PATH_DHCLIENT_CONF;
+char *path_dhclient_conf;
char *path_lease_db;
char *log_procname;
@@ -637,13 +637,18 @@ main(int argc, char *argv[])
log_setverbose(0); /* Don't show log_debug() messages. */
+ if (lstat(_PATH_DHCLIENT_CONF, &sb) == 0)
+ path_dhclient_conf = _PATH_DHCLIENT_CONF;
+
while ((ch = getopt(argc, argv, "c:di:nrv")) != -1)
switch (ch) {
case 'c':
- if (optarg == NULL)
- usage();
- cmd_opts |= OPT_CONFPATH;
- path_dhclient_conf = optarg;
+ if (strlen(optarg) == 0)
+ path_dhclient_conf = NULL;
+ else if (lstat(optarg, &sb) == 0)
+ path_dhclient_conf = optarg;
+ else
+ fatal("lstat(%s)", optarg);
break;
case 'd':
cmd_opts |= OPT_FOREGROUND;
@@ -673,17 +678,6 @@ main(int argc, char *argv[])
if (argc != 1)
usage();
- if ((cmd_opts & OPT_CONFPATH) != 0) {
- if (lstat(path_dhclient_conf, &sb) == -1) {
- /*
- * Non-existant file is OK. It lets you ignore
- * /etc/dhclient.conf for testing.
- */
- if (errno != ENOENT)
- fatal("lstat(%s)", path_dhclient_conf);
- }
- }
-
if ((cmd_opts & (OPT_FOREGROUND | OPT_NOACTION)) != 0)
cmd_opts |= OPT_VERBOSE;
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 3d6fe046bc0..6db785d097d 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.288 2020/11/06 21:53:55 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.289 2020/12/06 17:40:43 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -215,7 +215,6 @@ extern int cmd_opts;
#define OPT_VERBOSE 0x02
#define OPT_FOREGROUND 0x04
#define OPT_RELEASE 0x08
-#define OPT_CONFPATH 0x10
#define OPT_IGNORELIST 0x40
void dhcpoffer(struct interface_info *, struct option_data *,