[Openvas-commits] r3422 - in trunk/openvas-client: . src/gui src/util
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue May 19 12:08:31 CEST 2009
Author: felix
Date: 2009-05-19 12:08:31 +0200 (Tue, 19 May 2009)
New Revision: 3422
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/src/gui/ssh_key_info_form.c
trunk/openvas-client/src/util/openvas_lsc_user_deb.c
trunk/openvas-client/src/util/openvas_lsc_user_deb.h
trunk/openvas-client/src/util/openvas_lsc_user_makensis.c
trunk/openvas-client/src/util/openvas_lsc_user_makensis.h
trunk/openvas-client/src/util/openvas_ssh_rpm.c
trunk/openvas-client/src/util/openvas_ssh_rpm.h
Log:
Execute alien as fakeroot, use extracted module to fetch file names for
'credential installer/packages'.
* src/util/openvas_lsc_user_deb.c,
src/util/openvas_lsc_user_deb.h (openvas_lsc_user_deb_filename),
src/util/openvas_lsc_user_makensis.c,
src/util/openvas_lsc_user_makensis.h
(openvas_lsc_user_makensis_filename),
src/util/openvas_ssh_rpm.c,
src/util/openvas_ssh_rpm.h (openvas_ssh_rpm_filename):
Include new module openvas_lsc_target_prep, use its function for
filename generation, changed signature to take char*, corrected
documentation.
* src/util/openvas_lsc_user_deb.c (execute_alien): Execute alien with
fakeroot.
* src/gui/ssh_key_info_form.c (ssh_key_info_form_fill,
name_typed_in_cb):
Call functions to get filenames with new signature.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/ChangeLog 2009-05-19 10:08:31 UTC (rev 3422)
@@ -1,5 +1,28 @@
2009-05-19 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ Execute alien as fakeroot, use extracted module to fetch file names for
+ 'credential installer/packages'.
+
+ * src/util/openvas_lsc_user_deb.c,
+ src/util/openvas_lsc_user_deb.h (openvas_lsc_user_deb_filename),
+ src/util/openvas_lsc_user_makensis.c,
+ src/util/openvas_lsc_user_makensis.h
+ (openvas_lsc_user_makensis_filename),
+ src/util/openvas_ssh_rpm.c,
+ src/util/openvas_ssh_rpm.h (openvas_ssh_rpm_filename):
+ Include new module openvas_lsc_target_prep, use its function for
+ filename generation, changed signature to take char*, corrected
+ documentation.
+
+ * src/util/openvas_lsc_user_deb.c (execute_alien): Execute alien with
+ fakeroot.
+
+ * src/gui/ssh_key_info_form.c (ssh_key_info_form_fill,
+ name_typed_in_cb):
+ Call functions to get filenames with new signature.
+
+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).
Modified: trunk/openvas-client/src/gui/ssh_key_info_form.c
===================================================================
--- trunk/openvas-client/src/gui/ssh_key_info_form.c 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/gui/ssh_key_info_form.c 2009-05-19 10:08:31 UTC (rev 3422)
@@ -40,17 +40,14 @@
#include <gtk/gtk.h>
#include "context.h" /* for check_is_file */
#include "error_dlg.h"
-#include "openvas_lsc_user_deb.h" /* for openvas_lsc_user_deb_alien_found () */
-#include "openvas_lsc_user_makensis.h" /* for openvas_lsc_user_makensis_found () */
-#include "openvas_ssh_rpm.h" /* for openvas_lsc_rpm_generator_found () */
+#include "openvas_lsc_target_prep.h"
+#include "openvas_lsc_user_deb.h" /* for openvas_lsc_user_deb_alien_found and _filename */
+#include "openvas_lsc_user_makensis.h" /* for openvas_lsc_user_makensis_found and _filename */
+#include "openvas_ssh_rpm.h" /* for openvas_lsc_rpm_generator_found and _filename */
#include "openvas_ssh_login.h"
#include "preferences.h"
#include "ssh_key_info_form.h"
-/**
- * @brief Chars used with g_strcanon to produce valid file paths.
- */
-#define LEGAL_FILENAME_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ1234567890_./"
/**
* @brief Fills a ssh_key_info_form with values of a openvas_ssh_login struct
@@ -66,6 +63,8 @@
void
ssh_key_info_form_fill(ssh_key_info_form* form, openvas_ssh_login* loginfo)
{
+ gchar* credentials_path;
+
if(loginfo == NULL)
{
gtk_entry_set_text(GTK_ENTRY(form->name), "");
@@ -90,29 +89,30 @@
gtk_entry_set_text(GTK_ENTRY(form->ssh_key_passphrase), loginfo->ssh_key_passphrase);
// Exchange file extensions
- gchar* loc = g_strdup (loginfo->public_key_path);
- g_strlcpy (strrchr(loc, '.') + 1, "rpm", 4);
+ credentials_path = openvas_ssh_rpm_filename (loginfo->name);
- if (check_is_file (loc) == 0)
+ if (check_is_file (credentials_path) == 0)
gtk_entry_set_text (GTK_ENTRY(form->rpm_location), "-- rpm not found --");
else
- gtk_entry_set_text(GTK_ENTRY(form->rpm_location), loc);
+ gtk_entry_set_text(GTK_ENTRY(form->rpm_location), credentials_path);
- g_strlcpy (strrchr(loc, '.') + 1, "deb", 4);
+ g_free (credentials_path);
+ credentials_path = openvas_lsc_user_deb_filename (loginfo->name);
- if (check_is_file (loc) == 0)
+ if (check_is_file (credentials_path) == 0)
gtk_entry_set_text (GTK_ENTRY(form->deb_location), "-- deb not found --");
else
- gtk_entry_set_text(GTK_ENTRY(form->deb_location), loc);
+ gtk_entry_set_text(GTK_ENTRY(form->deb_location), credentials_path);
- g_strlcpy (strrchr(loc, '.') + 1, "exe", 4);
+ g_free (credentials_path);
+ credentials_path = openvas_lsc_user_makensis_filename (loginfo->name);
- if (check_is_file (loc) == 0)
+ if (check_is_file (credentials_path) == 0)
gtk_entry_set_text (GTK_ENTRY(form->exe_location), "-- exe not found --");
else
- gtk_entry_set_text(GTK_ENTRY(form->exe_location), loc);
+ gtk_entry_set_text(GTK_ENTRY(form->exe_location), credentials_path);
- g_free (loc);
+ g_free (credentials_path);
}
gtk_entry_set_editable(GTK_ENTRY(form->name), FALSE);
@@ -141,38 +141,38 @@
static void
name_typed_in_cb(GtkEntry *entry, ssh_key_info_form* form)
{
- const char* name = gtk_entry_get_text(entry);
+ const char* name = gtk_entry_get_text(entry);
- char* home = prefs_get_nessushome();
+ char* home = prefs_get_nessushome();
- gchar* pubkey_path = g_strdup_printf("%s/.openvas/.ssh/%s.pub", home, name);
- gchar* privkey_path = g_strdup_printf("%s/.openvas/.ssh/%s.p8", home, name);
+ gchar* canoname = g_strdup (name);
- // Instead of using g_strcanon, g_build_filename () could be used.
- gtk_entry_set_text(GTK_ENTRY(form->public_key_path),
- g_strcanon( pubkey_path, LEGAL_FILENAME_CHARS, '_'));
- gtk_entry_set_text(GTK_ENTRY(form->private_key_path),
- g_strcanon( privkey_path, LEGAL_FILENAME_CHARS, '_'));
+ g_strcanon (canoname, LEGAL_FILENAME_CHARS, '_');
- if (openvas_lsc_user_deb_alien_found() == TRUE)
+ gchar* pubkey_path = g_strdup_printf("%s/.openvas/.ssh/%s.pub", home, canoname);
+ gchar* privkey_path = g_strdup_printf("%s/.openvas/.ssh/%s.p8", home, canoname);
+
+ gtk_entry_set_text(GTK_ENTRY(form->public_key_path), pubkey_path);
+ gtk_entry_set_text(GTK_ENTRY(form->private_key_path), privkey_path);
+
+ if (openvas_ssh_rpm_generator_found() == TRUE)
{
- gchar* deb_path = g_strdup_printf("%s/.openvas/.ssh/%s.deb", home, name);
- gtk_entry_set_text (GTK_ENTRY(form->deb_location),
- g_strcanon (deb_path, LEGAL_FILENAME_CHARS, '_'));
- g_free (deb_path);
+ gchar* rpm_path = openvas_ssh_rpm_filename (canoname);
+ gtk_entry_set_text (GTK_ENTRY(form->rpm_location), rpm_path);
+ g_free (rpm_path);
+ // Can build deb from rpm only if can build rpm
+ if (openvas_lsc_user_deb_alien_found() == TRUE)
+ {
+ gchar* deb_path = openvas_lsc_user_deb_filename (canoname);
+ gtk_entry_set_text (GTK_ENTRY(form->deb_location),
+ g_strcanon (deb_path, LEGAL_FILENAME_CHARS, '_'));
+ g_free (deb_path);
+ }
}
- if (openvas_ssh_rpm_generator_found() == TRUE)
- {
- gchar* rpm_path = g_strdup_printf("%s/.openvas/.ssh/%s.rpm", home, name);
- gtk_entry_set_text (GTK_ENTRY(form->rpm_location),
- g_strcanon (rpm_path, LEGAL_FILENAME_CHARS, '_'));
- g_free (rpm_path);
- }
-
if (openvas_lsc_user_makensis_found() == TRUE)
{
- gchar* exe_path = g_strdup_printf("%s/.openvas/.ssh/%s.exe", home, name);
+ gchar* exe_path = openvas_lsc_user_makensis_filename (canoname);
gtk_entry_set_text (GTK_ENTRY(form->exe_location),
g_strcanon (exe_path, LEGAL_FILENAME_CHARS, '_'));
g_free (exe_path);
Modified: trunk/openvas-client/src/util/openvas_lsc_user_deb.c
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_deb.c 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/util/openvas_lsc_user_deb.c 2009-05-19 10:08:31 UTC (rev 3422)
@@ -55,6 +55,7 @@
#include "preferences.h" /* For prefs_get_nessushome */
#include "context.h" /* For check_is_dir (!) and context_remove_directory (!): @TODO */
#include "openvas_lsc_user_deb.h"
+#include "openvas_lsc_target_prep.h"
#include "openvas_ssh_rpm.h" /* for openvas_ssh_rpm_filename */
/**
@@ -67,12 +68,14 @@
gchar** cmd;
gint exit_status;
- cmd = (gchar **) g_malloc (4 * sizeof (gchar *));
+ cmd = (gchar **) g_malloc (6 * sizeof (gchar *));
- cmd[0] = g_strdup ("alien");
- cmd[1] = g_strdup ("--scripts");
- cmd[2] = g_strdup (rpmfile);
- cmd[3] = NULL;
+ cmd[0] = g_strdup ("fakeroot");
+ cmd[1] = g_strdup ("--");
+ cmd[2] = g_strdup ("alien");
+ cmd[3] = g_strdup ("--scripts");
+ cmd[4] = g_strdup (rpmfile);
+ cmd[5] = NULL;
printf ("--- executing alien.\n");
if (g_spawn_sync (".",
cmd,
@@ -94,6 +97,9 @@
g_free (cmd[0]);
g_free (cmd[1]);
g_free (cmd[2]);
+ g_free (cmd[3]);
+ g_free (cmd[4]);
+ g_free (cmd[5]);
g_free (cmd);
printf ("--- alien returned %d.\n", exit_status);
@@ -133,22 +139,15 @@
* @brief openvas_ssh_login.
*
* Installers will be placed to or read from this location. It equals the path
- * to the public key but with a different file extension (.rpm).
+ * to the public key but with a different file extension (.deb).
*
* @return Path to installer for given openvas_ssh_login, has to be freed using
* g_free, NULL in case of errors.
*/
gchar*
-openvas_lsc_user_deb_filename (const openvas_ssh_login* loginfo)
+openvas_lsc_user_deb_filename (const char* accountname)
{
- if ( loginfo == NULL || loginfo->public_key_path == NULL
- || strrchr(loginfo->public_key_path, '.') == NULL)
- return NULL;
-
- // Exchange file extensions
- gchar* loc = g_strdup (loginfo->public_key_path);
- g_strlcpy (strrchr(loc, '.') + 1, "deb", 4);
- return loc;
+ return openvas_lsc_target_prep_filename (accountname, "deb");
}
Modified: trunk/openvas-client/src/util/openvas_lsc_user_deb.h
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_deb.h 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/util/openvas_lsc_user_deb.h 2009-05-19 10:08:31 UTC (rev 3422)
@@ -42,7 +42,7 @@
gboolean openvas_lsc_user_deb (openvas_ssh_login* loginfo,
const gchar* to_filename);
-gchar* openvas_lsc_user_deb_filename (const openvas_ssh_login* loginfo);
+gchar* openvas_lsc_user_deb_filename (const char* loginfo);
gboolean openvas_lsc_user_deb_alien_found ();
Modified: trunk/openvas-client/src/util/openvas_lsc_user_makensis.c
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_makensis.c 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/util/openvas_lsc_user_makensis.c 2009-05-19 10:08:31 UTC (rev 3422)
@@ -65,8 +65,10 @@
#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_target_prep.h"
#include "openvas_lsc_user_makensis.h"
+
/** @TODO code duplicate of openvas_ssh_rpm.c */
/**
* @brief Creates a temporary directory to place copy of key and as working
@@ -251,22 +253,15 @@
* @brief Returns the path to installer for a given openvas_ssh_login.
*
* Installers will be placed to or read from this location. It equals the path
- * to the public key but with a different file extension (.rpm).
+ * to the public key but with a different file extension (.exe).
*
* @return Path to installer for given openvas_ssh_login, has to be freed using
* g_free, NULL in case of errors.
*/
gchar*
-openvas_lsc_user_makensis_filename (const openvas_ssh_login* loginfo)
+openvas_lsc_user_makensis_filename (const char* accountname)
{
- if ( loginfo == NULL || loginfo->public_key_path == NULL
- || strrchr(loginfo->public_key_path, '.') == NULL)
- return NULL;
-
- // Exchange file extensions
- gchar* loc = g_strdup (loginfo->public_key_path);
- g_strlcpy (strrchr(loc, '.') + 1, "exe", 4);
- return loc;
+ return openvas_lsc_target_prep_filename (accountname, "exe");
}
/**
Modified: trunk/openvas-client/src/util/openvas_lsc_user_makensis.h
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_makensis.h 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/util/openvas_lsc_user_makensis.h 2009-05-19 10:08:31 UTC (rev 3422)
@@ -43,7 +43,7 @@
gboolean openvas_lsc_user_makensis (openvas_ssh_login* loginfo,
const gchar* to_filename);
-gchar* openvas_lsc_user_makensis_filename (const openvas_ssh_login* loginfo);
+gchar* openvas_lsc_user_makensis_filename (const char* loginfo);
gboolean openvas_lsc_user_makensis_found ();
Modified: trunk/openvas-client/src/util/openvas_ssh_rpm.c
===================================================================
--- trunk/openvas-client/src/util/openvas_ssh_rpm.c 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/util/openvas_ssh_rpm.c 2009-05-19 10:08:31 UTC (rev 3422)
@@ -42,6 +42,7 @@
#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_target_prep.h"
#include "openvas_ssh_rpm.h"
/**
@@ -117,16 +118,9 @@
* g_free, NULL in case of errors.
*/
gchar*
-openvas_ssh_rpm_filename (const openvas_ssh_login* loginfo)
+openvas_ssh_rpm_filename (const char* accountname)
{
- if ( loginfo == NULL || loginfo->public_key_path == NULL
- || strrchr(loginfo->public_key_path, '.') == NULL)
- return NULL;
-
- // Exchange file extensions
- gchar* loc = g_strdup (loginfo->public_key_path);
- g_strlcpy (strrchr(loc, '.') + 1, "rpm", 4);
- return loc;
+ return openvas_lsc_target_prep_filename (accountname, "rpm");
}
/**
Modified: trunk/openvas-client/src/util/openvas_ssh_rpm.h
===================================================================
--- trunk/openvas-client/src/util/openvas_ssh_rpm.h 2009-05-19 10:06:42 UTC (rev 3421)
+++ trunk/openvas-client/src/util/openvas_ssh_rpm.h 2009-05-19 10:08:31 UTC (rev 3422)
@@ -43,7 +43,7 @@
gboolean openvas_ssh_rpm_create (openvas_ssh_login* loginfo,
const gchar* to_filename);
-gchar* openvas_ssh_rpm_filename (const openvas_ssh_login* loginfo);
+gchar* openvas_ssh_rpm_filename (const char* loginfo);
gboolean openvas_ssh_rpm_generator_found ();
More information about the Openvas-commits
mailing list