[Openvas-commits] r3382 - in trunk/openvas-client: . nessus src/util

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 15 13:57:32 CEST 2009


Author: felix
Date: 2009-05-15 13:57:31 +0200 (Fri, 15 May 2009)
New Revision: 3382

Added:
   trunk/openvas-client/src/util/openvas_lsc_user_deb.c
   trunk/openvas-client/src/util/openvas_lsc_user_deb.h
Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/MANIFEST
   trunk/openvas-client/nessus/Makefile
   trunk/openvas-client/src/util/Makefile
Log:
Added stub for module openvas_lsc_user_deb that will create deb packages
from the rpm packages that install accounts for lsc.

* MANIFEST: Added the new files.

* nessus/Makefile: Added object to UTIL_OBJS.

* src/util/Makefile: Added target for new module.

* src/util/openvas_lsc_user_deb.c, src/util/openvas_lsc_user_deb.c:
New. Will take care of executing alien to transform rpm packages to
deb packages.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-05-15 10:30:21 UTC (rev 3381)
+++ trunk/openvas-client/ChangeLog	2009-05-15 11:57:31 UTC (rev 3382)
@@ -1,5 +1,20 @@
 2009-05-15  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Added stub for module openvas_lsc_user_deb that will create deb packages
+	from the rpm packages that install accounts for lsc.
+
+	* MANIFEST: Added the new files.
+	
+	* nessus/Makefile: Added object to UTIL_OBJS.
+	
+	* src/util/Makefile: Added target for new module.
+	
+	* src/util/openvas_lsc_user_deb.c, src/util/openvas_lsc_user_deb.c:
+	New. Will take care of executing alien to transform rpm packages to
+	deb packages.
+	
+2009-05-15  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	Preparing display of filenames of 'installers' for credentials.
 
 	* src/gui/ssh_key_info_form.h: Added references to text entries to

Modified: trunk/openvas-client/MANIFEST
===================================================================
--- trunk/openvas-client/MANIFEST	2009-05-15 10:30:21 UTC (rev 3381)
+++ trunk/openvas-client/MANIFEST	2009-05-15 11:57:31 UTC (rev 3382)
@@ -233,6 +233,8 @@
 src/util/file_utils.c
 src/util/file_utils.h
 src/util/Makefile
+src/util/openvas_lsc_user_deb.c
+src/util/openvas_lsc_user_deb.h
 src/util/openvas_lsc_user_makensis.c
 src/util/openvas_lsc_user_makensis.h
 src/util/openvas_ssh_key_create.c

Modified: trunk/openvas-client/nessus/Makefile
===================================================================
--- trunk/openvas-client/nessus/Makefile	2009-05-15 10:30:21 UTC (rev 3381)
+++ trunk/openvas-client/nessus/Makefile	2009-05-15 11:57:31 UTC (rev 3382)
@@ -79,7 +79,8 @@
             ../src/util/openvas_ssh_rpm.o \
             ../src/util/severity_filter.o \
             ../src/openvas-lib/hash_table_file.o \
-            ../src/util/openvas_lsc_user_makensis.o
+            ../src/util/openvas_lsc_user_makensis.o\
+            ../src/util/openvas_lsc_user_deb.o
 
 
 all : cflags ${make_bindir}/$(NESSUSCLIENT)

Modified: trunk/openvas-client/src/util/Makefile
===================================================================
--- trunk/openvas-client/src/util/Makefile	2009-05-15 10:30:21 UTC (rev 3381)
+++ trunk/openvas-client/src/util/Makefile	2009-05-15 11:57:31 UTC (rev 3382)
@@ -49,7 +49,7 @@
 endif
 
 OBJS=openvas_ssh_key_create.o parseutils.o severity_filter.o file_utils.o\
-     openvas_ssh_rpm.o openvas_lsc_user_makensis.o
+     openvas_ssh_rpm.o openvas_lsc_user_makensis.o openvas_lsc_user_deb.o
 
 all : cflags $(OBJS)
 
@@ -78,5 +78,9 @@
                              openvas_lsc_user_makensis.h
 	$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c openvas_lsc_user_makensis.c
 
+openvas_lsc_user_deb.o: openvas_lsc_user_deb.c\
+                        openvas_lsc_user_deb.h
+	$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c openvas_lsc_user_deb.c
+
 clean :
 	rm -f *.o cflags

