[Openvas-commits] r3104 - in trunk/openvas-client: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 15 12:02:54 CEST 2009


Author: mwiegand
Date: 2009-04-15 12:02:53 +0200 (Wed, 15 Apr 2009)
New Revision: 3104

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/configure
   trunk/openvas-client/configure.in
   trunk/openvas-client/nessus.tmpl.in
   trunk/openvas-client/src/Makefile
   trunk/openvas-client/src/omp-cli.c
Log:
First (optional) integration of openvas-libraries in openvas-client. The
OMP Command Line Interface now depends on connection functionality
provided by openvas-libraries.

* src/omp-cli.c: Adjusted function names, added missing headers.

* src/Makefile: Adjusted to use LIBOPENVAS_*.

* configure.in: Added tests for libopenvasconfig.

* nessus.tmpl.in: Added support for LIBOPENVAS_*.

* configure: Regenerated.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-04-15 08:17:28 UTC (rev 3103)
+++ trunk/openvas-client/ChangeLog	2009-04-15 10:02:53 UTC (rev 3104)
@@ -1,3 +1,19 @@
+2009-04-15  Michael Wiegand <michael.wiegand at intevation.de>
+
+	First (optional) integration of openvas-libraries in openvas-client. The
+	OMP Command Line Interface now depends on connection functionality
+	provided by openvas-libraries.
+
+	* src/omp-cli.c: Adjusted function names, added missing headers.
+
+	* src/Makefile: Adjusted to use LIBOPENVAS_*.
+
+	* configure.in: Added tests for libopenvasconfig.
+
+	* nessus.tmpl.in: Added support for LIBOPENVAS_*.
+
+	* configure: Regenerated.
+
 2009-04-09  Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
 
 	* MANIFEST: Updated.

Modified: trunk/openvas-client/configure
===================================================================
--- trunk/openvas-client/configure	2009-04-15 08:17:28 UTC (rev 3103)
+++ trunk/openvas-client/configure	2009-04-15 10:02:53 UTC (rev 3104)
@@ -678,6 +678,7 @@
 PKG_CONFIG
 GLIB_CFLAGS
 GLIB_LIBS
+LIBOPENVASCONFIG
 ALLOCA
 XMKMF
 X_CFLAGS
@@ -714,6 +715,8 @@
 gdc_lib
 client
 client_install
+LIBOPENVAS_CFLAGS
+LIBOPENVAS_LIBS
 ac_configure_args
 ssl
 sslcflags
@@ -1778,7 +1781,6 @@
 
 test "x$prefix" != "xNONE" || prefix=/usr/local
 
-
 ac_config_headers="$ac_config_headers include/config.h"
 
 
@@ -4077,7 +4079,103 @@
 
 
 
+NEED_OPENVASLIBS_VERSION=2.0.3
 
