diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index 26f3b2cb9b..06f2b51227 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -410,12 +410,10 @@ dispatch_netconfig (NMDnsManager *self, return SR_SUCCESS; } -static gboolean -write_resolv_conf (FILE *f, - char **searches, - char **nameservers, - char **options, - GError **error) +static char * +create_resolv_conf (char **searches, + char **nameservers, + char **options) { gs_free char *searches_str = NULL; gs_free char *nameservers_str = NULL; @@ -443,9 +441,9 @@ write_resolv_conf (FILE *f, for (i = 0; i < num; i++) { if (i == 3) { g_string_append (str, "# "); - g_string_append (str, _("NOTE: the libc resolver may not support more than 3 nameservers.")); + g_string_append (str, "NOTE: the libc resolver may not support more than 3 nameservers."); g_string_append (str, "\n# "); - g_string_append (str, _("The nameservers listed below may not be recognized.")); + g_string_append (str, "The nameservers listed below may not be recognized."); g_string_append_c (str, '\n'); } @@ -456,10 +454,23 @@ write_resolv_conf (FILE *f, nameservers_str = g_string_free (str, FALSE); } - if (fprintf (f, "# Generated by NetworkManager\n%s%s%s", - searches_str ? searches_str : "", - nameservers_str ? nameservers_str : "", - options_str ? options_str : "") < 0) { + return g_strdup_printf ("# Generated by NetworkManager\n%s%s%s", + searches_str ?: "", + nameservers_str ?: "", + options_str ?: ""); +} + +static gboolean +write_resolv_conf (FILE *f, + char **searches, + char **nameservers, + char **options, + GError **error) +{ + gs_free char *content = NULL; + + content = create_resolv_conf (searches, nameservers, options); + if (fprintf (f, "%s", content) < 0) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,