add a config option to disable automatically setting the dhcp hostname

This commit is contained in:
Ariadne Conill 2020-10-14 05:15:58 -06:00
parent a210cf6a66
commit 4aa2749737
4 changed files with 13 additions and 0 deletions

View file

@ -24,3 +24,10 @@ allow_any_iface_as_template = 1
# work against non-template interfaces without converting them to a # work against non-template interfaces without converting them to a
# template. Valid values are 0 and 1, the default is 1. # template. Valid values are 0 and 1, the default is 1.
implicit_template_conversion = 1 implicit_template_conversion = 1
# use_hostname_for_dhcp:
# Automatically learn the hostname property, used for DHCP configuration
# by querying the system hostname using uname(2). This is basically
# equivalent to `hostname $(hostname)` without having to specify any
# configuration. Valid values are 0 and 1, the default is 1.
use_hostname_for_dhcp = 1

View file

@ -22,6 +22,7 @@ struct lif_config_file lif_config = {
.allow_addon_scripts = true, .allow_addon_scripts = true,
.allow_any_iface_as_template = true, .allow_any_iface_as_template = true,
.implicit_template_conversion = true, .implicit_template_conversion = true,
.use_hostname_for_dhcp = true,
}; };
static bool static bool
@ -47,6 +48,7 @@ static struct lif_config_handler handlers[] = {
{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts}, {"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts},
{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template}, {"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template},
{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion}, {"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion},
{"use_hostname_for_dhcp", set_bool_value, &lif_config.use_hostname_for_dhcp},
}; };
bool bool

View file

@ -22,6 +22,7 @@ struct lif_config_file {
bool allow_addon_scripts; bool allow_addon_scripts;
bool allow_any_iface_as_template; bool allow_any_iface_as_template;
bool implicit_template_conversion; bool implicit_template_conversion;
bool use_hostname_for_dhcp;
}; };
extern struct lif_config_file lif_config; extern struct lif_config_file lif_config;

View file

@ -123,6 +123,9 @@ lif_interface_init(struct lif_interface *interface, const char *ifname)
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 */ /* learn a reasonable default hostname */
struct utsname un; struct utsname un;
if (uname(&un) < 0) if (uname(&un) < 0)