mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 20:30:08 +01:00
dns: return error reason from nm_dns_plugin_update()
For logging, if the plugin fails with update, it should return a reason that we can log. Note that both dnsmasq and system-resolved plugins do the update asynchronously (of course). Hence, usually they never fail right away, and there isn't really possibility to handle the failure later. Still, we should print something sensible for that we need information what went wrong.
This commit is contained in:
parent
807fd682fb
commit
2223fcd92c
6 changed files with 33 additions and 12 deletions
|
|
@ -365,7 +365,8 @@ static gboolean
|
|||
update (NMDnsPlugin *plugin,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const CList *ip_config_lst_head,
|
||||
const char *hostname)
|
||||
const char *hostname,
|
||||
GError **error)
|
||||
{
|
||||
NMDnsDnsmasq *self = NM_DNS_DNSMASQ (plugin);
|
||||
NMDnsDnsmasqPrivate *priv = NM_DNS_DNSMASQ_GET_PRIVATE (self);
|
||||
|
|
|
|||
|
|
@ -1428,13 +1428,15 @@ update_dns (NMDnsManager *self,
|
|||
nm_dns_plugin_update (priv->sd_resolve_plugin,
|
||||
global_config,
|
||||
_ip_config_lst_head (self),
|
||||
priv->hostname);
|
||||
priv->hostname,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* Let any plugins do their thing first */
|
||||
if (priv->plugin) {
|
||||
NMDnsPlugin *plugin = priv->plugin;
|
||||
const char *plugin_name = nm_dns_plugin_get_name (plugin);
|
||||
gs_free_error GError *plugin_error = NULL;
|
||||
|
||||
if (nm_dns_plugin_is_caching (plugin)) {
|
||||
if (no_caching) {
|
||||
|
|
@ -1449,8 +1451,9 @@ update_dns (NMDnsManager *self,
|
|||
if (!nm_dns_plugin_update (plugin,
|
||||
global_config,
|
||||
_ip_config_lst_head (self),
|
||||
priv->hostname)) {
|
||||
_LOGW ("update-dns: plugin %s update failed", plugin_name);
|
||||
priv->hostname,
|
||||
&plugin_error)) {
|
||||
_LOGW ("update-dns: plugin %s update failed: %s", plugin_name, plugin_error->message);
|
||||
|
||||
/* If the plugin failed to update, we shouldn't write out a local
|
||||
* caching DNS configuration to resolv.conf.
|
||||
|
|
|
|||
|
|
@ -64,14 +64,16 @@ gboolean
|
|||
nm_dns_plugin_update (NMDnsPlugin *self,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const CList *ip_config_lst_head,
|
||||
const char *hostname)
|
||||
const char *hostname,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE);
|
||||
|
||||
return NM_DNS_PLUGIN_GET_CLASS (self)->update (self,
|
||||
global_config,
|
||||
ip_config_lst_head,
|
||||
hostname);
|
||||
hostname,
|
||||
error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ typedef struct {
|
|||
gboolean (*update) (NMDnsPlugin *self,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const CList *ip_config_lst_head,
|
||||
const char *hostname);
|
||||
const char *hostname,
|
||||
GError **error);
|
||||
|
||||
const char *plugin_name;
|
||||
|
||||
|
|
@ -64,7 +65,8 @@ const char *nm_dns_plugin_get_name (NMDnsPlugin *self);
|
|||
gboolean nm_dns_plugin_update (NMDnsPlugin *self,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const CList *ip_config_lst_head,
|
||||
const char *hostname);
|
||||
const char *hostname,
|
||||
GError **error);
|
||||
|
||||
void nm_dns_plugin_stop (NMDnsPlugin *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -338,7 +338,8 @@ static gboolean
|
|||
update (NMDnsPlugin *plugin,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const CList *ip_config_lst_head,
|
||||
const char *hostname)
|
||||
const char *hostname,
|
||||
GError **error)
|
||||
{
|
||||
NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin);
|
||||
gs_unref_hashtable GHashTable *interfaces = NULL;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@ static gboolean
|
|||
update (NMDnsPlugin *plugin,
|
||||
const NMGlobalDnsConfig *global_config,
|
||||
const CList *ip_config_lst_head,
|
||||
const char *hostname)
|
||||
const char *hostname,
|
||||
GError **error)
|
||||
{
|
||||
char *argv[] = { DNSSEC_TRIGGER_PATH, "--async", "--update", NULL };
|
||||
gs_free_error GError *local = NULL;
|
||||
int status;
|
||||
|
||||
/* TODO: We currently call a script installed with the dnssec-trigger
|
||||
|
|
@ -41,9 +43,19 @@ update (NMDnsPlugin *plugin,
|
|||
* without calling custom scripts. The dnssec-trigger functionality
|
||||
* may be eventually merged into NetworkManager.
|
||||
*/
|
||||
if (!g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &status, NULL))
|
||||
if (!g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &status, &local)) {
|
||||
nm_utils_error_set (error, NM_UTILS_ERROR_UNKNOWN,
|
||||
"error spawning dns-trigger: %s",
|
||||
local->message);
|
||||
return FALSE;
|
||||
return (status == 0);
|
||||
}
|
||||
if (status != 0) {
|
||||
nm_utils_error_set (error, NM_UTILS_ERROR_UNKNOWN,
|
||||
"dns-trigger exited with error code %d",
|
||||
status);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue