[PATCH 4/5] udhcpc: obtain hostname from OS by default
Andreas Oberritter
obi at opendreambox.org
Mon Apr 22 08:49:23 UTC 2013
Ping.
On 20.03.2013 15:31, Andreas Oberritter wrote:
> * Doesn't require the 'hostname' option in /etc/network/interfaces,
> and thus makes udhcpc behave like other clients.
>
> Signed-off-by: Andreas Oberritter <obi at opendreambox.org>
> ---
> 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 */
>
More information about the busybox
mailing list