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:
commit
71d832cceb
1 changed files with 10 additions and 10 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue