[Openvas-commits] r3354 - in trunk/openvas-client: . src/gui src/util

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 13 12:10:04 CEST 2009


Author: felix
Date: 2009-05-13 12:10:04 +0200 (Wed, 13 May 2009)
New Revision: 3354

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/src/gui/ssh_keys_dialog.c
   trunk/openvas-client/src/util/openvas_lsc_user_makensis.c
Log:
Better wording and catching the case where credentials export
functionality is attempted to be used before any credentials
were created.
Changed the nsi installer script with Thomas Rotters help to find out
the Administrators group name at runtime.

* src/gui/ssh_keys_dialog.c (ssh_keys_dialog_create_rpm_click,
 ssh_keys_dialog_create_exe_click): Better wording, internationalization
 catch situations where no account has yet been created.

* src/util/openvas_lsc_user_makensis.c (create_nsi_file): Changed
resulting nsi file so that the generated installer will during execution
time create two scripts and execute these. Big Thanks to Thomas Rotter
who helped with the scripts and advises regarding the MS WIN shell.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-05-13 09:42:49 UTC (rev 3353)
+++ trunk/openvas-client/ChangeLog	2009-05-13 10:10:04 UTC (rev 3354)
@@ -1,3 +1,20 @@
+2009-05-13  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
+	Better wording and catching the case where credentials export
+	functionality is attempted to be used before any credentials
+	were created.
+	Changed the nsi installer script with Thomas Rotters help to find out
+	the Administrators group name at runtime.
+
+	* src/gui/ssh_keys_dialog.c (ssh_keys_dialog_create_rpm_click,
+	 ssh_keys_dialog_create_exe_click): Better wording, internationalization
+	catch situations where no account has yet been created.
+	
+	* src/util/openvas_lsc_user_makensis.c (create_nsi_file): Changed
+	resulting nsi file so that the generated installer will during execution
+	time create two scripts and execute these. Big Thanks to Thomas Rotter
+	who helped with the scripts and advises regarding the MS WIN shell.
+
 2009-05-06  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
 	Updated rpm generator script - created from

