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;
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');
}
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,