mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-24 11:44:48 +00:00
dns: add configure option "--with-config-dns-rc-manager-default" for default of main.rc-manager
Downstream might want to choose a different default value for main.rc-manager setting (and it can does so, by compiling with explicit resolvconf or netconfig support). Make the default configurable at build-time and also embed it into the manual page of "NetworkManager.conf". https://bugzilla.redhat.com/show_bug.cgi?id=1337222
This commit is contained in:
parent
f664c04973
commit
51791c4772
15
configure.ac
15
configure.ac
|
@ -779,6 +779,11 @@ fi
|
|||
# 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]))
|
||||
AC_ARG_WITH(config-dns-rc-manager-default, AS_HELP_STRING([--with-config-dns-rc-manager-default=symlink|file|netconfig|resolvconf], [Configure default value for main.rc-manager setting]), [config_dns_rc_manager_default=$withval])
|
||||
if test "$config_dns_rc_manager_default" != symlink -a "$config_dns_rc_manager_default" != file -a "$config_dns_rc_manager_default" != netconfig -a "$config_dns_rc_manager_default" != resolvconf; then
|
||||
AC_MSG_WARN([Unknown --with-config-dns-rc-manager-default=$config_dns_rc_manager_default setting.])
|
||||
config_dns_rc_manager_default=
|
||||
fi
|
||||
# Use netconfig by default on SUSE
|
||||
AS_IF([test -z "$with_netconfig"], AC_CHECK_FILE(/etc/SuSE-release, with_netconfig=yes))
|
||||
# Otherwise default to "no"
|
||||
|
@ -788,9 +793,16 @@ AS_IF([test -z "$with_netconfig"], with_netconfig=no)
|
|||
if test "$with_resolvconf" = "yes"; then
|
||||
AC_PATH_PROGS(with_resolvconf, resolvconf, no, /sbin:/usr/sbin:/usr/local/sbin)
|
||||
fi
|
||||
if test "$with_resolvconf" != "no"; then
|
||||
AS_IF([test -z "$config_dns_rc_manager_default"], config_dns_rc_manager_default=resolvconf)
|
||||
fi
|
||||
if test "$with_netconfig" = "yes"; then
|
||||
AC_PATH_PROGS(with_netconfig, netconfig, no, /sbin:/usr/sbin:/usr/local/sbin)
|
||||
fi
|
||||
if test "$with_netconfig" != "no"; then
|
||||
AS_IF([test -z "$config_dns_rc_manager_default"], config_dns_rc_manager_default=netconfig)
|
||||
fi
|
||||
AS_IF([test -z "$config_dns_rc_manager_default"], config_dns_rc_manager_default=symlink)
|
||||
# Define resolvconf and netconfig paths
|
||||
if test "$with_resolvconf" != "no"; then
|
||||
AC_DEFINE_UNQUOTED(RESOLVCONF_PATH, "$with_resolvconf", [Path to resolvconf])
|
||||
|
@ -798,6 +810,8 @@ fi
|
|||
if test "$with_netconfig" != "no"; then
|
||||
AC_DEFINE_UNQUOTED(NETCONFIG_PATH, "$with_netconfig", [Path to netconfig])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_DNS_RC_MANAGER, "$config_dns_rc_manager_default", [Default value for main.rc-manager setting (--with-config-dns-rc-manager-default)])
|
||||
AC_SUBST(NM_CONFIG_DEFAULT_DNS_RC_MANAGER, $config_dns_rc_manager_default)
|
||||
|
||||
# iptables path
|
||||
AC_ARG_WITH(iptables, AS_HELP_STRING([--with-iptables=/path/to/iptables], [path to iptables]))
|
||||
|
@ -1190,6 +1204,7 @@ echo
|
|||
echo "Handlers for /etc/resolv.conf:"
|
||||
echo " resolvconf: ${with_resolvconf}"
|
||||
echo " netconfig: ${with_netconfig}"
|
||||
echo " config-dns-rc-manager-default: ${config_dns_rc_manager_default}"
|
||||
echo
|
||||
|
||||
echo "DHCP clients:"
|
||||
|
|
|
@ -312,7 +312,9 @@ no-auto-default=*
|
|||
<term><varname>rc-manager</varname></term>
|
||||
<listitem><para>Set the <filename>resolv.conf</filename>
|
||||
management mode. The default value depends on how NetworkManager
|
||||
was built. Regardless of this setting, NetworkManager will
|
||||
was built, whereas this version of NetworkManager was build with
|
||||
a default of "<literal>&NM_CONFIG_DEFAULT_DNS_RC_MANAGER;</literal>".
|
||||
Regardless of this setting, NetworkManager will
|
||||
always write resolv.conf to its runtime state directory.</para>
|
||||
<para><literal>symlink</literal>: NetworkManager will symlink
|
||||
<filename>/etc/resolv.conf</filename> to its private
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
<!ENTITY NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT "@NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@">
|
||||
<!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@">
|
||||
|
|
|
@ -67,15 +67,11 @@ G_DEFINE_TYPE (NMDnsManager, nm_dns_manager, G_TYPE_OBJECT)
|
|||
|
||||
#define HASH_LEN 20
|
||||
|
||||
#ifdef RESOLVCONF_PATH
|
||||
#define RESOLVCONF_SELECTED
|
||||
#else
|
||||
#ifndef RESOLVCONF_PATH
|
||||
#define RESOLVCONF_PATH "/sbin/resolvconf"
|
||||
#endif
|
||||
|
||||
#ifdef NETCONFIG_PATH
|
||||
#define NETCONFIG_SELECTED
|
||||
#else
|
||||
#ifndef NETCONFIG_PATH
|
||||
#define NETCONFIG_PATH "/sbin/netconfig"
|
||||
#endif
|
||||
|
||||
|
@ -1482,41 +1478,6 @@ _clear_plugin (NMDnsManager *self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static NMDnsManagerResolvConfManager
|
||||
_get_resolv_conf_manager_default (void)
|
||||
{
|
||||
#if defined(RESOLVCONF_SELECTED)
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF;
|
||||
#elif defined(NETCONFIG_SELECTED)
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG;
|
||||
#else
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static NMDnsManagerResolvConfManager
|
||||
_get_resolv_conf_manager (NMConfig *config)
|
||||
{
|
||||
const char *man;
|
||||
|
||||
man = nm_config_data_get_rc_manager (nm_config_get_data (config));
|
||||
if (!man)
|
||||
return _get_resolv_conf_manager_default ();
|
||||
|
||||
if (NM_IN_STRSET (man, "symlink", "none"))
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK;
|
||||
if (nm_streq (man, "file"))
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE;
|
||||
if (nm_streq (man, "resolvconf"))
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF;
|
||||
if (nm_streq (man, "netconfig"))
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG;
|
||||
if (nm_streq (man, "unmanaged"))
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED;
|
||||
|
||||
return NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN;
|
||||
}
|
||||
|
||||
static bool
|
||||
_get_resconf_immutable (void)
|
||||
{
|
||||
|
@ -1549,11 +1510,33 @@ init_resolv_conf_mode (NMDnsManager *self)
|
|||
else if (_get_resconf_immutable ())
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE;
|
||||
else {
|
||||
rc_manager = _get_resolv_conf_manager (priv->config);
|
||||
const char *man;
|
||||
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN;
|
||||
man = nm_config_data_get_rc_manager (nm_config_get_data (priv->config));
|
||||
|
||||
again:
|
||||
if (!man) {
|
||||
/* nop */
|
||||
} else if (NM_IN_STRSET (man, "symlink", "none"))
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK;
|
||||
else if (nm_streq (man, "file"))
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE;
|
||||
else if (nm_streq (man, "resolvconf"))
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF;
|
||||
else if (nm_streq (man, "netconfig"))
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG;
|
||||
else if (nm_streq (man, "unmanaged"))
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED;
|
||||
|
||||
if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN) {
|
||||
_LOGW ("init: unknown resolv.conf manager '%s'",
|
||||
nm_config_data_get_rc_manager (nm_config_get_data (priv->config)));
|
||||
rc_manager = _get_resolv_conf_manager_default ();
|
||||
if (man) {
|
||||
_LOGW ("init: unknown resolv.conf manager \"%s\", fallback to \"%s\"",
|
||||
man, ""NM_CONFIG_DEFAULT_DNS_RC_MANAGER);
|
||||
}
|
||||
man = ""NM_CONFIG_DEFAULT_DNS_RC_MANAGER;
|
||||
rc_manager = NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue