Author: mattm
Date: 2016-10-14 15:01:06 +0200 (Fri, 14 Oct 2016)
New Revision: 26410

Modified:
   branches/openvas-manager-6.0/ChangeLog
   branches/openvas-manager-6.0/src/manage_sql.c
Log:
        Backport r26406.

        * src/manage_sql.c (check_db_configs): Only check for removed Service
        Detection NVTs when there are NVTs in the nvts table.

Modified: branches/openvas-manager-6.0/ChangeLog
===================================================================
--- branches/openvas-manager-6.0/ChangeLog      2016-10-14 12:32:02 UTC (rev 
26409)
+++ branches/openvas-manager-6.0/ChangeLog      2016-10-14 13:01:06 UTC (rev 
26410)
@@ -1,3 +1,10 @@
+2016-10-14  Matthew Mundell <matthew.mund...@greenbone.net>
+
+       Backport r26406.
+
+       * src/manage_sql.c (check_db_configs): Only check for removed Service
+       Detection NVTs when there are NVTs in the nvts table.
+
 2016-10-12  Timo Pollmeier <timo.pollme...@greenbone.net>
 
        Backport r26381.

Modified: branches/openvas-manager-6.0/src/manage_sql.c
===================================================================
--- branches/openvas-manager-6.0/src/manage_sql.c       2016-10-14 12:32:02 UTC 
(rev 26409)
+++ branches/openvas-manager-6.0/src/manage_sql.c       2016-10-14 13:01:06 UTC 
(rev 26410)
@@ -13057,15 +13057,21 @@
   /* In the Service Detection family, NVTs sometimes move to Product
    * Detection, and once an NVT was removed.  So remove those NVTs
    * from Service Detection in the NVT selector. */
+
   sql ("DELETE FROM nvt_selectors"
        " WHERE name = '" MANAGE_NVT_SELECTOR_UUID_DISCOVERY "'"
        " AND family = 'Service detection'"
-       " AND (((SELECT family FROM nvts"
-       "        WHERE oid = nvt_selectors.family_or_nvt)"
-       "       = 'Product detection')"
-       "      OR NOT EXISTS (SELECT * FROM nvts"
-       "                     WHERE oid = nvt_selectors.family_or_nvt));");
+       " AND (SELECT family FROM nvts"
+       "      WHERE oid = nvt_selectors.family_or_nvt)"
+       "     = 'Product detection';");
 
+  if (sql_int ("SELECT EXISTS (SELECT * FROM nvts);"))
+    sql ("DELETE FROM nvt_selectors"
+         " WHERE name = '" MANAGE_NVT_SELECTOR_UUID_DISCOVERY "'"
+         " AND family = 'Service detection'"
+         " AND NOT EXISTS (SELECT * FROM nvts"
+         "                 WHERE oid = nvt_selectors.family_or_nvt);");
+
   if (sql_int ("SELECT count(*) FROM configs"
                " WHERE uuid = '%s';",
                CONFIG_UUID_HOST_DISCOVERY)

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

Reply via email to