[Openvas-commits] r5434 - in trunk/openvas-client: . openvas/prefs_dialog

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 7 17:28:01 CEST 2009


Author: mattm
Date: 2009-10-07 17:28:00 +0200 (Wed, 07 Oct 2009)
New Revision: 5434

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/openvas/prefs_dialog/prefs_scope_tree.c
Log:
	* openvas/prefs_dialog/prefs_scope_tree.c [USE_OMP] (create_omp_scope):
	Ensure RC contains correct name.  Free strings used to set ID in RC.

Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-10-07 14:00:26 UTC (rev 5433)
+++ trunk/openvas-client/ChangeLog	2009-10-07 15:28:00 UTC (rev 5434)
@@ -1,5 +1,10 @@
 2009-10-07  Matthew Mundell <matthew.mundell at intevation.de>
 
+	* openvas/prefs_dialog/prefs_scope_tree.c [USE_OMP] (create_omp_scope):
+	Ensure RC contains correct name.  Free strings used to set ID in RC.
+
+2009-10-07  Matthew Mundell <matthew.mundell at intevation.de>
+
 	* openvas/prefs_dialog/prefs_dialog_auth.c (prefs_dialog_auth_do_connect):
 	Add const to return and err.
 	(prefs_dialog_auth_connect_dialog): Add const to err.

Modified: trunk/openvas-client/openvas/prefs_dialog/prefs_scope_tree.c
===================================================================
--- trunk/openvas-client/openvas/prefs_dialog/prefs_scope_tree.c	2009-10-07 14:00:26 UTC (rev 5433)
+++ trunk/openvas-client/openvas/prefs_dialog/prefs_scope_tree.c	2009-10-07 15:28:00 UTC (rev 5434)
@@ -983,8 +983,62 @@
           return -3;
         }
 
-      // FIX ensure name is set in openvasrc?
+      /* Hack to ensure name in openvasrc. */
 
+      pref = rc_preference (rcfile, "name");
+      if (pref && (strcmp (pref, name) == 0))
+        g_free (pref);
+      else
+        {
+          char *pos;
+          gchar *rc;
+          gsize rc_len;
+          GString *string;
+          GError *error;
+
+          error = NULL;
+          g_file_get_contents (file_name, &rc, &rc_len, &error);
+          if (error)
+            {
+              show_error (_("%s: g_file_get_contents"), __FUNCTION__);
+              // FIX note error
+              g_error_free (error);
+              g_free (file_name);
+              return -4;
+            }
+
+          pos = strchr (rc, '\n');
+          if (pos)
+            {
+              *pos = '\0';
+              string = g_string_new (rc);
+              /* The first \n ensures that "name" begins a line. */
+              g_string_append_printf (string, "\nname = %s\n", name);
+              g_string_append (string, pos + 1);
+            }
+          else
+            {
+              string = g_string_new (rc);
+              /* The first \n ensures that "name" begins a line. */
+              g_string_append_printf (string, "\nname = %s\n", name);
+            }
+
+          g_free (rc);
+          rc = g_string_free (string, FALSE);
+
+          error = NULL;
+          g_file_set_contents (file_name, (gchar*) rc, strlen (rc), &error);
+          g_free (rc);
+          if (error)
+            {
+              show_error (_("%s: g_file_get_contents"), __FUNCTION__);
+              // FIX note error
+              g_error_free (error);
+              g_free (file_name);
+              return -5;
+            }
+        }
+
       /* Hack to ensure ID in openvasrc. */
 
       pref = rc_preference (rcfile, "id");
@@ -993,7 +1047,7 @@
       else
         {
           char *pos;
-          gchar *rc, *rc2;
+          gchar *rc;
           gsize rc_len;
           GString *string;
           GError *error;
@@ -1025,10 +1079,12 @@
               g_string_append_printf (string, "\nid = %s\n", id);
             }
 
-          rc2 = g_string_free (string, FALSE);
+          g_free (rc);
+          rc = g_string_free (string, FALSE);
 
           error = NULL;
-          g_file_set_contents (file_name, (gchar*) rc2, strlen (rc2), &error);
+          g_file_set_contents (file_name, (gchar*) rc, strlen (rc), &error);
+          g_free (rc);
           if (error)
             {
               show_error (_("%s: g_file_get_contents"), __FUNCTION__);



More information about the Openvas-commits mailing list