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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Dec 17 15:58:52 CET 2009


Author: mwiegand
Date: 2009-12-17 15:58:49 +0100 (Thu, 17 Dec 2009)
New Revision: 6175

Added:
   trunk/gsa/src/html/src/help/settings.htm4
Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_oap.c
   trunk/gsa/src/gsad_oap.h
   trunk/gsa/src/html/header.m4
   trunk/gsa/src/html/src/gsad.xsl
   trunk/gsa/src/html/src/help/contents.htm4
   trunk/gsa/src/html/src/oap.xsl
Log:
Added support for retrieving settings from the openvas-admininistrator.

* src/gsad.c (init_validator): Added get_settings to the list of
valid commands, fixed sorting of commands.
(exec_omp_get): Added handling of get_settings command.

* src/gsad_oap.c (get_settings_oap): New function to handle
get_settings.

* src/gsad_oap.h: Updated.

* src/html/src/oap.xsl: Added handling of get_settings_response.

* src/html/src/gsad.xsl: Added new menu item.

* src/html/src/help/contents.htm4: Added new list item.

* src/html/src/help/settings.htm4: New.

* src/html/header.m4: Added new menu item.


Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/ChangeLog	2009-12-17 14:58:49 UTC (rev 6175)
@@ -1,3 +1,26 @@
+2009-12-17  Michael Wiegand <michael.wiegand at greenbone.net>
+
+	Added support for retrieving settings from the openvas-admininistrator.
+
+	* src/gsad.c (init_validator): Added get_settings to the list of
+	valid commands, fixed sorting of commands.
+	(exec_omp_get): Added handling of get_settings command.
+
+	* src/gsad_oap.c (get_settings_oap): New function to handle
+	get_settings.
+
+	* src/gsad_oap.h: Updated.
+
+	* src/html/src/oap.xsl: Added handling of get_settings_response.
+
+	* src/html/src/gsad.xsl: Added new menu item.
+
+	* src/html/src/help/contents.htm4: Added new list item.
+
+	* src/html/src/help/settings.htm4: New.
+
+	* src/html/header.m4: Added new menu item.
+
 2009-12-17  Matthew Mundell <matthew.mundell at intevation.de>
 
 	Add sort buttons for task and status to the get_status page.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/gsad.c	2009-12-17 14:58:49 UTC (rev 6175)
@@ -178,18 +178,19 @@
                          "|(get_config_family)"
                          "|(get_config_nvt)"
                          "|(get_configs)"
+                         "|(get_feed)"
                          "|(get_lsc_credentials)"
                          "|(get_nvt_details)"
                          "|(get_report)"
+                         "|(get_settings)"
                          "|(get_status)"
                          "|(get_targets)"
                          "|(get_users)"
-                         "|(get_feed)"
-                         "|(sync_feed)"
                          "|(save_config)"
                          "|(save_config_family)"
                          "|(save_config_nvt)"
-                         "|(start_task)$");
+                         "|(start_task)"
+                         "|(sync_feed)$");
 
   openvas_validator_add (validator, "boolean",    "^0|1$");
   openvas_validator_add (validator, "comment",    "^[-_[:alnum:], \\./]{0,400}$");
@@ -1604,6 +1605,9 @@
       return get_nvt_details_omp (credentials, oid);
     }
 
+  else if (!strcmp (cmd, "get_settings"))
+    return get_settings_oap (credentials, sort_field, sort_order);
+
   else
     return gsad_message ("Internal error", __FUNCTION__, __LINE__,
                          "An internal error occured inside GSA daemon. "

Modified: trunk/gsa/src/gsad_oap.c
===================================================================
--- trunk/gsa/src/gsad_oap.c	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/gsad_oap.c	2009-12-17 14:58:49 UTC (rev 6175)
@@ -497,3 +497,71 @@
   return xsl_transform_oap (credentials, text);
 }
 
+/**
+ * @brief Get all settings and XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication
+ * @param[in]  sort_field   Field to sort on, or NULL.
+ * @param[in]  sort_order   "ascending", "descending", or NULL.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+get_settings_oap (credentials_t * credentials, const char * sort_field,
+                  const char * sort_order)
+{
+  tracef ("In get_settings_oap\n");
+  entity_t entity;
+  char *text = NULL;
+  gnutls_session_t session;
+  int socket;
+
+  switch (administrator_connect (credentials, &socket, &session))
+    {
+      case -1:
+        return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                             "An internal error occurred while getting the user list. "
+                             "The current list of settings is not available. "
+                             "Diagnostics: Failure to connect to administrator daemon.",
+                             "/omp?cmd=get_status");
+      case -2:
+        return xsl_transform_oap (credentials,
+                                  g_strdup
+                                   ("<gsad_msg status_text=\"Access refused.\""
+                                    " operation=\"List Configurations\">"
+                                    "Only users given the Administrator role"
+                                    " may access the settings list."
+                                    "</gsad_msg>"));
+    }
+
+  if (openvas_server_sendf (&session,
+                            "<commands>"
+                            "<get_settings/>"
+                            "</commands>")
+      == -1)
+    {
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while getting the user list. "
+                           "The current list of settings is not available. "
+                           "Diagnostics: Failure to send command to administrator daemon.",
+                           "/omp?cmd=get_status");
+    }
+
+  entity = NULL;
+  if (read_entity_and_text (&session, &entity, &text))
+    {
+      openvas_server_close (socket, session);
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while getting the user list. "
+                           "The current list of settings is not available. "
+                           "Diagnostics: Failure to receive response from administrator daemon.",
+                           "/omp?cmd=get_status");
+    }
+  free_entity (entity);
+
+  openvas_server_close (socket, session);
+  tracef ("get_settings_oap: got text: %s", text);
+  fflush (stderr);
+  return xsl_transform_oap (credentials, text);
+}
+

Modified: trunk/gsa/src/gsad_oap.h
===================================================================
--- trunk/gsa/src/gsad_oap.h	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/gsad_oap.h	2009-12-17 14:58:49 UTC (rev 6175)
@@ -43,5 +43,6 @@
 char * delete_user_oap (credentials_t *, const char *);
 char * get_feed_oap (credentials_t *, const char *, const char *);
 char * sync_feed_oap (credentials_t *);
+char * get_settings_oap (credentials_t *, const char *, const char *);
 
 #endif /* not _GSAD_OAP_H */

