[Openvas-commits] r3254 - in trunk/openvas-client: . src/gui src/util
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed May 6 12:37:27 CEST 2009
Author: felix
Date: 2009-05-06 12:37:26 +0200 (Wed, 06 May 2009)
New Revision: 3254
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/src/gui/ssh_keys_dialog.c
trunk/openvas-client/src/util/openvas_lsc_user_makensis.c
trunk/openvas-client/src/util/openvas_lsc_user_makensis.h
Log:
Improved "user-installer" functionality.
* src/util/openvas_lsc_user_makensis.c (create_nsi_file): Thanks to
Thomas Rotter, give the user admin rights. Display messages. Some parts
adopted from winslads installer (thanks to Dirk Jagdmann).
* src/util/openvas_lsc_user_makensis.c,
src/util/openvas_lsc_user_makensis.h
(openvas_lsc_user_makensis_found): New, checks for presence of makensis
in path.
* src/util/openvas_lsc_user_makensis.c (openvas_lsc_user_makensis):
Better error checking and handling, removes temporary directory when
done.
* src/gui/gui/ssh_keys_dialog.c (ssh_keys_dialog_create_exe_click):
Checks for presence of makensis in path, display messages if failed.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-05-06 10:29:40 UTC (rev 3253)
+++ trunk/openvas-client/ChangeLog 2009-05-06 10:37:26 UTC (rev 3254)
@@ -1,5 +1,25 @@
2009-05-06 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ Improved "user-installer" functionality.
+
+ * src/util/openvas_lsc_user_makensis.c (create_nsi_file): Thanks to
+ Thomas Rotter, give the user admin rights. Display messages. Some parts
+ adopted from winslads installer (thanks to Dirk Jagdmann).
+
+ * src/util/openvas_lsc_user_makensis.c,
+ src/util/openvas_lsc_user_makensis.h
+ (openvas_lsc_user_makensis_found): New, checks for presence of makensis
+ in path.
+
+ * src/util/openvas_lsc_user_makensis.c (openvas_lsc_user_makensis):
+ Better error checking and handling, removes temporary directory when
+ done.
+
+ * src/gui/gui/ssh_keys_dialog.c (ssh_keys_dialog_create_exe_click):
+ Checks for presence of makensis in path, display messages if failed.
+
+2009-05-06 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
* src/util/file_utils.c, src/util/file_utils.h (file_utils_rmdir_rf):
New (copied from openvas-config-manager/src/openvascd.c).
Modified: trunk/openvas-client/src/gui/ssh_keys_dialog.c
===================================================================
--- trunk/openvas-client/src/gui/ssh_keys_dialog.c 2009-05-06 10:29:40 UTC (rev 3253)
+++ trunk/openvas-client/src/gui/ssh_keys_dialog.c 2009-05-06 10:37:26 UTC (rev 3254)
@@ -291,9 +291,16 @@
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
- // create nsi, makensis
- // if(
- openvas_lsc_user_makensis (login, filename);
+ if (openvas_lsc_user_makensis_found ())
+ {
+ if (openvas_lsc_user_makensis (login, filename) == FALSE)
+ show_error (_("Creation of a user-install-executable failed."));
+ else
+ show_info (_("Creation of a user-install-executable successful."));
+ }
+ else
+ show_info (_("To use this function you need to have nsis (http://nsis.sourceforge.net/) installed.\n"));
+
gtk_widget_destroy (file_chooser);
}
Modified: trunk/openvas-client/src/util/openvas_lsc_user_makensis.c
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_makensis.c 2009-05-06 10:29:40 UTC (rev 3253)
+++ trunk/openvas-client/src/util/openvas_lsc_user_makensis.c 2009-05-06 10:37:26 UTC (rev 3254)
@@ -114,9 +114,15 @@
fprintf (fd, "# Set desktop as install directory\n");
fprintf (fd, "installDir $DESKTOP\n\n");
+ fprintf (fd, "# Put some text\n");
+ fprintf (fd, "BrandingText \"OpenVAS Local Security Checks User\"\n\n");
+
+ // For ms vista installers we need the UAC plugin and use the following lines:
+ //fprintf (fd, "# Request application privileges for Windows Vista\n");
+ //fprintf (fd, "RequestExecutionLevel admin\n\n");
+
fprintf (fd, "#\n# Default (installer) section.\n#\n");
fprintf (fd, "section\n\n");
- /** TODO check if we have admin rights, fail with a message if not */
fprintf (fd, "# Define output path\n");
fprintf (fd, "setOutPath $INSTDIR\n\n");
@@ -125,12 +131,17 @@
fprintf (fd, "writeUninstaller $INSTDIR\\openvas_lsc_remove_%s.exe\n\n",
loginfo->username);
- fprintf (fd, "# Run cmd to add user\n");
- /** TODO pick up return value, fail with a message if bad */
- fprintf (fd, "ExecWait \"net user %s %s /add /active:yes\"\n\n",
+ fprintf (fd, "# Run cmd to add user and give it admin rights\n");
+ /** @TODO pick up return value, fail with a message if bad */
+ /** @TODO provide /comment:"OpenVAS User" /fullname:"OpenVAS Testuser" */
+ fprintf (fd, "ExecWait \"net user %s %s /add /active:yes\"\n",
loginfo->username, loginfo->userpassword);
+ fprintf (fd, "ExecWait \"net localgroup Administrators %%COMPUTERNAME%%\\%s /add\"\n\n",
+ loginfo->username);
- /** TODO Display message that everything seems to be fine */
+ // Display note about NTLM and SMB signing and encryptio
+ fprintf (fd, "# Display message that everything seems to be fine\n");
+ fprintf (fd, "messageBox MB_OK \"A user has been added. An uninstaller is placed on your Desktop.\"\n\n");
fprintf (fd, "# Default (install) section end\n");
fprintf (fd, "sectionEnd\n\n");
@@ -147,12 +158,15 @@
/** @TODO Uninstaller should remove itself */
fprintf (fd, "# Unistaller should remove itself (from desktop/installdir)\n\n");
+ fprintf (fd, "# Display message that everything seems to be fine\n");
+ fprintf (fd, "messageBox MB_OK \"A user has been removed. You can now savely remmove the uninstaller from your Desktop.\"\n\n");
+
fprintf (fd, "# Uninstaller section end\n");
fprintf (fd, "sectionEnd\n\n");
fclose (fd);
- return FALSE;
+ return TRUE;
}
/**
@@ -197,6 +211,22 @@
}
/**
+ * @brief Returns whether makensis could be found in the path.
+ * @return true if makensis could be found in the path, false otherwise.
+ */
+gboolean
+openvas_lsc_user_makensis_found ()
+{
+ gboolean found;
+ // Check if makensis is found in path
+ gchar* makensis_path = g_find_program_in_path ("makensis");
+
+ found = (makensis_path != NULL);
+ g_free (makensis_path);
+ return found;
+}
+
+/**
* @brief Attempts creation of RPM packages to install a users public key file.
*
* @param loginfo openvas_ssh_login struct to create rpm for.
@@ -207,20 +237,18 @@
openvas_lsc_user_makensis (openvas_ssh_login* loginfo, const gchar* to_filename)
{
gboolean success = FALSE;
- /*
- // Check if makensis is found in path
- gchar* makensis_path = g_find_program_in_path ("makensis");
+ int rmdir_response;
- if (makensis_path == NULL)
- {
- show_error ("makensis not found.");
- return FALSE;
- }
- */
gchar* tmpdir = create_tmp_dir ();
gchar* nsifile = g_build_filename (tmpdir, "lsc_user_installer.nsi", NULL);
- create_nsi_file (nsifile, loginfo, to_filename);
- success = execute_makensis (nsifile);
- /** @TODO delete tmp dir and contents */
+ success = create_nsi_file (nsifile, loginfo, to_filename);
+ if (success)
+ success = execute_makensis (nsifile);
+ rmdir_response = file_utils_rmdir_rf (tmpdir);
+ if (rmdir_response != 0 && success)
+ show_error (_("The directory %s could not be deleted.\nIt might contain provided credential data as plain text, so removal is suggested."),
+ tmpdir);
+ g_free (tmpdir);
+
return success;
}
Modified: trunk/openvas-client/src/util/openvas_lsc_user_makensis.h
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_makensis.h 2009-05-06 10:29:40 UTC (rev 3253)
+++ trunk/openvas-client/src/util/openvas_lsc_user_makensis.h 2009-05-06 10:37:26 UTC (rev 3254)
@@ -43,4 +43,6 @@
gboolean openvas_lsc_user_makensis (openvas_ssh_login* loginfo,
const gchar* to_filename);
+gboolean openvas_lsc_user_makensis_found ();
+
#endif /* _OPENVAS_LSC_NSI_EXPORT_H */
More information about the Openvas-commits
mailing list