summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-08-14 16:16:06 +0000
committerRoy Marples <roy@marples.name>2008-08-14 16:16:06 +0000
commit68e04b443823cfd04b747a8accd4bdea4f6f74f2 (patch)
treec795d82bdec06b85fe71909a14e81819d21a2f97 /dhcpcd.c
parentfb8a5f981735c7c6a85a9f996cc4bcd39f48e34a (diff)
downloaddhcpcd-68e04b443823cfd04b747a8accd4bdea4f6f74f2.tar.xz
Re-jig the order of doing things to improve our logging.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 2f345ef7..d895016d 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -803,39 +803,10 @@ main(int argc, char **argv)
options->options &= ~DHCPCD_DAEMONISE;
#endif
- if (options->request_address.s_addr == 0 &&
- (options->options & DHCPCD_INFORM ||
- options->options & DHCPCD_REQUEST))
- {
- if (get_address(options->interface,
- &options->request_address,
- &options->request_netmask) != 1)
- {
- logger(LOG_ERR, "no existing address");
- goto abort;
- }
- }
-
- if (IN_LINKLOCAL(ntohl(options->request_address.s_addr))) {
- logger(LOG_ERR,
- "you are not allowed to request a link local address");
- goto abort;
- }
-
if (geteuid())
logger(LOG_WARNING, PACKAGE " will not work correctly unless"
" run as root");
- prefix = xmalloc(sizeof(char) * (IF_NAMESIZE + 3));
- snprintf(prefix, IF_NAMESIZE, "%s: ", options->interface);
- setlogprefix(prefix);
- snprintf(options->pidfile, sizeof(options->pidfile), PIDFILE,
- options->interface);
- free(prefix);
-
- chdir("/");
- umask(022);
-
if (options->options & DHCPCD_TEST) {
if (options->options & DHCPCD_REQUEST ||
options->options & DHCPCD_INFORM) {
@@ -856,6 +827,39 @@ main(int argc, char **argv)
}
}
+ prefix = xmalloc(sizeof(char) * (IF_NAMESIZE + 3));
+ snprintf(prefix, IF_NAMESIZE, "%s: ", options->interface);
+ setlogprefix(prefix);
+ snprintf(options->pidfile, sizeof(options->pidfile), PIDFILE,
+ options->interface);
+ free(prefix);
+
+ if (options->request_address.s_addr == 0 &&
+ (options->options & DHCPCD_INFORM ||
+ options->options & DHCPCD_REQUEST))
+ {
+ errno = 0;
+ if (get_address(options->interface,
+ &options->request_address,
+ &options->request_netmask) != 1)
+ {
+ if (errno)
+ logger(LOG_ERR, "get_address: %s",
+ strerror(errno));
+ else
+ logger(LOG_ERR, "no existing address");
+ goto abort;
+ }
+ }
+ if (IN_LINKLOCAL(ntohl(options->request_address.s_addr))) {
+ logger(LOG_ERR,
+ "you are not allowed to request a link local address");
+ goto abort;
+ }
+
+ chdir("/");
+ umask(022);
+
if (sig != 0 && !(options->options & DHCPCD_DAEMONISED)) {
i = -1;
pid = read_pid(options->pidfile);