Modified: trunk/openvas-client/src/gui/ssh_keys_dialog.c
===================================================================
--- trunk/openvas-client/src/gui/ssh_keys_dialog.c	2009-05-13 09:42:49 UTC (rev 3353)
+++ trunk/openvas-client/src/gui/ssh_keys_dialog.c	2009-05-13 10:10:04 UTC (rev 3354)
@@ -263,13 +263,18 @@
 {
   /** @TODO Following code duplicate of create_rpm_ click, refactor. */
   const char* selected_account = listnotebook_get_selected (notebook);
+  if (selected_account == NULL || !strcmp(selected_account, STR_NO_LOGINS_YET))
+    {
+      show_info (_("No credentials selected to create installer for."));
+      return;
+    }
   openvas_ssh_login* login = g_hash_table_lookup(Global->sshkeys, selected_account);
   GtkWidget* file_chooser;
   gchar* filename;
 
   if (login == NULL)
     {
-      show_error ("Cannot find credentials to create RPM for.");
+      show_error (_("Cannot find credentials to create installer for."));
       return;
     }
 
@@ -311,13 +316,18 @@
 ssh_keys_dialog_create_rpm_click (GtkWidget* parent, GtkWidget* notebook)
 {
   const char* selected_account = listnotebook_get_selected (notebook);
+  if (selected_account == NULL || !strcmp(selected_account, STR_NO_LOGINS_YET))
+    {
+      show_info (_("No credentials selected to create RPM for."));
+      return;
+    }
   openvas_ssh_login* login = g_hash_table_lookup(Global->sshkeys, selected_account);
   GtkWidget* file_chooser;
   gchar* filename;
 
   if (login == NULL)
     {
-      show_error ("Cannot find credentials to create RPM for.");
+      show_error (_("Cannot find credentials to create RPM for."));
       return;
     }
 
@@ -340,7 +350,7 @@
   filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
 
   if (openvas_ssh_rpm_create (login, filename) == TRUE)
-    show_info (_("RPM Creation likely succeeded.\n"));
+    show_info (_("RPM Creation succeeded.\n"));
   else
     show_error (_("RPM Creation failed\n"));
 

Modified: trunk/openvas-client/src/util/openvas_lsc_user_makensis.c
===================================================================
--- trunk/openvas-client/src/util/openvas_lsc_user_makensis.c	2009-05-13 09:42:49 UTC (rev 3353)
+++ trunk/openvas-client/src/util/openvas_lsc_user_makensis.c	2009-05-13 10:10:04 UTC (rev 3354)
@@ -118,6 +118,8 @@
   fprintf (fd, "BrandingText \"OpenVAS Local Security Checks User\"\n\n");
 
   // For ms vista installers we need the UAC plugin and use the following lines:
+  // This requires the user to have the UAC plugin installed and to provide the
+  // the path to it.
   //fprintf (fd, "# Request application privileges for Windows Vista\n");
   //fprintf (fd, "RequestExecutionLevel admin\n\n");
 
@@ -131,15 +133,34 @@
   fprintf (fd, "writeUninstaller $INSTDIR\\openvas_lsc_remove_%s.exe\n\n",
                loginfo->username);
 
-  fprintf (fd, "# Run cmd to add user and give it admin rights\n");
-  /** @TODO pick up return value, fail with a message if bad */
+  // Need to find localized Administrators group name, create a
+  // GetAdminGroupName - vb script (Thanks to Thomas Rotter)
+  fprintf (fd, "# Create Thomas Rotters GetAdminGroupName.vb script\n");
+  fprintf (fd, "ExecWait \"cmd /C Echo Set objWMIService = GetObject($\\\"winmgmts:\\\\.\\root\\cimv2$\\\") > $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\" \"\n");
+  fprintf (fd, "ExecWait \"cmd /C Echo Set colAccounts = objWMIService.ExecQuery ($\\\"Select * From Win32_Group Where SID = 'S-1-5-32-544'$\\\")  >> $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\"\"\n");
+  fprintf (fd, "ExecWait \"cmd /C Echo For Each objAccount in colAccounts >> $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\"\"\n");
+  fprintf (fd, "ExecWait \"cmd /C Echo Wscript.Echo objAccount.Name >> $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\"\"\n");
+  fprintf (fd, "ExecWait \"cmd /C Echo Next >> $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\"\"\n");
+  fprintf (fd, "ExecWait \"cmd /C cscript //nologo $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\" > $\\\"%%temp%%\\AdminGroupName.txt$\\\"\"\n\n");
+
   /** @TODO provide /comment:"OpenVAS User" /fullname:"OpenVAS Testuser" */
-  fprintf (fd, "ExecWait \"net user %s %s /add /active:yes\"\n",
+  fprintf (fd, "# Create batch script that installs the user\n");
+  fprintf (fd, "ExecWait \"cmd /C Echo Set /P AdminGroupName= ^<$\\\"%%temp%%\\AdminGroupName.txt$\\\" > $\\\"%%temp%%\\AddUser.bat$\\\"\" \n");
+  fprintf (fd, "ExecWait \"cmd /C Echo net user %s %s /add /active:yes >> $\\\"%%temp%%\\AddUser.bat$\\\"\"\n",
                loginfo->username, loginfo->userpassword);
-  fprintf (fd, "ExecWait \"net localgroup Administrators %%COMPUTERNAME%%\\%s /add\"\n\n",
-               loginfo->username);
+  fprintf (fd, "ExecWait \"cmd /C Echo net localgroup %%AdminGroupName%% %%COMPUTERNAME%%\\%s /add >> $\\\"%%temp%%\\AddUser.bat$\\\"\"\n\n",
+                loginfo->username);
 
-  // Display note about NTLM and SMB signing and encryptio
+  fprintf (fd, "# Execute AddUser script\n");
+  fprintf (fd, "ExecWait \"cmd /C $\\\"%%temp%%\\AddUser.bat$\\\"\"\n\n");
+
+  // Remove up temporary files for localized Administrators group names
+  fprintf (fd, "# Remove temporary files for localized admin group names\n");
+  fprintf (fd, "ExecWait \"del $\\\"%%temp%%\\AdminGroupName.txt$\\\"\"\n");
+  fprintf (fd, "ExecWait \"del $\\\"%%temp%%\\GetAdminGroupName.vbs$\\\"\"\n\n");
+  fprintf (fd, "ExecWait \"del $\\\"%%temp%%\\AddUser.bat$\\\"\"\n\n");
+
+  /** @TODO Display note about NTLM and SMB signing and encryption, 'Easy Filesharing' in WIN XP */
   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");
 
@@ -151,7 +172,6 @@
   fprintf (fd, "section \"Uninstall\"\n\n");
 
   fprintf (fd, "# Run cmd to remove user\n");
-  /** TODO pick up return value, fail with a message if bad */
   fprintf (fd, "ExecWait \"net user %s /delete\"\n\n",
                loginfo->username);
 
@@ -196,8 +216,8 @@
                     NULL                 ) == FALSE
       || exit_status != 0)
     {
-      show_error(_("Error (%d) creating the rpm with.\n"
-                   "For further information consult your shell."), exit_status, cmd);
+      show_error(_("Error (%d) creating the executable.\n"
+                   "For further information consult your shell."), exit_status);
       exit_status = -1;
     }
 
@@ -236,14 +256,15 @@
 gboolean
 openvas_lsc_user_makensis (openvas_ssh_login* loginfo, const gchar* to_filename)
 {
-  gboolean success = FALSE;
-  int rmdir_response;
+  gboolean success   = FALSE;
+  int rmdir_response = TRUE;
 
   gchar* tmpdir  = create_tmp_dir ();
   gchar* nsifile = g_build_filename (tmpdir, "lsc_user_installer.nsi", NULL);
   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."),



More information about the Openvas-commits mailing list