Author: jan
Date: 2008-09-09 14:06:36 +0200 (Tue, 09 Sep 2008)
New Revision: 1306

Modified:
   trunk/openvas-server/ChangeLog
   trunk/openvas-server/openvasd/comm.c
   trunk/openvas-server/openvasd/comm.h
   trunk/openvas-server/openvasd/ntp_11.c
Log:
Make the command PLUGIN_LIST send OIDs instead of old IDs.
Make the PLUGIN_INFO command be interpreted with OIDs
instead of IDs.

* openvasd/comm.c (send_plug_info): Changed behaviour
that in case there is no OID, the plugin is not sent
and instead a log message is issued. Previously the ID "1"
was applied.
Send OID instead of old ID.
(plugin_send_infos): Now takes char * oid as second parameter
instead of int id.

* openvasd/comm.h: Changed proto for plugin_send_infos accordingly.

* openvasd/ntp_11.c (ntp_11_parse_input): Call plugin_send_infos
with its new API.



Modified: trunk/openvas-server/ChangeLog
===================================================================
--- trunk/openvas-server/ChangeLog      2008-09-09 11:57:48 UTC (rev 1305)
+++ trunk/openvas-server/ChangeLog      2008-09-09 12:06:36 UTC (rev 1306)
@@ -1,3 +1,22 @@
+2008-09-05  Jan-Oliver Wagner <[EMAIL PROTECTED]>
+
+       Make the command PLUGIN_LIST send OIDs instead of old IDs.
+       Make the PLUGIN_INFO command be interpreted with OIDs
+       instead of IDs.
+
+       * openvasd/comm.c (send_plug_info): Changed behaviour
+       that in case there is no OID, the plugin is not sent
+       and instead a log message is issued. Previously the ID "1"
+       was applied.
+       Send OID instead of old ID.
+       (plugin_send_infos): Now takes char * oid as second parameter
+       instead of int id.
+
+       * openvasd/comm.h: Changed proto for plugin_send_infos accordingly.
+
+       * openvasd/ntp_11.c (ntp_11_parse_input): Call plugin_send_infos
+       with its new API.
+
 2008-09-09  Michael Wiegand <[EMAIL PROTECTED]>
 
        Adding preliminary support for OVAL definitions. Second step for change

Modified: trunk/openvas-server/openvasd/comm.c
===================================================================
--- trunk/openvas-server/openvasd/comm.c        2008-09-09 11:57:48 UTC (rev 
1305)
+++ trunk/openvas-server/openvasd/comm.c        2008-09-09 12:06:36 UTC (rev 
1306)
@@ -178,16 +178,14 @@
 
 
 /*
- * Sends the list of plugins that the server
- * could load to the client, using the 
- * NTP format
+ * Sends a plugin info.
  */
 void 
 send_plug_info(globals, plugins)
  struct arglist * globals;
  struct arglist * plugins;
 {
-  int i=1,j;
+  int j;
   static const char * categories[] =
     {"init", "scanner", "settings" , "infos", "attack", "mixed", 
"destructive_attack", "denial", "kill_host", "flood", "end", "unknown" };
 #define CAT_MAX        (sizeof(categories) / sizeof(categories[0]))
@@ -196,10 +194,13 @@
   const char *a, *b, *d, *e = NULL;
   char * desc = NULL;
 
-      args = plugins->value;
-      if(plug_get_id(args) == 0)
-        plug_set_id(args, i);
-       
+  args = plugins->value;
+
+  if (! plug_get_oid(args)) {
+    log_write ("NVT without OID found. Will not be sent.\n");
+    return;
+  }
+
       t = plug_get_description(args);
       
       if(t != NULL){
@@ -223,27 +224,27 @@
       {
        char * str;
        if(strchr(a, '\n') != NULL ){
-               fprintf(stderr, "ERROR - %d %s\n", plug_get_id(args), a);
+               fprintf(stderr, "ERROR - %s %s\n", plug_get_oid(args), a);
        }
        
        if(strchr(b, '\n') != NULL ){
-               fprintf(stderr, "ERROR - %d %s\n", plug_get_id(args), b);
+               fprintf(stderr, "ERROR - %s %s\n", plug_get_oid(args), b);
        
        }
        
        if(strchr(desc, '\n') != NULL ){
-               fprintf(stderr, "ERROR - %d %s\n", plug_get_id(args), desc);
+               fprintf(stderr, "ERROR - %s %s\n", plug_get_oid(args), desc);
        
        }
        
        if(strchr(d, '\n')){
-               fprintf(stderr, "ERROR - %d %s\n", plug_get_id(args), d);
+               fprintf(stderr, "ERROR - %s %s\n", plug_get_oid(args), d);
        }
        
        str = emalloc(strlen(a) + strlen(b) + strlen(desc) + strlen(d) +
                  strlen(plug_get_family(args))+ 1024);
-       sprintf(str, "%d <|> %s <|> %s <|> %s <|> %s <|> %s <|> %s",
-                 plug_get_id(args), a,
+       sprintf(str, "%s <|> %s <|> %s <|> %s <|> %s <|> %s <|> %s",
+               plug_get_oid(args), a,
                  categories[j],
                  b, desc, d,
                  plug_get_family(args));
@@ -282,13 +283,13 @@
 
 
 void
-plugin_send_infos(globals, id)
+plugin_send_infos(globals, oid)
  struct arglist * globals;
- int id;
+ char * oid;
 {
  struct arglist * plugins = arg_get_value(globals, "plugins");
 
- if(!id)
+ if(!oid)
   return;
  if(!plugins)
   return;
@@ -296,11 +297,7 @@
  while(plugins->next)
  {
   struct arglist * args = plugins->value;
-  if(args)
-  {
-   int p_id = plug_get_id(args);
-   if(p_id == id)break;
-  }
+  if (args && !strcmp(oid, plug_get_oid(args))) break;
   plugins = plugins->next;
   }
 
@@ -611,7 +608,7 @@
        t = strchr(s, ' ');
        if(!t)continue;
        t[0] = '\0';
-       plugin_send_infos(globals, atoi(s));
+       plugin_send_infos(globals, s);
    }
   else break;
  }

Modified: trunk/openvas-server/openvasd/comm.h
===================================================================
--- trunk/openvas-server/openvasd/comm.h        2008-09-09 11:57:48 UTC (rev 
1305)
+++ trunk/openvas-server/openvasd/comm.h        2008-09-09 12:06:36 UTC (rev 
1306)
@@ -40,6 +40,6 @@
 void comm_setup_plugins(struct arglist *, char *);
 void client_handler();
 void comm_send_md5_plugins(struct arglist*);
-void plugin_send_infos(struct arglist*, int);
+void plugin_send_infos(struct arglist*, char *);
 
 #endif

Modified: trunk/openvas-server/openvasd/ntp_11.c
===================================================================
--- trunk/openvas-server/openvasd/ntp_11.c      2008-09-09 11:57:48 UTC (rev 
1305)
+++ trunk/openvas-server/openvasd/ntp_11.c      2008-09-09 12:06:36 UTC (rev 
1306)
@@ -121,7 +121,7 @@
         break;
       }
       s = t + 5;
-      plugin_send_infos(globals, atoi(s));
+      plugin_send_infos(globals, s);
       break;
       }
 

_______________________________________________
Openvas-commits mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits

Reply via email to