[Openvas-commits] r3419 - in trunk/openvas-client: . nessus src/util
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue May 19 11:58:28 CEST 2009
Author: felix
Date: 2009-05-19 11:58:27 +0200 (Tue, 19 May 2009)
New Revision: 3419
Added:
trunk/openvas-client/src/util/openvas_lsc_target_prep.c
trunk/openvas-client/src/util/openvas_lsc_target_prep.h
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/MANIFEST
trunk/openvas-client/nessus/Makefile
trunk/openvas-client/src/util/Makefile
Log:
Extracted module with common functionality that is needed for
credential installer/packages (rpm,deb,exe).
* src/util/openvas_lsc_target_prep.c,
src/util/openvas_lsc_target_prep.h: New module with common functionality
for the package/installer generators.
* MANIFEST: Added the two new files.
* nessus/Makefile: Added object to UTIL_OBJS.
* src/util/Makefile: Added target for new module.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-05-19 08:55:13 UTC (rev 3418)
+++ trunk/openvas-client/ChangeLog 2009-05-19 09:58:27 UTC (rev 3419)
@@ -1,3 +1,18 @@
+2009-05-19 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
+ Extracted module with common functionality that is needed for
+ credential installer/packages (rpm,deb,exe).
+
+ * src/util/openvas_lsc_target_prep.c,
+ src/util/openvas_lsc_target_prep.h: New module with common functionality
+ for the package/installer generators.
+
+ * MANIFEST: Added the two new files.
+
+ * nessus/Makefile: Added object to UTIL_OBJS.
+
+ * src/util/Makefile: Added target for new module.
+
2009-05-18 Felix Wolfsteller <felix.wolfsteller at intevation.de>
* doc/Doxyfile: Turn EXTRACT_ALL off, to enable warnings about missing
Modified: trunk/openvas-client/MANIFEST
===================================================================
--- trunk/openvas-client/MANIFEST 2009-05-19 08:55:13 UTC (rev 3418)
+++ trunk/openvas-client/MANIFEST 2009-05-19 09:58:27 UTC (rev 3419)
@@ -237,6 +237,8 @@
src/util/openvas_lsc_user_deb.h
src/util/openvas_lsc_user_makensis.c
src/util/openvas_lsc_user_makensis.h
+src/util/openvas_lsc_target_prep.c
+src/util/openvas_lsc_target_prep.h
src/util/openvas_ssh_key_create.c
src/util/openvas_ssh_key_create.h
src/util/openvas_ssh_rpm.c
Modified: trunk/openvas-client/nessus/Makefile
===================================================================
--- trunk/openvas-client/nessus/Makefile 2009-05-19 08:55:13 UTC (rev 3418)
+++ trunk/openvas-client/nessus/Makefile 2009-05-19 09:58:27 UTC (rev 3419)
@@ -80,7 +80,8 @@
../src/util/severity_filter.o \
../src/openvas-lib/hash_table_file.o \
../src/util/openvas_lsc_user_makensis.o\
- ../src/util/openvas_lsc_user_deb.o
+ ../src/util/openvas_lsc_user_deb.o\
+ ../src/util/openvas_lsc_target_prep.o
all : cflags ${make_bindir}/$(NESSUSCLIENT)
Modified: trunk/openvas-client/src/util/Makefile
===================================================================
--- trunk/openvas-client/src/util/Makefile 2009-05-19 08:55:13 UTC (rev 3418)
+++ trunk/openvas-client/src/util/Makefile 2009-05-19 09:58:27 UTC (rev 3419)
@@ -49,7 +49,8 @@
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_lsc_user_deb.o
+ openvas_ssh_rpm.o openvas_lsc_user_makensis.o openvas_lsc_user_deb.o\
+ openvas_lsc_target_prep.o
all : cflags $(OBJS)
@@ -65,6 +66,9 @@
openvas_ssh_key_create.o: openvas_ssh_key_create.c openvas_ssh_key_create.h
$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c openvas_ssh_key_create.c
+openvas_lsc_target_prep.o: openvas_lsc_target_prep.c openvas_lsc_target_prep.h
+ $(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c openvas_lsc_target_prep.c
+
openvas_ssh_rpm.o: openvas_ssh_rpm.c openvas_ssh_rpm.h
$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -DOPENVASCLIENT_LSCRPMGEN_DIR=\"$(prefix)/lib/openvas\" -c openvas_ssh_rpm.c
Added: trunk/openvas-client/src/util/openvas_lsc_target_prep.c
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_target_prep.c 2009-05-19 08:55:13 UTC (rev 3418)
+++ trunk/openvas-client/src/util/openvas_lsc_target_prep.c 2009-05-19 09:58:27 UTC (rev 3419)
@@ -0,0 +1,116 @@
+/* OpenVAS-Client
+ * $Id$
+ * Description: Common functions for lsc target preparation (e.g. credentials
+ * package generation).
+ *
+ * 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.
+ */
+
+
+#include "error_dlg.h"
+#include "file_utils.h"
+#include "nessus_i18n.h"
+#include "openvas_lsc_target_prep.h"
+#include "openvas_ssh_login.h"
+#include "preferences.h" /* For prefs_get_nessushome */
+
+/**
+ * @brief Chars used with g_strcanon to produce valid file paths.
+ * (duplicate in ssh_key_info_form)
+ */
+#define LEGAL_FILENAME_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ1234567890_./"
+
+
+/**
+ * @brief Creates a temporary directory as working directory for installer and
+ * @brief package generators.
+ *
+ * Default directory is .openvas/.ssh/.tmprpm .
+ *
+ * @return Path to the temporary directory if directory successfully created or
+ * @return exists, NULL in case of error (and will show the error).
+ */
+gchar*
+openvas_lsc_target_prep_create_tmp_dir ()
+{
+ gchar* tmpdir = g_build_filename (prefs_get_nessushome(), ".openvas", ".ssh",
+ ".tmprpm", NULL);
+ if (file_utils_ensure_dir(tmpdir) == FALSE)
+ {
+ show_error ("Could not create temporary dir %s.", tmpdir);
+ g_free (tmpdir);
+ tmpdir = NULL;
+ }
+ return tmpdir;
+}
+
+
+/**
+ * @brief Creates a path for a installer or package for credentials for local
+ * @brief security checks.
+ *
+ * Installers will be placed to or read from this location. (Default
+ * $(HOME).openvas/lsc-credentials/openvas_lsc_target_preparation_accountname.extension)
+ *
+ * @param Name Name of the account (non-letters except for underscores and dots
+ * are replaced by underscores).
+ * @param extension File extension for this installer/package.
+ *
+ * @return Path to installer/package for given openvas_ssh_login, has to be
+ * freed using g_free, NULL in case of errors.
+ */
+gchar*
+openvas_lsc_target_prep_filename (const char* accountname,
+ const char* extension)
+{
+ gchar* filename;
+ gchar* dir;
+ gchar* path;
+
+ if (accountname == NULL || extension == NULL)
+ return NULL;
+
+ filename = g_strdup_printf ("openvas_lsc_target_preparation_%s.%s", accountname, extension);
+ g_strcanon (filename, LEGAL_FILENAME_CHARS, '_');
+
+ dir = g_build_filename (prefs_get_nessushome(), ".openvas", "lsc-credentials", NULL);
+ if (file_utils_ensure_dir (dir) == FALSE)
+ {
+ g_free (dir);
+ g_free (filename);
+ return NULL;
+ }
+
+ path = g_build_filename (dir, filename, NULL);
+ g_free (filename);
+ g_free (dir);
+ return path;
+}
Added: trunk/openvas-client/src/util/openvas_lsc_target_prep.h
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_target_prep.h 2009-05-19 08:55:13 UTC (rev 3418)
+++ trunk/openvas-client/src/util/openvas_lsc_target_prep.h 2009-05-19 09:58:27 UTC (rev 3419)
@@ -0,0 +1,48 @@
+/* OpenVAS-Client
+ * $Id$
+ * Description: Common functions for lsc target preparation (e.g. credentials
+ * package generation).
+ *
+ * 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_TARGET_PREP_H
+#define _OPENVAS_LSC_TARGET_PREP_H
+
+#include "openvas_ssh_login.h"
+#define LEGAL_FILENAME_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ1234567890_./"
+
+gchar* openvas_lsc_target_prep_create_tmp_dir ();
+
+gchar* openvas_lsc_target_prep_filename (const char* accountname,
+ const char* extension);
+
+#endif /* _OPENVAS_LSC_TARGET_PREP_H */
More information about the Openvas-commits
mailing list