* Doesn't require the 'hostname' option in /etc/network/interfaces,
  and thus makes udhcpc behave like other clients.

Signed-off-by: Andreas Oberritter <[email protected]>
---
 networking/udhcp/dhcpc.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index fe2e681..35487b6 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1375,6 +1375,15 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
                logmode |= LOGMODE_SYSLOG;
        }
 
+       /* try to get hostname from OS */
+       if (!client_config.hostname) {
+               char hostname[256];     /* SUSv2: hostnames are <= 255 bytes */
+               if (gethostname(hostname, sizeof(hostname)) == 0) {
+                       hostname[sizeof(hostname) - 1] = '\0';
+                       client_config.hostname = 
alloc_dhcp_option(DHCP_HOST_NAME, hostname, 0);
+               }
+       }
+
        /* Make sure fd 0,1,2 are open */
        bb_sanitize_stdio();
        /* Equivalent of doing a fflush after every \n */
-- 
1.7.10.4

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to