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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 16 13:49:07 CET 2009


Author: mattm
Date: 2009-12-16 13:49:06 +0100 (Wed, 16 Dec 2009)
New Revision: 6148

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/gsad_omp.h
   trunk/gsa/src/html/src/omp.xsl
Log:
	Separate credential name from credential login name.

	* src/gsad.c (init_validator): Add credential_login.
	(struct gsad_connection_info): Add req_parms.credential_login.
	(free_resources): Free credential login.
	(serve_post): Check for credential_login key.
	(exec_omp_post): In create_lsc_credential case pass credential_login to
	create_lsc_credential_omp.

	* src/gsad_omp.c (create_lsc_credential_omp): Add login arg.  Send to
	manager as login entity.

	* src/gsad_omp.c: Update header.

	* src/html/src/omp.xsl (html-create-lsc-credential-form): Add Login field.
	(html-lsc-credentials-table): Add Login heading.
	(lsc_credential): Add Login column.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-12-16 12:38:32 UTC (rev 6147)
+++ trunk/gsa/ChangeLog	2009-12-16 12:49:06 UTC (rev 6148)
@@ -1,3 +1,23 @@
+2009-12-16  Matthew Mundell <matthew.mundell at intevation.de>
+
+	Separate credential name from credential login name.
+
+	* src/gsad.c (init_validator): Add credential_login.
+	(struct gsad_connection_info): Add req_parms.credential_login.
+	(free_resources): Free credential login.
+	(serve_post): Check for credential_login key.
+	(exec_omp_post): In create_lsc_credential case pass credential_login to
+	create_lsc_credential_omp.
+
+	* src/gsad_omp.c (create_lsc_credential_omp): Add login arg.  Send to
+	manager as login entity.
+
+	* src/gsad_omp.c: Update header.
+
+	* src/html/src/omp.xsl (html-create-lsc-credential-form): Add Login field.
+	(html-lsc-credentials-table): Add Login heading.
+	(lsc_credential): Add Login column.
+
 2009-12-15  Matthew Mundell <matthew.mundell at intevation.de>
 
 	* src/gsad.c: Order authors alphabetically by surname.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-12-16 12:38:32 UTC (rev 6147)
+++ trunk/gsa/src/gsad.c	2009-12-16 12:49:06 UTC (rev 6148)
@@ -194,6 +194,7 @@
   openvas_validator_add (validator, "boolean",    "^0|1$");
   openvas_validator_add (validator, "comment",    "^[-_[:alnum:], \\./]{0,400}$");
   openvas_validator_add (validator, "create_credentials_type", "^(gen|pass)$");
+  openvas_validator_add (validator, "credential_login", "^[[:alnum:]]{1,10}$");
   openvas_validator_add (validator, "family",     "^[-_[:alnum:] :]{1,200}$");
   openvas_validator_add (validator, "first_result", "^[0-9]+$");
   openvas_validator_add (validator, "format",     "^(html)|(nbe)|(pdf)|(xml)$");
@@ -254,6 +255,7 @@
     char *cmd;           ///< Value of "cmd" parameter.
     char *name;          ///< Value of "name" parameter.
     char *comment;       ///< Value of "comment" parameter.
+    char *credential_login; ///< Value of "credential_login" parameter.
     char *family;        ///< Value of "family" parameter.
     char *scanconfig;    ///< Value of "scanconfig" parameter.
     char *scantarget;    ///< Value of "scantarget" parameter.
@@ -430,6 +432,10 @@
     {
       free (con_info->req_parms.comment);
     }
+  if (con_info->req_parms.credential_login)
+    {
+      free (con_info->req_parms.credential_login);
+    }
   if (con_info->req_parms.family)
     {
       free (con_info->req_parms.family);
@@ -621,6 +627,21 @@
           con_info->answercode = MHD_HTTP_OK;
           return MHD_YES;
         }
