summaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
authorDenis Vlasenko2006-09-07 17:05:44 +0000
committerDenis Vlasenko2006-09-07 17:05:44 +0000
commit239369b3685473094b2661c05634dfbe26f470b1 (patch)
treeed316732ba1856d03153fcba7a4e47fae92c22c5 /networking/udhcp
parenta9801658ee4b7f5717d145818428452f864e1015 (diff)
downloadbusybox-239369b3685473094b2661c05634dfbe26f470b1.zip
busybox-239369b3685473094b2661c05634dfbe26f470b1.tar.gz
Fix (hopefully) bug 976. Need more thorough audit.
Restore erroneously removed FEATURE_UDHCP_SYSLOG.
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/Config.in10
-rw-r--r--networking/udhcp/common.c6
-rw-r--r--networking/udhcp/dhcpc.c18
-rw-r--r--networking/udhcp/dhcpd.c2
-rw-r--r--networking/udhcp/libbb_udhcp.h2
5 files changed, 27 insertions, 11 deletions
diff --git a/networking/udhcp/Config.in b/networking/udhcp/Config.in
index 7732937..3954b46 100644
--- a/networking/udhcp/Config.in
+++ b/networking/udhcp/Config.in
@@ -37,6 +37,16 @@ config CONFIG_APP_UDHCPC
See http://udhcp.busybox.net for further details.
+config CONFIG_FEATURE_UDHCP_SYSLOG
+ bool "Log udhcp messages to syslog"
+ default n
+ depends on CONFIG_APP_UDHCPD || CONFIG_APP_UDHCPC
+ help
+ If not daemonized, udhcpd prints its messages to stdout/stderr.
+ If this option is selected, it will also log them to syslog.
+
+ See http://udhcp.busybox.net for further details.
+
config CONFIG_FEATURE_UDHCP_DEBUG
bool "Compile udhcp with noisy debugging messages"
default n
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 1ae65f7..c34b3de 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -67,7 +67,7 @@ void udhcp_background(const char *pidfile)
#endif /* __uClinux__ */
}
-void udhcp_start_log_and_pid(const char *client_server, const char *pidfile)
+void udhcp_start_log_and_pid(const char *pidfile)
{
int pid_fd;
@@ -82,9 +82,9 @@ void udhcp_start_log_and_pid(const char *client_server, const char *pidfile)
setlinebuf(stdout);
if (ENABLE_FEATURE_UDHCP_SYSLOG) {
- openlog(client_server, LOG_PID, LOG_LOCAL0);
+ openlog(bb_applet_name, LOG_PID, LOG_LOCAL0);
logmode |= LOGMODE_SYSLOG;
}
- bb_info_msg("%s (v%s) started", client_server, BB_VER);
+ bb_info_msg("%s (v%s) started", bb_applet_name, BB_VER);
}
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 5b2612e..eb1f1db 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -32,6 +32,11 @@
#include "signalpipe.h"
static int state;
+/* Something is definitely wrong here. IPv4 addresses
+ * in variables of type long?? BTW, we use inet_ntoa()
+ * in the code. Manpage says that struct in_addr has a member of type long (!)
+ * which holds IPv4 address, and the struct is passed by value (!!)
+ */
static unsigned long requested_ip; /* = 0 */
static unsigned long server_addr;
static unsigned long timeout;
@@ -267,7 +272,7 @@ int udhcpc_main(int argc, char *argv[])
}
/* Start the log, sanitize fd's, and write a pid file */
- udhcp_start_log_and_pid("udhcpc", client_config.pidfile);
+ udhcp_start_log_and_pid(client_config.pidfile);
if (read_interface(client_config.interface, &client_config.ifindex,
NULL, client_config.arp) < 0)
@@ -446,8 +451,9 @@ int udhcpc_main(int argc, char *argv[])
case INIT_SELECTING:
/* Must be a DHCPOFFER to one of our xid's */
if (*message == DHCPOFFER) {
- if ((temp = get_option(&packet, DHCP_SERVER_ID))) {
- memcpy(&server_addr, temp, 4);
+ temp = get_option(&packet, DHCP_SERVER_ID);
+ if (temp) {
+ server_addr = *(uint32_t*)temp;
xid = packet.xid;
requested_ip = packet.yiaddr;
@@ -465,12 +471,12 @@ int udhcpc_main(int argc, char *argv[])
case RENEWING:
case REBINDING:
if (*message == DHCPACK) {
- if (!(temp = get_option(&packet, DHCP_LEASE_TIME))) {
+ temp = get_option(&packet, DHCP_LEASE_TIME);
+ if (!temp) {
bb_error_msg("No lease time with ACK, using 1 hour lease");
lease = 60 * 60;
} else {
- memcpy(&lease, temp, 4);
- lease = ntohl(lease);
+ lease = ntohl(*(uint32_t*)temp);
}
/* enter bound state */
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 8715661..bee4ffd 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -55,7 +55,7 @@ int udhcpd_main(int argc, char *argv[])
read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
/* Start the log, sanitize fd's, and write a pid file */
- udhcp_start_log_and_pid("udhcpd", server_config.pidfile);
+ udhcp_start_log_and_pid(server_config.pidfile);
if ((option = find_option(server_config.options, DHCP_LEASE_TIME))) {
memcpy(&server_config.lease, option->data + 2, 4);
diff --git a/networking/udhcp/libbb_udhcp.h b/networking/udhcp/libbb_udhcp.h
index b353876..ab4ad06 100644
--- a/networking/udhcp/libbb_udhcp.h
+++ b/networking/udhcp/libbb_udhcp.h
@@ -21,7 +21,7 @@
#define COMBINED_BINARY
void udhcp_background(const char *pidfile);
-void udhcp_start_log_and_pid(const char *client_server, const char *pidfile);
+void udhcp_start_log_and_pid(const char *pidfile);
void udhcp_run_script(struct dhcpMessage *packet, const char *name);