Author: timopollmeier
Date: 2016-09-21 15:17:13 +0200 (Wed, 21 Sep 2016)
New Revision: 26251

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage_migrators.c
   trunk/openvas-manager/src/manage_sql.c
Log:
        * src/manage_migrators.c (migrate_177_to_178): Set credential to NULL
        instead of 0 so it works with postgres. Do so before attempting to
        delete the credential and also delete credential data together with
        the credential.

        * src/manage_sql.c (check_db_scanners): Set credential to NULL instead
        of 0 so it works with postgres.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog     2016-09-21 13:05:52 UTC (rev 26250)
+++ trunk/openvas-manager/ChangeLog     2016-09-21 13:17:13 UTC (rev 26251)
@@ -1,3 +1,13 @@
+2016-09-21  Timo Pollmeier <timo.pollme...@greenbone.net>
+
+       * src/manage_migrators.c (migrate_177_to_178): Set credential to NULL
+       instead of 0 so it works with postgres. Do so before attempting to
+       delete the credential and also delete credential data together with
+       the credential.
+
+       * src/manage_sql.c (check_db_scanners): Set credential to NULL instead
+       of 0 so it works with postgres.
+
 2016-09-21  Matthew Mundell <matthew.mund...@greenbone.net>
 
        * src/openvasmd.c (main): Check for conflicts with --unix-socket.

Modified: trunk/openvas-manager/src/manage_migrators.c
===================================================================
--- trunk/openvas-manager/src/manage_migrators.c        2016-09-21 13:05:52 UTC 
(rev 26250)
+++ trunk/openvas-manager/src/manage_migrators.c        2016-09-21 13:17:13 UTC 
(rev 26251)
@@ -13371,11 +13371,16 @@
   sql ("UPDATE scanners SET ca_pub = NULL"
        " WHERE uuid = '" SCANNER_UUID_DEFAULT "';");
 
-  /* Delete credential of default scanner if it is not used elsewhere. */
+  /* Get credential to delete it if possible */
   sql_int64 (&credential,
              "SELECT credential FROM scanners"
              " WHERE uuid = '" SCANNER_UUID_DEFAULT "'");
 
+  /* Remove reference to credential from default scanner. */
+  sql ("UPDATE scanners SET credential = NULL"
+       " WHERE uuid = '" SCANNER_UUID_DEFAULT "';");
+
+  /* Delete credential of default scanner if it is not used elsewhere. */
   if ((sql_int ("SELECT count(*) FROM scanners"
                 " WHERE credential = %llu"
                 "   AND uuid != '" SCANNER_UUID_DEFAULT "';",
@@ -13399,14 +13404,12 @@
                    "   AND credential_location = %d;",
                    credential, LOCATION_TABLE) == 0))
     {
+      sql ("DELETE FROM credentials_data WHERE credential = %llu",
+           credential);
       sql ("DELETE FROM credentials WHERE id = %llu",
            credential);
     }
 
-  /* Remove reference to credential from default scanner. */
-  sql ("UPDATE scanners SET credential = 0"
-       " WHERE uuid = '" SCANNER_UUID_DEFAULT "';");
-
   /* Set the database version to 178. */
 
   set_db_version (178);

Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c      2016-09-21 13:05:52 UTC (rev 
26250)
+++ trunk/openvas-manager/src/manage_sql.c      2016-09-21 13:17:13 UTC (rev 
26251)
@@ -13958,7 +13958,7 @@
            " (uuid, owner, name, host, port, type, ca_pub, credential,"
            "  creation_time, modification_time)"
            " VALUES ('" SCANNER_UUID_DEFAULT "', NULL, 'OpenVAS Default',"
-           " '" OPENVASSD_ADDRESS "', 0, %d, NULL, 0, m_now (), m_now ());",
+           " '" OPENVASSD_ADDRESS "', 0, %d, NULL, NULL, m_now (), m_now ());",
            SCANNER_TYPE_OPENVAS);
     }
 

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to