Added: trunk/openvas-client/src/util/openvas_lsc_user_deb.c
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_deb.c	2009-05-15 10:30:21 UTC (rev 3381)
+++ trunk/openvas-client/src/util/openvas_lsc_user_deb.c	2009-05-15 11:57:31 UTC (rev 3382)
@@ -0,0 +1,144 @@
+/* OpenVAS-Client
+ * $Id$
+ * Description: Create user install packages from rpm packages by calling alien.
+ *
+ * Authors:
+ * Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ *
+ * Copyright:
+ * Copyright (C) 2009 Intevation GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or, at your option, any later version as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * In addition, as a special exception, you have
+ * permission to link the code of this program with the OpenSSL
+ * library (or with modified versions of OpenSSL that use the same
+ * license as OpenSSL), and distribute linked combinations including
+ * the two. You must obey the GNU General Public License in all
+ * respects for all of the code used other than OpenSSL. If you
+ * modify this file, you may extend this exception to your version
+ * of the file, but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version.
+ */
+
+/**
+ * @file
+ * 
+ * The OpenVAS Credentials Manager allows the user to create "accounts" that
+ * are used to perform local checks.
+ * 
+ * For *nix- systems RPM packages can be created that install the public key of
+ * the 'account' (@see openvas_lsc_user_rpm).
+ * 
+ * Using the tool "alien" these packages can be transformed into debian (.deb)
+ * packages.
+ */
+
+#include "openvas_ssh_login.h"
+#include "file_utils.h"
+#include "nessus_i18n.h"
+#include "error_dlg.h"
+#include <glib/gstdio.h>
+#include "includes.h" /* For stdio (function: remove) */
+#include "preferences.h" /* For prefs_get_nessushome */
+#include "context.h" /* For check_is_dir (!) and context_remove_directory (!): @TODO */
+#include "openvas_lsc_user_makensis.h"
+
+/**
+ * @brief Execute alien to create a deb packages from an rpm package.
+ * @param rpmfile .rpm file to transform with alien to a .deb.
+ */
+static gboolean
+execute_alien (const gchar* rpmfile)
+{
+  gchar** cmd;
+  gint exit_status;
+
+  cmd = (gchar **) g_malloc (3 * sizeof (gchar *));
+
+  cmd[0] = g_strdup ("alien");
+  cmd[1] = g_strdup (rpmfile);
+  cmd[2] = NULL;
+  printf ("--- executing alien.\n");
+  if (g_spawn_sync (".",
+                    cmd,
+                    NULL, // env
+                    G_SPAWN_SEARCH_PATH,
+                    NULL, // setup func
+                    NULL,
+                    NULL,
+                    NULL,
+                    &exit_status,
+                    NULL                 ) == FALSE
+      || exit_status != 0)
+    {
+      show_error(_("Error (%d) creating the deb package.\n"
+                   "For further information consult your shell."), exit_status);
+      exit_status = -1;
+    }
+
+  g_free (cmd[0]);
+  g_free (cmd[1]);
+  g_free (cmd[2]);
+  g_free (cmd);
+
+  printf ("--- alien returned %d.\n", exit_status);
+  return (exit_status == 0);
+}
+
+/**
+ * @brief Returns whether alien could be found in the path.
+ * 
+ * The check itself will only be done once.
+ * 
+ * @return true if alien could be found in the path, false otherwise.
+ */
+gboolean
+openvas_lsc_user_deb_alien_found ()
+{
+  static gboolean searched = FALSE;
+  static gboolean found    = FALSE;
+
+  if (searched == FALSE)
+    {
+      // Check if alien is found in path
+      gchar* alien_path = g_find_program_in_path ("alien");
+      if (alien_path != NULL)
+        {
+          found = TRUE;
+          g_free (alien_path);
+        }
+      searched = TRUE;
+    }
+
+  return found;
+}
+
+/**
+ * @brief Attempts creation of a deb packages from an rpm package.
+ * 
+ * @param loginfo openvas_ssh_login struct to create rpm for.
+ * 
+ * @return TRUE if successful, FALSE otherwise.
+ */
+gboolean
+openvas_lsc_user_deb (openvas_ssh_login* loginfo, const gchar* to_filename)
+{
+  gboolean success   = FALSE;
+  
+  /** @TODO execute_alien */
+
+  return success;
+}

Added: trunk/openvas-client/src/util/openvas_lsc_user_deb.h
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_deb.h	2009-05-15 10:30:21 UTC (rev 3381)
+++ trunk/openvas-client/src/util/openvas_lsc_user_deb.h	2009-05-15 11:57:31 UTC (rev 3382)
@@ -0,0 +1,47 @@
+/* OpenVAS-Client
+ * $Id$
+ * Description: Create user install packages from rpm packages by calling alien.
+ *
+ * Authors:
+ * Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ *
+ * Copyright:
+ * Copyright (C) 2009 Intevation GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or, at your option, any later version as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * In addition, as a special exception, you have
+ * permission to link the code of this program with the OpenSSL
+ * library (or with modified versions of OpenSSL that use the same
+ * license as OpenSSL), and distribute linked combinations including
+ * the two. You must obey the GNU General Public License in all
+ * respects for all of the code used other than OpenSSL. If you
+ * modify this file, you may extend this exception to your version
+ * of the file, but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version.
+ */
+
+#ifndef _OPENVAS_LSC_USER_DEB_H
+#define _OPENVAS_LSC_USER_DEB_H
+
+#include <glib.h>
+#include "openvas_ssh_login.h"
+
+gboolean openvas_lsc_user_deb (openvas_ssh_login* loginfo,
+                               const gchar* to_filename);
+
+gboolean openvas_lsc_user_deb_alien_found ();
+
+#endif /* _OPENVAS_LSC_USER_DEB_H */



More information about the Openvas-commits mailing list