confd: add exception for hostname DHCP client option

No need to guard the hostname option in quotes, it must not contain
whitespace.  If user configured more than one word, use first.

Fixes #283

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-01-30 15:32:38 +01:00
committed by Tobias Waldekranz
parent 94dd57a741
commit 08cec2e9bc
2 changed files with 7 additions and 3 deletions
+3
View File
@@ -22,6 +22,7 @@ static const struct srx_module_requirement reqs[] = {
{ NULL }
};
static char *ip_cache(const char *ifname, char *str, size_t len)
{
const char *fn = "/var/lib/misc/%s.cache";
@@ -148,6 +149,8 @@ static char *compose_option(const char *ifname, const char *name, const char *va
} else {
if (!strcmp(name, "fqdn"))
fqdn(value, option, len);
else if (!strcmp(name, "hostname"))
snprintf(option, len, "-x %s:%s ", name, value);
else
snprintf(option, len, "-x %s:'\"%s\"' ", name, value);
}
@@ -133,9 +133,10 @@ module infix-dhcp-client {
leaf value {
type string;
description "Optional value, only used for non-flag request options.
Example: option:hostname, value:xyzzy
option:clientid, value:01:02:03:04:05:06:07:08:09:0a
option:0x51, value:xyzzy.example.com";
Example: option:hostname, value:xyzzy
option:clientid, value:01:02:03:04:05:06:07:08:09:0a
option:0x51, value:xyzzy.example.com";
must "../name != 'hostname' or re-match(., '[a-zA-Z0-9\\-_]{0,253}')";
}
}
leaf route-preference {