diff options
| author | Roy Marples <roy@marples.name> | 2009-01-29 11:21:16 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-01-29 11:21:16 +0000 |
| commit | ed913a59775402a9ce66067858d7280fe4506176 (patch) | |
| tree | 622bc27dd349878a48255b2102e881cedda64401 /if-options.c | |
| parent | f2151f9eafc673071c14667f0f334c3288f74a65 (diff) | |
| download | dhcpcd-ed913a59775402a9ce66067858d7280fe4506176.tar.xz | |
dhcpcd should not send hostname by default.
However, the default config file we ship enables the sending of the hostname
by default.
This makes things more explicit I think, and also allows the FQDN to be sent
but not the hostname if someone ever needs this.
Diffstat (limited to 'if-options.c')
| -rw-r--r-- | if-options.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/if-options.c b/if-options.c index e0090f2b..decc9604 100644 --- a/if-options.c +++ b/if-options.c @@ -312,20 +312,23 @@ parse_option(struct if_options *ifo, int opt, const char *arg) strlcpy(ifo->script, arg, sizeof(ifo->script)); break; case 'h': - if (arg) + if (arg) { s = parse_string(ifo->hostname, HOSTNAME_MAX_LEN, arg); - else - s = 0; - if (s == -1) { - syslog(LOG_ERR, "hostname: %m"); - return -1; - } - if (s != 0 && ifo->hostname[0] == '.') { - syslog(LOG_ERR, "hostname cannot begin with a ."); - return -1; + if (s == -1) { + syslog(LOG_ERR, "hostname: %m"); + return -1; + } + if (s != 0 && ifo->hostname[0] == '.') { + syslog(LOG_ERR, "hostname cannot begin with ."); + return -1; + } + ifo->hostname[s] = '\0'; } - ifo->hostname[s] = '\0'; + if (ifo->hostname[0] == '\0') + ifo->options &= ~DHCPCD_HOSTNAME; + else + ifo->options |= DHCPCD_HOSTNAME; break; case 'i': if (arg) @@ -676,16 +679,16 @@ read_config(const char *file, const char *ifname, const char *ssid) ifo->timeout = DEFAULT_TIMEOUT; ifo->reboot = DEFAULT_REBOOT; ifo->metric = -1; + strlcpy(ifo->script, SCRIPT, sizeof(ifo->script)); gethostname(ifo->hostname, HOSTNAME_MAX_LEN); /* Ensure that the hostname is NULL terminated */ ifo->hostname[HOSTNAME_MAX_LEN] = '\0'; if (strcmp(ifo->hostname, "(none)") == 0 || strcmp(ifo->hostname, "localhost") == 0) ifo->hostname[0] = '\0'; - strlcpy(ifo->script, SCRIPT, sizeof(ifo->script)); ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1, - VENDORCLASSID_MAX_LEN, - "%s %s", PACKAGE, VERSION); + VENDORCLASSID_MAX_LEN, + "%s %s", PACKAGE, VERSION); /* Parse our options file */ f = fopen(file ? file : CONFIG, "r"); @@ -698,8 +701,8 @@ read_config(const char *file, const char *ifname, const char *ssid) if (line && *line) { p = line + strlen(line) - 1; while (p != line && - (*p == ' ' || *p == '\t') && - *(p - 1) != '\\') + (*p == ' ' || *p == '\t') && + *(p - 1) != '\\') *p-- = '\0'; } /* Start of an interface block, skip if not ours */ |
