+Send the hostname by default unless null, (none) or localhost.
+This can be overridden by using a an empty option for -h (-h '').
+
dhcpcd-3.0.3
NIS setup (yp.conf / domainname) works again.
Send hostname/fqdn in DISCOVER and INFORM messages too.
if (dhcp->hostname)
strcpy (newhostname, dhcp->hostname);
- sethostname (newhostname, strlen (newhostname));
- logger (LOG_INFO, "setting hostname to `%s'", newhostname);
+ if (*newhostname)
+ {
+ logger (LOG_INFO, "setting hostname to `%s'", newhostname);
+ sethostname (newhostname, strlen (newhostname));
+ }
}
write_info (iface, dhcp);
*n_params = p - n_params - 1;
- if (options->hostname)
+ if (*options->hostname)
{
if (options->fqdn == FQDN_DISABLE)
{
.\" $Id$
.\"
-.TH dhcpcd 8 "30 November 2006" "dhcpcd 3.0"
+.TH dhcpcd 8 "06 December 2006" "dhcpcd 3.0"
.SH NAME
dhcpcd \- DHCP client daemon
field containing a specific string in the DHCP messages from clients.
When combined with the -F switch, specifies the string used for the
FQDN option field instead of the hostname option field.
+We send the current hostname by default. To send no hostname, use -h ''.
.TP
.BI \-i \ vendorClassID
Specifies the vendor class identifier string.
options.donis = true;
options.dontp = true;
options.dogateway = true;
+ gethostname (options.hostname, sizeof (options.hostname));
+ if (strcmp (options.hostname, "(none)") == 0 ||
+ strcmp (options.hostname, "localhost") == 0)
+ memset (options.hostname, 0, sizeof (options.hostname));
options.timeout = DEFAULT_TIMEOUT;
int doversion = 0;
exit (EXIT_FAILURE);
}
else
- options.hostname = optarg;
+ strcpy (options.hostname, optarg);
break;
case 'i':
if (strlen(optarg) > CLASS_ID_MAX_LEN)
argv[optind], IF_NAMESIZE);
exit (EXIT_FAILURE);
}
- options.interface = argv[optind];
+ strcpy (options.interface, argv[optind]);
}
else
{
#ifdef __linux__
#include <linux/limits.h>
#endif
+#include <net/if.h>
#include <netinet/in.h>
#include <limits.h>
#include <stdbool.h>
#define CLASS_ID_MAX_LEN 48
#define CLIENT_ID_MAX_LEN 48
-#define HOSTNAME_MAX_LEN 64
+#define HOSTNAME_MAX_LEN 255
#define USERCLASS_MAX_LEN 255
typedef struct options_t {
- char *interface;
- char *hostname;
+ char interface[IF_NAMESIZE];
+ char hostname[HOSTNAME_MAX_LEN];
int fqdn;
char classid[CLASS_ID_MAX_LEN];
char clientid[CLIENT_ID_MAX_LEN];