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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 30 12:34:10 CET 2011


Author: mattm
Date: 2011-11-30 12:34:06 +0100 (Wed, 30 Nov 2011)
New Revision: 12222

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
Log:
	* src/gsad.c (exec_omp_post): Allow empty passwords.  If login is empty
	go to the login page with fail message, instead of an internal error page.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-11-30 11:26:16 UTC (rev 12221)
+++ trunk/gsa/ChangeLog	2011-11-30 11:34:06 UTC (rev 12222)
@@ -1,5 +1,10 @@
 2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	* src/gsad.c (exec_omp_post): Allow empty passwords.  If login is empty
+	go to the login page with fail message, instead of an internal error page.
+
+2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>
+
 	* src/gsad_omp.c (create_note_omp): Add missing days init.
 
 2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-11-30 11:26:16 UTC (rev 12221)
+++ trunk/gsa/src/gsad.c	2011-11-30 11:34:06 UTC (rev 12222)
@@ -1161,13 +1161,20 @@
 
   if (cmd && !strcmp (cmd, "login"))
     {
+      const char *password;
+
+      password = params_value (con_info->params, "password");
+      if ((password == NULL)
+          && (params_original_value (con_info->params, "password") == NULL))
+        password = "";
+
       if (params_value (con_info->params, "login")
-          && params_value (con_info->params, "password"))
+          && password)
         {
           int ret;
           gchar *timezone, *role;
           ret = authenticate_omp (params_value (con_info->params, "login"),
-                                  params_value (con_info->params, "password"),
+                                  password,
                                   &role,
                                   &timezone);
           if (ret)
@@ -1197,7 +1204,7 @@
             {
               user_t *user;
               user = user_add (params_value (con_info->params, "login"),
-                               params_value (con_info->params, "password"),
+                               password,
                                timezone,
                                role);
               /* Redirect to get_tasks. */
@@ -1207,6 +1214,32 @@
               return 1;
             }
         }
+      else if ((params_value (con_info->params, "login") == NULL)
+               && ((params_original_value (con_info->params, "login") == NULL)
+                   || (strcmp (params_original_value (con_info->params, "login"),
+                               "")
+                       == 0)))
+        {
+          time_t now;
+          gchar *xml;
+          char *res;
+          char ctime_now[200];
+
+          now = time (NULL);
+          ctime_r_strip_newline (&now, ctime_now);
+
+          xml = g_strdup_printf ("<login_page>"
+                                 "<message>"
+                                 "Login failed."
+                                 "</message>"
+                                 "<token></token>"
+                                 "<time>%s</time>"
+                                 "</login_page>",
+                                 ctime_now);
+          res = xsl_transform (xml);
+          g_free (xml);
+          con_info->response = res;
+        }
       else
         {
           con_info->response = gsad_message (credentials,
@@ -1214,7 +1247,7 @@
                                              __FUNCTION__,
                                              __LINE__,
                                              "An internal error occured inside GSA daemon. "
-                                             "Diagnostics: Login or password missing.",
+                                             "Diagnostics: Error in login or password.",
                                              "/omp?cmd=get_tasks");
         }
       con_info->answercode = MHD_HTTP_OK;



More information about the Openvas-commits mailing list