diff -u dhcp3-3.0.3.orig/common/options.c dhcp3-3.0.3/common/options.c --- dhcp3-3.0.3.orig/common/options.c 2004-12-04 10:03:18.000000000 +1000 +++ dhcp3-3.0.3/common/options.c 2006-07-22 10:25:20.000000000 +1000 @@ -1100,6 +1100,7 @@ option -> format [i] != '.') i++; case 'X': + case 'h': for (k = 0; k < len; k++) { if (!isascii (data [k]) || !isprint (data [k])) diff -u dhcp3-3.0.3.orig/common/parse.c dhcp3-3.0.3/common/parse.c --- dhcp3-3.0.3.orig/common/parse.c 2005-03-04 02:55:23.000000000 +1000 +++ dhcp3-3.0.3/common/parse.c 2006-07-22 10:48:58.000000000 +1000 @@ -4299,6 +4299,20 @@ return 1; } +int make_possible_hostname(val) + char** val; +{ + static char localhostname[HOST_NAME_MAX]; + + if (!strcmp(*val, "")) { + if (gethostname (localhostname, HOST_NAME_MAX)) + return 0; + localhostname [HOST_NAME_MAX-1] = 0; + *val = localhostname; + } + return 1; +} + int parse_option_token (rv, cfile, fmt, expr, uniform, lookups) struct expression **rv; struct parse *cfile; @@ -4343,6 +4357,7 @@ return 0; } *fmt = g; + case 'h': case 'X': token = peek_token (&val, (unsigned *)0, cfile); if (token == NUMBER_OR_NAME || token == NUMBER) { @@ -4357,6 +4372,8 @@ token = next_token (&val, &len, cfile); if(token == STRING) { + if (**fmt == 'h' && !make_possible_hostname (&val)) + parse_warn (cfile, "gethostname() failed"); if (!make_const_data (&t, (const unsigned char *)val, len, 1, 1, MDL)) @@ -4570,6 +4587,7 @@ skip_to_semi (cfile); return 0; } + case 'h': case 'X': len = parse_X (cfile, &hunkbuf [hunkix], sizeof hunkbuf - hunkix); diff -u dhcp3-3.0.3.orig/common/tables.c dhcp3-3.0.3/common/tables.c --- dhcp3-3.0.3.orig/common/tables.c 2004-09-02 03:06:35.000000000 +1000 +++ dhcp3-3.0.3/common/tables.c 2006-07-22 10:19:04.000000000 +1000 @@ -81,6 +81,8 @@ quoted string. If not, it's output as colon-seperated hex. On input, the option can be specified either as a quoted string or as a colon-seperated hex list. + h - same as X, but if the ASCII string "", option is set + to the value returned by gethostname(2) N - enumeration. N is followed by a text string containing the name of the set of enumeration values to parse or emit, followed by a '.'. The width of the data is specified in the @@ -102,7 +104,7 @@ { "lpr-servers", "IA", &dhcp_universe, 9 }, { "impress-servers", "IA", &dhcp_universe, 10 }, { "resource-location-servers", "IA", &dhcp_universe, 11 }, - { "host-name", "X", &dhcp_universe, 12 }, + { "host-name", "h", &dhcp_universe, 12 }, { "boot-size", "S", &dhcp_universe, 13 }, { "merit-dump", "t", &dhcp_universe, 14 }, { "domain-name", "t", &dhcp_universe, 15 },