dhcp: make default dhcp plugin configurable at compile-time

This commit is contained in:
Thomas Haller 2016-10-14 11:00:16 +02:00
parent d298b7c96d
commit e9bf87805c
4 changed files with 26 additions and 5 deletions

View file

@ -808,6 +808,16 @@ else
AC_DEFINE(WITH_DHCPCD, 0, [Define if you have dhcpcd])
fi
AC_ARG_WITH(config-dhcp-default, AS_HELP_STRING([--with-config-dhcp-default=dhclient|dhcpcd|internal], [Default configuration option for main.dhcp setting, used as fallback if the configuration option is unset]), [config_dhcp_default="$withval"], [config_dhcp_default=""])
if test "$config_dhcp_default" = yes -o "$config_dhcp_default" = no; then
config_dhcp_default=''
fi
test -z "$config_dhcp_default" -a "$with_dhclient" != "no" && config_dhcp_default='dhclient'
test -z "$config_dhcp_default" -a "$with_dhcpcd" != "no" && config_dhcp_default='dhcpcd'
test -z "$config_dhcp_default" && config_dhcp_default='internal'
AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_DHCP, "$config_dhcp_default", [Default configuration option for main.dhcp setting])
AC_SUBST(NM_CONFIG_DEFAULT_DHCP, $config_dhcp_default)
# resolvconf and netconfig support
AC_ARG_WITH(resolvconf, AS_HELP_STRING([--with-resolvconf=yes|no|path], [Enable resolvconf support]))
AC_ARG_WITH(netconfig, AS_HELP_STRING([--with-netconfig=yes|no], [Enable SUSE netconfig support]))
@ -1213,7 +1223,7 @@ echo " netconfig: ${with_netconfig}"
echo " config-dns-rc-manager-default: ${config_dns_rc_manager_default}"
echo
echo "DHCP clients:"
echo "DHCP clients (default $config_dhcp_default):"
echo " dhclient: $with_dhclient"
echo " dhcpcd: $with_dhcpcd"
echo " dhcpcd-supports-ipv6: $with_dhcpcd_supports_ipv6"

View file

@ -189,9 +189,9 @@ plugins-=remove-me
clients to be installed. The <literal>internal</literal>
option uses a built-in DHCP client which is not currently as
featureful as the external clients.</para>
<para>If this key is missing, available DHCP clients are
looked for in this order: <literal>dhclient</literal>,
<literal>dhcpcd</literal>,
<para>If this key is missing, it defaults to <literal>&NM_CONFIG_DEFAULT_DHCP;</literal>.
It the chosen plugin is not available, clients are looked for
in this order: <literal>dhclient</literal>, <literal>dhcpcd</literal>,
<literal>internal</literal>.</para></listitem>
</varlistentry>
<varlistentry>

View file

@ -5,3 +5,4 @@
<!ENTITY NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT "@NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@">
<!ENTITY NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT "@NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@">
<!ENTITY NM_CONFIG_DEFAULT_DNS_RC_MANAGER "@NM_CONFIG_DEFAULT_DNS_RC_MANAGER@">
<!ENTITY NM_CONFIG_DEFAULT_DHCP "@NM_CONFIG_DEFAULT_DHCP@">

View file

@ -349,13 +349,23 @@ nm_dhcp_manager_init (NMDhcpManager *self)
if (nm_config_get_configure_and_quit (config)) {
client_factory = &_nm_dhcp_client_factory_internal;
if (client && !nm_streq (client, client_factory->name))
nm_log_warn (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set.");
nm_log_info (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set.");
} else {
if (client) {
client_factory = _client_factory_available (_client_factory_find_by_name (client));
if (!client_factory)
nm_log_warn (LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client);
}
if (!client_factory) {
client_factory = _client_factory_find_by_name (""NM_CONFIG_DEFAULT_DHCP);
if (!client_factory)
nm_log_err (LOGD_DHCP, "dhcp-init: default DHCP client '%s' is not installed", NM_CONFIG_DEFAULT_DHCP);
else {
client_factory = _client_factory_available (client_factory);
if (!client_factory)
nm_log_info (LOGD_DHCP, "dhcp-init: default DHCP client '%s' is not available", NM_CONFIG_DEFAULT_DHCP);
}
}
if (!client_factory) {
for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) {
client_factory = _client_factory_available (_nm_dhcp_manager_factories[i]);