Merge pull request #123 from ifupdown-ng/chore/narrow-dhcp-hostname-configuration

interface: learn hostname from uname(2) only if an interface requests…
This commit is contained in:
Ariadne Conill 2020-11-04 11:47:24 -07:00 committed by GitHub
commit 71d832cceb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,16 +122,6 @@ lif_interface_init(struct lif_interface *interface, const char *ifname)
/* keep the 'vlan' executor as a config hint for backwards compatibility */ /* keep the 'vlan' executor as a config hint for backwards compatibility */
if (strchr(ifname, '.') != NULL) if (strchr(ifname, '.') != NULL)
lif_interface_use_executor(interface, "vlan"); lif_interface_use_executor(interface, "vlan");
if (!lif_config.use_hostname_for_dhcp)
return;
/* learn a reasonable default hostname */
struct utsname un;
if (uname(&un) < 0)
return;
lif_dict_add(&interface->vars, "hostname", strdup(un.nodename));
} }
bool bool
@ -211,6 +201,16 @@ lif_interface_use_executor(struct lif_interface *interface, const char *executor
interface->is_bridge = true; interface->is_bridge = true;
else if (!strcmp(executor, "bond")) else if (!strcmp(executor, "bond"))
interface->is_bond = true; interface->is_bond = true;
if (strcmp(executor, "dhcp") || !lif_config.use_hostname_for_dhcp)
return;
/* learn a reasonable default hostname */
struct utsname un;
if (uname(&un) < 0)
return;
lif_dict_add(&interface->vars, "hostname", strdup(un.nodename));
} }
void void