[Openvas-commits] r11580 - in trunk/gsa: . src src/html

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 7 09:00:35 CEST 2011


Author: mattm
Date: 2011-09-07 09:00:34 +0200 (Wed, 07 Sep 2011)
New Revision: 11580

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/html/omp.xsl
Log:
	* src/gsad_omp.c (check_modify_config): Add name error case.
	(save_config_omp): Pass name and comment to Manager.

	* src/html/omp.xsl (html-config-table): Add name and comment editing.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-07 06:58:04 UTC (rev 11579)
+++ trunk/gsa/ChangeLog	2011-09-07 07:00:34 UTC (rev 11580)
@@ -1,3 +1,10 @@
+2011-09-07  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	* src/gsad_omp.c (check_modify_config): Add name error case.
+	(save_config_omp): Pass name and comment to Manager.
+
+	* src/html/omp.xsl (html-config-table): Add name and comment editing.
+
 2011-09-06  Matthew Mundell <matthew.mundell at greenbone.net>
 
 	* src/html/omp.xsl (host): Correct help link.

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-07 06:58:04 UTC (rev 11579)
+++ trunk/gsa/src/gsad_omp.c	2011-09-07 07:00:34 UTC (rev 11580)
@@ -282,6 +282,16 @@
                          " so modification of the config is forbidden."
                          "</gsad_msg>"));
     }
+  else if (strcmp (status_text, "MODIFY_CONFIG name must be unique") == 0)
+    {
+      free_entity (entity);
+      return xsl_transform_omp
+              (credentials,
+               g_strdup ("<gsad_msg status_text=\"Config name must be unique\""
+                         " operation=\"Save Config\">"
+                         "A config with the given name exists already."
+                         "</gsad_msg>"));
+    }
   else if (strcmp (status_text, "OK"))
     {
       free_entity (entity);
@@ -5876,7 +5886,19 @@
   gchar *html;
   const char *next;
   params_t *preferences, *selects, *trends;
+  const char *config_id, *name, *comment;
 
+  config_id = params_value (params, "config_id");
+  name = params_value (params, "name");
+  comment = params_value (params, "comment");
+
+  if ((config_id == NULL) || (name == NULL) || (comment == NULL))
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while saving a config. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_configs");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -5894,6 +5916,34 @@
                              "/omp?cmd=get_configs");
     }
 
+  /* Save name and comment. */
+
+  if (openvas_server_sendf_xml (&session,
+                                "<modify_config config_id=\"%s\">"
+                                "<name>%s</name>"
+                                "<comment>%s</comment>"
+                                "</modify_config>",
+                                params_value (params, "config_id"),
+                                name,
+                                comment)
+      == -1)
+    {
+      openvas_server_close (socket, session);
+      return gsad_message (credentials,
+                           "Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while saving a config. "
+                           "It is unclear whether the entire config has been saved. "
+                           "Diagnostics: Failure to send command to manager daemon.",
+                           "/omp?cmd=get_configs");
+    }
+
+  ret = check_modify_config (credentials, &session, __FUNCTION__, __LINE__);
+  if (ret)
+    {
+      openvas_server_close (socket, session);
+      return ret;
+    }
+
   /* Save preferences. */
 
   preferences = params_values (params, "preference:");

Modified: trunk/gsa/src/html/omp.xsl
===================================================================
--- trunk/gsa/src/html/omp.xsl	2011-09-07 06:58:04 UTC (rev 11579)
+++ trunk/gsa/src/html/omp.xsl	2011-09-07 07:00:34 UTC (rev 11580)
@@ -6424,16 +6424,6 @@
     </div>
     <br/>
 
-    <table>
-      <tr>
-        <td><b>Name:</b></td>
-        <td><b><xsl:value-of select="$config/name"/></b></td>
-      </tr>
-      <tr>
-        <td>Comment:</td><td><xsl:value-of select="$config/comment"/></td>
-      </tr>
-    </table>
-
     <xsl:choose>
       <xsl:when test="edit">
         <form action="" method="post">
@@ -6443,6 +6433,28 @@
           <input type="hidden" name="config_id" value="{$config/@id}"/>
           <input type="hidden" name="name" value="{$config/name}"/>
 
+          <table border="0" cellspacing="0" cellpadding="3" width="100%">
+            <tr>
+              <td valign="top" width="125">Name</td>
+              <td>
+                <input type="text" name="name" value="{$config/name}" size="30"
+                       maxlength="80"/>
+              </td>
+            </tr>
+            <tr>
+              <td valign="top">Comment (optional)</td>
+              <td>
+                <input type="text" name="comment" size="30" maxlength="400"
+                       value="{$config/comment}"/>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="2" style="text-align:right;">
+                <input type="submit" name="submit" value="Save Config"/>
+              </td>
+            </tr>
+          </table>
+
           <h1>Edit Network Vulnerability Test Families</h1>
 
           <xsl:call-template name="edit-families">
@@ -6478,6 +6490,16 @@
         </form>
       </xsl:when>
       <xsl:otherwise>
+        <table>
+          <tr>
+            <td><b>Name:</b></td>
+            <td><b><xsl:value-of select="$config/name"/></b></td>
+          </tr>
+          <tr>
+            <td>Comment:</td><td><xsl:value-of select="$config/comment"/></td>
+          </tr>
+        </table>
+
         <h1>Network Vulnerability Test Families</h1>
 
         <xsl:apply-templates select="$config" mode="families"/>



More information about the Openvas-commits mailing list