From: Antonio Huete Jimenez Date: Wed, 1 Aug 2012 18:36:59 +0000 (+0200) Subject: dhclient - Print out debug messages only when DEBUG is defined. X-Git-Tag: v3.2.0~348 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/4cada237105de20b71c83bc565f08d8f6860aa9d dhclient - Print out debug messages only when DEBUG is defined. Taken-from: OpenBSD --- diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 1315047440..a5d8d9f8ac 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.128 2009/06/03 02:05:34 stevesk Exp $ */ +/* $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.129 2009/06/06 04:02:42 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -231,9 +231,11 @@ routehandler(void) linkstat = LINK_STATE_IS_UP(ifm->ifm_data.ifi_link_state) ? 1 : 0; if (linkstat != ifi->linkstat) { +#ifdef DEBUG debug("link state %s -> %s", ifi->linkstat ? "up" : "down", linkstat ? "up" : "down"); +#endif ifi->linkstat = interface_link_status(ifi->name); if (ifi->linkstat) { client->state = S_INIT; @@ -754,7 +756,9 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options) if (lease->address.len == sizeof(client->packet.yiaddr) && !memcmp(lease->address.iabuf, &client->packet.yiaddr, lease->address.len)) { +#ifdef DEBUG debug("%s already seen.", name); +#endif return; } } diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index db7ac74ec4..53fd65ffde 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: src/sbin/dhclient/dhcpd.h,v 1.68 2009/03/10 23:19:36 krw Exp $ */ +/* $OpenBSD: src/sbin/dhclient/dhcpd.h,v 1.69 2009/06/06 04:02:42 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -219,7 +219,9 @@ extern int warnings_occurred; void error(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); int warning(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); int note(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +#ifdef DEBUG int debug(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +#endif int parse_warn(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); /* conflex.c */ diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 38461c7a16..5350265917 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: src/sbin/dhclient/dispatch.c,v 1.43 2009/02/19 03:29:21 krw Exp $ */ +/* $OpenBSD: src/sbin/dhclient/dispatch.c,v 1.44 2009/06/06 04:02:42 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -318,9 +318,10 @@ interface_status(char *ifname) * EINVAL or ENOTTY simply means that the interface * does not support the SIOCGIFMEDIA ioctl. We regard it alive. */ +#ifdef DEBUG if (errno != EINVAL && errno != ENOTTY) debug("ioctl(SIOCGIFMEDIA) on %s: %m", ifname); - +#endif ifi->noifmedia = 1; goto active; } @@ -434,8 +435,10 @@ interface_link_status(char *ifname) strlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name)); if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) { /* EINVAL/ENOTTY -> link state unknown. treat as active */ +#ifdef DEBUG if (errno != EINVAL && errno != ENOTTY) debug("ioctl(SIOCGIFMEDIA) on %s: %m", ifname); +#endif close(sock); return (1); } diff --git a/sbin/dhclient/errwarn.c b/sbin/dhclient/errwarn.c index d8dbcbae13..bbbcaf2e0f 100644 --- a/sbin/dhclient/errwarn.c +++ b/sbin/dhclient/errwarn.c @@ -140,6 +140,7 @@ note(char *fmt, ...) return (0); } +#ifdef DEBUG /* * Log a debug message... */ @@ -154,9 +155,7 @@ debug(char *fmt, ...) vsnprintf(mbuf, sizeof(mbuf), fbuf, list); va_end(list); -#ifndef DEBUG syslog(LOG_DEBUG, "%s", mbuf); -#endif if (log_perror) { write(STDERR_FILENO, mbuf, strlen(mbuf)); @@ -165,7 +164,7 @@ debug(char *fmt, ...) return (0); } - +#endif /* * Find %m in the input string and substitute an error message string. */ diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c index 8e88ad9dce..6a1ac4c1bc 100644 --- a/sbin/dhclient/packet.c +++ b/sbin/dhclient/packet.c @@ -1,5 +1,4 @@ -/* $OpenBSD: packet.c,v 1.12 2006/12/28 01:10:46 stevesk Exp $ */ -/* $DragonFly: src/sbin/dhclient/packet.c,v 1.1 2008/08/30 16:07:58 hasso Exp $ */ +/* $OpenBSD: src/sbin/dhclient/packet.c,v 1.13 2009/06/06 04:02:42 krw Exp $ */ /* Packet assembly code, originally contributed by Archie Cobbs. */ @@ -190,10 +189,11 @@ decode_udp_ip_header(unsigned char *buf, int bufix, struct sockaddr_in *from, return (-1); } +#ifdef DEBUG if (ntohs(ip->ip_len) != buflen) debug("ip length %d disagrees with bytes received %d.", ntohs(ip->ip_len), buflen); - +#endif memcpy(&from->sin_addr, &ip->ip_src, 4); /* @@ -218,8 +218,10 @@ decode_udp_ip_header(unsigned char *buf, int bufix, struct sockaddr_in *from, } return (-1); } +#ifdef DEBUG if (len + data != buf + bufix + buflen) debug("accepting packet with data after udp payload."); +#endif } usum = udp->uh_sum; diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c index 646bdd76b7..bb2c2411c0 100644 --- a/sbin/dhclient/privsep.c +++ b/sbin/dhclient/privsep.c @@ -1,5 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.14 2007/02/15 15:22:27 stevesk Exp $ */ -/* $DragonFly: src/sbin/dhclient/privsep.c,v 1.1 2008/08/30 16:07:58 hasso Exp $ */ +/* $OpenBSD: src/sbin/dhclient/privsep.c,v 1.15 2009/06/06 04:02:42 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -78,7 +77,9 @@ buf_read(int sock, void *buf, size_t nbytes) do { n = read(sock, buf, nbytes); if (n == 0) { /* connection closed */ +#ifdef DEBUG debug("buf_read (connection closed)"); +#endif exit(1); } if (n != -1 && n < nbytes)