+      if (!strcmp (key, "credential_login"))
+        {
+          con_info->req_parms.credential_login = malloc (size + 1);
+          memcpy ((char *) con_info->req_parms.credential_login,
+                  (char *) data,
+                  size);
+          con_info->req_parms.credential_login[size] = 0;
+          if (abort_on_insane
+              && openvas_validate (validator,
+                                   "credential_login",
+                                   con_info->req_parms.credential_login))
+            return MHD_NO;
+          con_info->answercode = MHD_HTTP_OK;
+          return MHD_YES;
+        }
       if (!strcmp (key, "name"))
         {
           con_info->req_parms.name = malloc (size + 1);
@@ -1023,6 +1044,13 @@
           con_info->req_parms.comment = NULL;
         }
       if (openvas_validate (validator,
+                            "credential_login",
+                            con_info->req_parms.credential_login))
+        {
+          free (con_info->req_parms.name);
+          con_info->req_parms.name = NULL;
+        }
+      if (openvas_validate (validator,
                             "password",
                             con_info->req_parms.password))
         {
@@ -1041,6 +1069,7 @@
                                    con_info->req_parms.name,
                                    con_info->req_parms.comment,
                                    con_info->req_parms.base,
+                                   con_info->req_parms.credential_login,
                                    con_info->req_parms.password);
     }
   else if (!strcmp (con_info->req_parms.cmd, "create_task"))

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2009-12-16 12:38:32 UTC (rev 6147)
+++ trunk/gsa/src/gsad_omp.c	2009-12-16 12:49:06 UTC (rev 6148)
@@ -645,6 +645,7 @@
  * @param[in]  name         Credential name.
  * @param[in]  comment      Comment on credential.
  * @param[in]  type         Either "gen" or "pass".
+ * @param[in]  login        Credential user name.
  * @param[in]  password     Password, for type "pass".
  *
  * @return Result of XSL transformation.
@@ -654,6 +655,7 @@
                            char *name,
                            char *comment,
                            const char *type,
+                           const char *login,
                            const char *password)
 {
   entity_t entity;
@@ -670,7 +672,7 @@
 
   xml = g_string_new ("<commands_response>");
 
-  if (name == NULL || comment == NULL)
+  if (name == NULL || comment == NULL || login == NULL)
     g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Create Credential"));
   else
     {
@@ -683,20 +685,26 @@
                                     "<create_lsc_credential>"
                                     "<name>%s</name>"
                                     "%s%s%s"
+                                    "<login>%s</login>"
                                     "</create_lsc_credential>",
-                                    name, comment ? "<comment>" : "",
+                                    name,
+                                    comment ? "<comment>" : "",
                                     comment ? comment : "",
-                                    comment ? "</comment>" : "");
+                                    comment ? "</comment>" : "",
+                                    login);
       else
         ret = openvas_server_sendf (&session,
                                     "<create_lsc_credential>"
                                     "<name>%s</name>"
                                     "%s%s%s"
+                                    "<login>%s</login>"
                                     "<password>%s</password>"
                                     "</create_lsc_credential>",
-                                    name, comment ? "<comment>" : "",
+                                    name,
+                                    comment ? "<comment>" : "",
                                     comment ? comment : "",
                                     comment ? "</comment>" : "",
+                                    login,
                                     password ? password : "");
 
       if (ret == -1)

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2009-12-16 12:38:32 UTC (rev 6147)
+++ trunk/gsa/src/gsad_omp.h	2009-12-16 12:49:06 UTC (rev 6148)
@@ -58,7 +58,7 @@
 char * get_lsc_credentials_omp (credentials_t *, const char *, const char *,
                                 unsigned int *, const char *, const char *);
 char * create_lsc_credential_omp (credentials_t *, char *, char *,
-                                  const char *, const char *);
+                                  const char *, const char *, const char *);
 char * delete_lsc_credential_omp (credentials_t *, const char *);
 
 char * get_targets_omp (credentials_t *, const char *, const char *);

Modified: trunk/gsa/src/html/src/omp.xsl
===================================================================
--- trunk/gsa/src/html/src/omp.xsl	2009-12-16 12:38:32 UTC (rev 6147)
+++ trunk/gsa/src/html/src/omp.xsl	2009-12-16 12:49:06 UTC (rev 6148)
@@ -1135,6 +1135,13 @@
             </td>
           </tr>
           <tr>
+            <td valign="top" width="125">Login</td>
+            <td>
+              <input type="text" name="credential_login" value="" size="30"
+                     maxlength="80"/>
+            </td>
+          </tr>
+          <tr>
             <td valign="top" width="125">Comment (optional)</td>
             <td>
               <input type="text" name="comment" size="30" maxlength="400"/>
@@ -1190,6 +1197,7 @@
         <table class="gbntable" cellspacing="2" cellpadding="4" border="0">
           <tr class="gbntablehead2">
             <td>Name</td>
+            <td>Login</td>
             <td>Comment</td>
             <td width="100">Actions</td>
           </tr>
@@ -1244,6 +1252,9 @@
       <b><xsl:value-of select="name"/></b>
     </td>
     <td>
+      <xsl:value-of select="login"/>
+    </td>
+    <td>
       <xsl:value-of select="comment"/>
     </td>
     <td>



More information about the Openvas-commits mailing list