+
+# Extract the first word of "libopenvas-config", so it can be a program name with args.
+set dummy libopenvas-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_LIBOPENVASCONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $LIBOPENVASCONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LIBOPENVASCONFIG="$LIBOPENVASCONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_LIBOPENVASCONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+LIBOPENVASCONFIG=$ac_cv_path_LIBOPENVASCONFIG
+if test -n "$LIBOPENVASCONFIG"; then
+  { echo "$as_me:$LINENO: result: $LIBOPENVASCONFIG" >&5
+echo "${ECHO_T}$LIBOPENVASCONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+
+if test "x$LIBOPENVASCONFIG" = "x"; then
+  { echo "$as_me:$LINENO: WARNING: \"Could not find $LIBOPENVASCONFIG!" >&5
+echo "$as_me: WARNING: \"Could not find $LIBOPENVASCONFIG!" >&2;}
+else
+  OPENVASLIBS_VERSION=`$LIBOPENVASCONFIG --version`
+
+  OPENVASLIBS_MAJOR=`echo $OPENVASLIBS_VERSION | \
+                 sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`
+  OPENVASLIBS_MINOR=`echo $OPENVASLIBS_VERSION | \
+                 sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`
+  OPENVASLIBS_PATCH=`echo $OPENVASLIBS_VERSION | \
+                 sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`
+  REQ_OPENVASLIBS_MAJOR=`echo $NEED_OPENVASLIBS_VERSION | \
+                 sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`
+  REQ_OPENVASLIBS_MINOR=`echo $NEED_OPENVASLIBS_VERSION | \
+                 sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`
+  REQ_OPENVASLIBS_PATCH=`echo $NEED_OPENVASLIBS_VERSION | \
+                 sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`
+
+
+  ok=no
+  if test "$OPENVASLIBS_MAJOR" -gt "$REQ_OPENVASLIBS_MAJOR"; then
+    ok=yes
+  else
+    if test "$OPENVASLIBS_MAJOR" -eq "$REQ_OPENVASLIBS_MAJOR"; then
+      if test "$OPENVASLIBS_MINOR" -gt "$REQ_OPENVASLIBS_MINOR"; then
+        ok=yes
+      else
+        if test "$OPENVASLIBS_MINOR" -eq "$REQ_OPENVASLIBS_MINOR"; then
+          if test "$OPENVASLIBS_PATCH" -ge "$REQ_OPENVASLIBS_PATCH"; then
+            ok=yes
+          fi
+        fi
+      fi
+    fi
+  fi
+  if test $ok = no; then
+    { echo "$as_me:$LINENO: WARNING: \"openvas-libraries $OPENVASLIBS_VERSION too old.\"
+    \"Minimum required is $NEED_OPENVASLIBS_VERSION .\"
+    \"You will not be able to compile the OMP cli.\"
+    " >&5
+echo "$as_me: WARNING: \"openvas-libraries $OPENVASLIBS_VERSION too old.\"
+    \"Minimum required is $NEED_OPENVASLIBS_VERSION .\"
+    \"You will not be able to compile the OMP cli.\"
+    " >&2;}
+  else
+    LIBOPENVAS_LIBS=`$LIBOPENVASCONFIG --libs`
+
+    LIBOPENVAS_CFLAGS=`$LIBOPENVASCONFIG --cflags`
+  fi
+fi
+
+
 saveCFLAGS="$CFLAGS"
 
 { echo "$as_me:$LINENO: checking for ANSI C header files" >&5
@@ -11408,6 +11506,7 @@
 
 
 
+
 ac_config_files="$ac_config_files nessus.tmpl include/corevers.h openvasclient-mkcert"
 
 cat >confcache <<\_ACEOF
@@ -12091,6 +12190,7 @@
 PKG_CONFIG!$PKG_CONFIG$ac_delim
 GLIB_CFLAGS!$GLIB_CFLAGS$ac_delim
 GLIB_LIBS!$GLIB_LIBS$ac_delim
+LIBOPENVASCONFIG!$LIBOPENVASCONFIG$ac_delim
 ALLOCA!$ALLOCA$ac_delim
 XMKMF!$XMKMF$ac_delim
 X_CFLAGS!$X_CFLAGS$ac_delim
@@ -12124,7 +12224,6 @@
 nessus_lib!$nessus_lib$ac_delim
 man_nessus_1!$man_nessus_1$ac_delim
 dl_lib!$dl_lib$ac_delim
-gdc_lib!$gdc_lib$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -12166,8 +12265,11 @@
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+gdc_lib!$gdc_lib$ac_delim
 client!$client$ac_delim
 client_install!$client_install$ac_delim
+LIBOPENVAS_CFLAGS!$LIBOPENVAS_CFLAGS$ac_delim
+LIBOPENVAS_LIBS!$LIBOPENVAS_LIBS$ac_delim
 ac_configure_args!$ac_configure_args$ac_delim
 ssl!$ssl$ac_delim
 sslcflags!$sslcflags$ac_delim
@@ -12177,7 +12279,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 12; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

Modified: trunk/openvas-client/configure.in
===================================================================
--- trunk/openvas-client/configure.in	2009-04-15 08:17:28 UTC (rev 3103)
+++ trunk/openvas-client/configure.in	2009-04-15 10:02:53 UTC (rev 3104)
@@ -28,7 +28,6 @@
 
 test "x$prefix" != "xNONE" || prefix=/usr/local
 
-
 dnl Set up the main lines of the config script
 AC_CONFIG_HEADER(include/config.h)
 AC_PREFIX_DEFAULT("/usr/local")
@@ -99,6 +98,61 @@
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
+NEED_OPENVASLIBS_VERSION=2.0.3
+
+dnl Testing for presence and correct version of openvas-libraries:
+dnl --------------------------------------------------------------
+
+AC_PATH_PROG(LIBOPENVASCONFIG, libopenvas-config)
+
+if test "x$LIBOPENVASCONFIG" = "x"; then
+  AC_MSG_WARN("Could not find $LIBOPENVASCONFIG!, you will not be able to compile the OMP cli.")
+else
+  OPENVASLIBS_VERSION=`$LIBOPENVASCONFIG --version`
+
+  OPENVASLIBS_MAJOR=`echo $OPENVASLIBS_VERSION | \
+                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+  OPENVASLIBS_MINOR=`echo $OPENVASLIBS_VERSION | \
+                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+  OPENVASLIBS_PATCH=`echo $OPENVASLIBS_VERSION | \
+                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+  REQ_OPENVASLIBS_MAJOR=`echo $NEED_OPENVASLIBS_VERSION | \
+                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+  REQ_OPENVASLIBS_MINOR=`echo $NEED_OPENVASLIBS_VERSION | \
+                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+  REQ_OPENVASLIBS_PATCH=`echo $NEED_OPENVASLIBS_VERSION | \
+                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+
+
+  ok=no
+  if test "$OPENVASLIBS_MAJOR" -gt "$REQ_OPENVASLIBS_MAJOR"; then
+    ok=yes
+  else
+    if test "$OPENVASLIBS_MAJOR" -eq "$REQ_OPENVASLIBS_MAJOR"; then
+      if test "$OPENVASLIBS_MINOR" -gt "$REQ_OPENVASLIBS_MINOR"; then
+        ok=yes
+      else
+        if test "$OPENVASLIBS_MINOR" -eq "$REQ_OPENVASLIBS_MINOR"; then
+          if test "$OPENVASLIBS_PATCH" -ge "$REQ_OPENVASLIBS_PATCH"; then
+            ok=yes
+          fi
+        fi
+      fi
+    fi
+  fi
+  if test $ok = no; then
+    AC_MSG_WARN(
+    "openvas-libraries $OPENVASLIBS_VERSION too old."
+    "Minimum required is $NEED_OPENVASLIBS_VERSION ."
+    "You will not be able to compile the OMP cli."
+    )
+  else
+    LIBOPENVAS_LIBS=`$LIBOPENVASCONFIG --libs`
+
+    LIBOPENVAS_CFLAGS=`$LIBOPENVASCONFIG --cflags`
+  fi
+fi
+
 dnl only vanilla sed can handle long substitution lines
 
 saveCFLAGS="$CFLAGS"
@@ -572,13 +626,14 @@
 AC_SUBST(datadir)
 AC_SUBST(GTKCONFIG_CFLAGS)
 AC_SUBST(GTKCONFIG_LIBS)
+AC_SUBST(LIBOPENVAS_CFLAGS)
+AC_SUBST(LIBOPENVAS_LIBS)
 AC_SUBST(ac_configure_args)
 AC_SUBST(ssl)
 AC_SUBST(sslcflags)
 AC_SUBST(installuser)
 AC_SUBST(gettext_flags)
 
-
 dnl And we put everything in the appropriate files
 AC_OUTPUT(nessus.tmpl include/corevers.h openvasclient-mkcert)
 

Modified: trunk/openvas-client/nessus.tmpl.in
===================================================================
--- trunk/openvas-client/nessus.tmpl.in	2009-04-15 08:17:28 UTC (rev 3103)
+++ trunk/openvas-client/nessus.tmpl.in	2009-04-15 10:02:53 UTC (rev 3104)
@@ -108,6 +108,8 @@
 GTKCONFIG_LIBS=@GTKCONFIG_LIBS@
 GLIB_CFLAGS=@GLIB_CFLAGS@
 GLIB_LIBS=@GLIB_LIBS@
+LIBOPENVAS_CFLAGS=@LIBOPENVAS_CFLAGS@
+LIBOPENVAS_LIBS=@LIBOPENVAS_LIBS@
 DL_LIB=@dl_lib@
 GDC_LIB=@gdc_lib@
 RESOLV_LIB=@resolv_lib@

Modified: trunk/openvas-client/src/Makefile
===================================================================
--- trunk/openvas-client/src/Makefile	2009-04-15 08:17:28 UTC (rev 3103)
+++ trunk/openvas-client/src/Makefile	2009-04-15 10:02:53 UTC (rev 3104)
@@ -41,10 +41,10 @@
 	@chmod +x cflags
 
 omp-cli.o: omp-cli.c
-	$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c omp-cli.c
+	$(CC) $(CFLAGS) $(LIBOPENVAS_CFLAGS) $(OPENVAS_INCLUDE) -c omp-cli.c
 
 omp-cli: cflags $(OBJS)
-	$(CC) $(LDFLAGS) common.o omp-cli.o -o omp-cli $(LIBS) $(GLIB_LIBS) -lgnutls
+	$(CC) $(LDFLAGS) common.o omp-cli.o -o omp-cli $(LIBS) $(GLIB_LIBS) $(LIBOPENVAS_LIBS)
 
 common.o: ../../openvas-manager/src/tests/common.c ../../openvas-manager/src/tests/common.h ../../openvas-manager/src/tracef.h
 	$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c ../../openvas-manager/src/tests/common.c

Modified: trunk/openvas-client/src/omp-cli.c
===================================================================
--- trunk/openvas-client/src/omp-cli.c	2009-04-15 08:17:28 UTC (rev 3103)
+++ trunk/openvas-client/src/omp-cli.c	2009-04-15 10:02:53 UTC (rev 3104)
@@ -34,14 +34,13 @@
  */
 
 #include <glib.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
+#include <openvas_server.h>
 #include "common.h"
 #include "corevers.h"
 
-#define TRACE 0
-
 /**
  * @brief The name of this program.
  */
@@ -152,7 +151,7 @@
               manager_port);
     }
 
-  socket = connect_to_manager_host_port (&session, manager_host_string, manager_port);
+  socket = openvas_server_connect_to_server (&session, manager_host_string, manager_port);
   if (socket == -1)
     {
       fprintf (stderr, "Failed to acquire socket.\n");
@@ -161,16 +160,16 @@
 
   if (authenticate (&session, omp_username, omp_password))
     {
-      close_manager_connection (socket, session);
+      openvas_server_close_server_connection (socket, session);
       fprintf (stderr, "Failed to authenticate.\n");
       exit (EXIT_FAILURE);
     }
 
   fprintf (stderr, "Sending to manager: %s", omp_command);
 
-  if (send_to_manager (&session, omp_command) == -1)
+  if (openvas_server_send_to_server (&session, omp_command) == -1)
     {
-      close_manager_connection (socket, session);
+      openvas_server_close_server_connection (socket, session);
       fprintf (stderr, "Failed to send_to_manager.\n");
       exit (EXIT_FAILURE);
     }
@@ -181,7 +180,7 @@
   if (read_entity (&session, &entity))
     {
       fprintf (stderr, "Failed to read response.\n");
-      close_manager_connection (socket, session);
+      openvas_server_close_server_connection (socket, session);
       exit (EXIT_FAILURE);
     }
 
@@ -191,7 +190,7 @@
 
   /* Cleanup. */
 
-  close_manager_connection (socket, session);
+  openvas_server_close_server_connection (socket, session);
   free_entity (entity);
 
   exit (EXIT_SUCCESS);



More information about the Openvas-commits mailing list