summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-01-29 11:21:16 +0000
committerRoy Marples <roy@marples.name>2009-01-29 11:21:16 +0000
commited913a59775402a9ce66067858d7280fe4506176 (patch)
tree622bc27dd349878a48255b2102e881cedda64401
parentf2151f9eafc673071c14667f0f334c3288f74a65 (diff)
downloaddhcpcd-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.
-rw-r--r--dhcp.c4
-rw-r--r--dhcpcd.8.in5
-rw-r--r--dhcpcd.conf6
-rw-r--r--dhcpcd.conf.5.in5
-rw-r--r--if-options.c35
5 files changed, 27 insertions, 28 deletions
diff --git a/dhcp.c b/dhcp.c
index 264189bb..e53d27c8 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -892,7 +892,7 @@ make_message(struct dhcp_message **message,
* upto the first dot (the short hostname) as otherwise
* confuses some DHCP servers when updating DNS.
* The FQDN option should be used if a FQDN is required. */
- if (ifo->hostname[0]) {
+ if (ifo->options & DHCPCD_HOSTNAME && ifo->hostname[0]) {
*p++ = DHO_HOSTNAME;
hp = strchr(ifo->hostname, '.');
if (hp)
@@ -903,7 +903,7 @@ make_message(struct dhcp_message **message,
memcpy(p, ifo->hostname, len);
p += len;
}
- if (ifo->fqdn != FQDN_DISABLE) {
+ if (ifo->fqdn != FQDN_DISABLE && ifo->hostname[0]) {
/* IETF DHC-FQDN option (81), RFC4702 */
*p++ = DHO_FQDN;
lp = p;
diff --git a/dhcpcd.8.in b/dhcpcd.8.in
index a3a14907..635c0949 100644
--- a/dhcpcd.8.in
+++ b/dhcpcd.8.in
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 5, 2009
+.Dd January 28, 2009
.Dt DHCPCD 8 SMM
.Sh NAME
.Nm dhcpcd
@@ -349,9 +349,6 @@ hostname.
Valid values for
.Ar fqdn
are disable, none, ptr and both.
-The current hostname or the hostname specified using the
-.Fl h , -hostname
-option must be a FQDN.
.Nm
itself never does any DNS updates.
.Nm
diff --git a/dhcpcd.conf b/dhcpcd.conf
index cce1795c..78e55fcb 100644
--- a/dhcpcd.conf
+++ b/dhcpcd.conf
@@ -1,9 +1,11 @@
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
-# dhcpcd-run-hooks uses these options.
-option domain_name_servers, domain_name, domain_search, host_name
+# We normally want to inform the DHCP server of our hostname for DDNS.
+hostname
+# A list of options we should request from the DHCP server.
+option domain_name_servers, domain_name, domain_search, host_name
# Most distros have ntp support.
option ntp_servers
diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in
index 629a948a..e1976e3a 100644
--- a/dhcpcd.conf.5.in
+++ b/dhcpcd.conf.5.in
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 5, 2009
+.Dd January 28, 2009
.Dt DHCPCD.CONF 5 SMM
.Sh NAME
.Nm dhcpcd.conf
@@ -98,9 +98,6 @@ if a FQDN (ie, contains a .) then it will be encoded as such.
.It Ic fqdn Op none | ptr | both
none disables FQDN encoding, ptr just asks the DHCP server to update the PTR
record of the host in DNS whereas both also updates the A record.
-The current hostname or the hostname specified using the
-.Ic hostname
-option must be a FQDN.
.Nm dhcpcd
itself never does any DNS updates.
.Nm dhcpcd
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 */