summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-01-02 16:27:43 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-01-02 16:27:43 +0000
commit5c3423359b8dc761e190a6de255764cb3a4dd42d (patch)
tree2df7bc18753c0fdbd90094e56000c9ac340c3247 /sbin
parent2295affeb4c0c4f4b69bc9283abc33ce87aee8f5 (diff)
Only check '-l' parameter for regular-fileness. Not built-in default
path. And only error out if the file is successfully lstat()'d and is not a regular file. i.e. aleady exists. Fixes (U)pdate. Removes some accidentally duplicated code.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index c73ed057e6b..e2a4c21517b 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.199 2012/12/29 14:40:00 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.200 2013/01/02 16:27:42 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -309,6 +309,11 @@ main(int argc, char *argv[])
break;
case 'l':
path_dhclient_db = optarg;
+ if (lstat(path_dhclient_db, &sb) != -1) {
+ if (!S_ISREG(sb.st_mode))
+ error("'%s' is not a regular file",
+ path_dhclient_db);
+ }
break;
case 'q':
quiet = 1;
@@ -341,20 +346,6 @@ main(int argc, char *argv[])
_PATH_DHCLIENT_DB, ifi->name) == -1)
error("asprintf");
- if (lstat(path_dhclient_db, &sb) == -1)
- error("Cannot lstat() '%s': %s", path_dhclient_db,
- strerror(errno));
- if (!S_ISREG(sb.st_mode))
- error("'%s' is not a regular file", path_dhclient_db);
-
- if (path_dhclient_conf) {
- if (lstat(path_dhclient_conf, &sb) == -1)
- error("Cannot lstat() '%s': %s", path_dhclient_conf,
- strerror(errno));
- if (!S_ISREG(sb.st_mode))
- error("'%s' is not a regular file", path_dhclient_conf);
- }
-
if (quiet)
log_perror = 0;