Modified: trunk/gsa/src/html/header.m4
===================================================================
--- trunk/gsa/src/html/header.m4	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/html/header.m4	2009-12-17 14:58:49 UTC (rev 6175)
@@ -52,6 +52,7 @@
       <ul>
         <li><a href="/omp?cmd=get_users">Users</a></li>
         <li><a href="/omp?cmd=get_feed">NVT Feed</a></li>
+        <li><a href="/omp?cmd=get_settings">Settings</a></li>
       </ul>
       </li>
       <li>Help

Modified: trunk/gsa/src/html/src/gsad.xsl
===================================================================
--- trunk/gsa/src/html/src/gsad.xsl	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/html/src/gsad.xsl	2009-12-17 14:58:49 UTC (rev 6175)
@@ -106,6 +106,7 @@
             <ul>
               <li><a href="/oap?cmd=get_users">Users</a></li>
               <li><a href="/oap?cmd=get_feed">NVT Feed</a></li>
+              <li><a href="/oap?cmd=get_settings">Settings</a></li>
             </ul>
           </li>
           <li>

Modified: trunk/gsa/src/html/src/help/contents.htm4
===================================================================
--- trunk/gsa/src/html/src/help/contents.htm4	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/html/src/help/contents.htm4	2009-12-17 14:58:49 UTC (rev 6175)
@@ -29,6 +29,7 @@
   <ul>
   <li> <a href="configure_users.html">Configure Users</a></li>
   <li> <a href="feed_management.html">NVT Feed Management</a></li>
+  <li> <a href="settings.html">Settings</a></li>
   </ul>
 <li> Miscellaneous</li>
   <ul>

Added: trunk/gsa/src/html/src/help/settings.htm4
===================================================================
--- trunk/gsa/src/html/src/help/settings.htm4	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/html/src/help/settings.htm4	2009-12-17 14:58:49 UTC (rev 6175)
@@ -0,0 +1,19 @@
+m4_define(`PAGE_TITLE', `Help: NVT Feed Management')
+m4_include(`header.m4')
+
+<div style="float:left;"><a href="/help/contents.html">Help Contents</a></div>
+<div style="float:right;"><a href="/omp?cmd=get_settings">Jump to dialog</a></div>
+&nbsp;<br />
+
+<h1>Settings</h1>
+
+<p>
+The management of settings is only accessible for users that own the
+"Administrator" role.
+</p>
+
+<p>
+This dialog allows you to view the current settings of your installation.
+</p>
+
+m4_include(`footer.m4')

Modified: trunk/gsa/src/html/src/oap.xsl
===================================================================
--- trunk/gsa/src/html/src/oap.xsl	2009-12-17 14:47:38 UTC (rev 6174)
+++ trunk/gsa/src/html/src/oap.xsl	2009-12-17 14:58:49 UTC (rev 6175)
@@ -251,4 +251,62 @@
 
 <!-- END FEED MANAGEMENT -->
 
+<!-- BEGIN SETTINGS MANAGEMENT -->
+
+<xsl:template name="html-settings-table">
+  <xsl:apply-templates select="scanner_settings"/>
+</xsl:template>
+
+<!--     SCANNER_SETTINGS -->
+
+<xsl:template match="scanner_settings">
+  <div class="gb_window">
+    <div class="gb_window_part_left"></div>
+    <div class="gb_window_part_right"></div>
+    <div class="gb_window_part_center">Scanner Settings
+      <a href="/help/settings.html"
+         title="Help: Settings">
+        <img src="/img/help.png"/>
+      </a>
+    </div>
+    <div class="gb_window_part_content_no_pad">
+      <div>From file: <xsl:value-of select="@sourcefile"/></div>
+      <div id="settings">
+        <table class="gbntable" cellspacing="2" cellpadding="4" border="0">
+          <tr class="gbntablehead2">
+            <td>Setting</td>
+            <td>Value</td>
+          </tr>
+          <xsl:apply-templates select="setting"/>
+        </table>
+      </div>
+    </div>
+  </div>
+</xsl:template>
+
+<!--     SETTING -->
+
+<xsl:template match="setting">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="position() mod 2 = 0">even</xsl:when>
+      <xsl:otherwise>odd</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <tr class="{$class}">
+    <td>
+      <b><xsl:value-of select="@name"/></b>
+    </td>
+    <td><xsl:value-of select="text()"/></td>
+  </tr>
+</xsl:template>
+
+<!--     GET_SETTINGS_RESPONSE -->
+
+<xsl:template match="get_settings_response">
+  <xsl:call-template name="html-settings-table"/>
+</xsl:template>
+
+<!-- END SETTINGS MANAGEMENT -->
+
 </xsl:stylesheet>



More information about the Openvas-commits mailing list