Commit 1c338861 authored by Thomas Haller's avatar Thomas Haller
Browse files

dns: make strv arguments of create_resolv_conf() const

parent a15756d9
......@@ -569,9 +569,9 @@ again:
}
static char *
create_resolv_conf (char **searches,
char **nameservers,
char **options)
create_resolv_conf (const char *const*searches,
const char *const*nameservers,
const char *const*options)
{
GString *str;
gsize i;
......@@ -636,9 +636,9 @@ write_resolv_conf_contents (FILE *f,
static gboolean
write_resolv_conf (FILE *f,
char **searches,
char **nameservers,
char **options,
const char *const*searches,
const char *const*nameservers,
const char *const*options,
GError **error)
{
gs_free char *content = NULL;
......@@ -700,7 +700,11 @@ dispatch_resolvconf (NMDnsManager *self,
return SR_ERROR;
}
success = write_resolv_conf (f, searches, nameservers, options, error);
success = write_resolv_conf (f,
NM_CAST_STRV_CC (searches),
NM_CAST_STRV_CC (nameservers),
NM_CAST_STRV_CC (options),
error);
err = pclose (f);
if (err < 0) {
errnosv = errno;
......@@ -741,9 +745,9 @@ _read_link_cached (const char *path, gboolean *is_cached, char **cached)
static void
update_resolv_conf_no_stub (NMDnsManager *self,
char **searches,
char **nameservers,
char **options)
const char *const*searches,
const char *const*nameservers,
const char *const*options)
{
gs_free char *content = NULL;
GError *local = NULL;
......@@ -766,9 +770,9 @@ update_resolv_conf_no_stub (NMDnsManager *self,
static SpawnResult
update_resolv_conf (NMDnsManager *self,
char **searches,
char **nameservers,
char **options,
const char *const*searches,
const char *const*nameservers,
const char *const*options,
GError **error,
NMDnsManagerResolvConfManager rc_manager)
{
......@@ -1431,7 +1435,10 @@ update_dns (NMDnsManager *self,
* guarantee they stay alive. */
clear_domain_lists (self);
update_resolv_conf_no_stub (self, searches, nameservers, options);
update_resolv_conf_no_stub (self,
NM_CAST_STRV_CC (searches),
NM_CAST_STRV_CC (nameservers),
NM_CAST_STRV_CC (options));
/* If caching was successful, we only send 127.0.0.1 to /etc/resolv.conf
* to ensure that the glibc resolver doesn't try to round-robin nameservers,
......@@ -1454,7 +1461,12 @@ update_dns (NMDnsManager *self,
switch (priv->rc_manager) {
case NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK:
case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE:
result = update_resolv_conf (self, searches, nameservers, options, error, priv->rc_manager);
result = update_resolv_conf (self,
NM_CAST_STRV_CC (searches),
NM_CAST_STRV_CC (nameservers),
NM_CAST_STRV_CC (options),
error,
priv->rc_manager);
resolv_conf_updated = TRUE;
/* If we have ended with no nameservers avoid updating again resolv.conf
* on stop, as some external changes may be applied to it in the meanwhile */
......@@ -1479,15 +1491,26 @@ update_dns (NMDnsManager *self,
if (result == SR_NOTFOUND) {
_LOGD ("update-dns: program not available, writing to resolv.conf");
g_clear_error (error);
result = update_resolv_conf (self, searches, nameservers, options, error, NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK);
result = update_resolv_conf (self,
NM_CAST_STRV_CC (searches),
NM_CAST_STRV_CC (nameservers),
NM_CAST_STRV_CC (options),
error,
NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK);
resolv_conf_updated = TRUE;
}
}
/* Unless we've already done it, update private resolv.conf in NMRUNDIR
ignoring any errors */
if (!resolv_conf_updated)
update_resolv_conf (self, searches, nameservers, options, NULL, NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED);
if (!resolv_conf_updated) {
update_resolv_conf (self,
NM_CAST_STRV_CC (searches),
NM_CAST_STRV_CC (nameservers),
NM_CAST_STRV_CC (options),
NULL,
NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED);
}
/* signal that resolv.conf was changed */
if (update && result == SR_SUCCESS)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment