diff options
author | Renato Botelho <renato@netgate.com> | 2016-01-25 08:56:15 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-01-25 08:56:15 -0200 |
commit | eb84e0723f3b4bc5e40024f66fe21c14b09e9ec4 (patch) | |
tree | fec6b99d018e13f1fccbe31478aaf29a28a55642 /lib/libstand/bootp.c | |
parent | c50df8e1b90c4f9b8bbffa592477c129854776ce (diff) | |
parent | 94b1bbbd44bd88b6db1c00d795cdf7675b3ae254 (diff) | |
download | FreeBSD-src-eb84e0723f3b4bc5e40024f66fe21c14b09e9ec4.zip FreeBSD-src-eb84e0723f3b4bc5e40024f66fe21c14b09e9ec4.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'lib/libstand/bootp.c')
-rw-r--r-- | lib/libstand/bootp.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/libstand/bootp.c b/lib/libstand/bootp.c index 904b3ba..1af7bd5 100644 --- a/lib/libstand/bootp.c +++ b/lib/libstand/bootp.c @@ -354,6 +354,7 @@ vend_rfc1048(cp, len) u_char *ep; int size; u_char tag; + const char *val; #ifdef BOOTP_DEBUG if (debug) @@ -380,15 +381,17 @@ vend_rfc1048(cp, len) } if (tag == TAG_SWAPSERVER) { /* let it override bp_siaddr */ - bcopy(cp, &rootip.s_addr, sizeof(swapip.s_addr)); + bcopy(cp, &rootip.s_addr, sizeof(rootip.s_addr)); } if (tag == TAG_ROOTPATH) { - strncpy(rootpath, (char *)cp, sizeof(rootpath)); - rootpath[size] = '\0'; + if ((val = getenv("dhcp.root-path")) == NULL) + val = (const char *)cp; + strlcpy(rootpath, val, sizeof(rootpath)); } if (tag == TAG_HOSTNAME) { - strncpy(hostname, (char *)cp, sizeof(hostname)); - hostname[size] = '\0'; + if ((val = getenv("dhcp.host-name")) == NULL) + val = (const char *)cp; + strlcpy(hostname, val, sizeof(hostname)); } #ifdef SUPPORT_DHCP if (tag == TAG_DHCP_MSGTYPE) { @@ -730,7 +733,11 @@ setenv_(u_char *cp, u_char *ep, struct dhcp_opt *opts) sprintf(env, op->desc, opts[0].desc, tag); else sprintf(env, "%s%s", opts[0].desc, op->desc); - setenv(env, buf, 1); + /* + * Do not replace existing values in the environment, so that + * locally-obtained values can override server-provided values. + */ + setenv(env, buf, 0); } } if (tp != tags) { |