[Openvas-commits] r2599 - in trunk/openvas-client: . src/gui src/openvas-lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 27 09:17:15 CET 2009


Author: felix
Date: 2009-02-27 09:17:13 +0100 (Fri, 27 Feb 2009)
New Revision: 2599

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/src/gui/ssh_key_info_form.c
   trunk/openvas-client/src/gui/ssh_key_info_form.h
   trunk/openvas-client/src/openvas-lib/openvas_ssh_login.c
   trunk/openvas-client/src/openvas-lib/openvas_ssh_login.h
Log:
Added client-side support for username/password authentification using
the OpenVAS SSH Key Manager. GUI is extended by a password text entry,
value is saved in .ssh/.logins. The current server will ignore these
values (per-host user/password logins will not work yet).

* src/openvas-lib/openvas_ssh_login.h: Added new member userpassword,
adjusted the prototype to create a new login.

* src/openvas-lib/openvas_ssh_login.c: Added new keyword for key file
that saves the information for logins, respect the new userpassword.

* src/openvas-lib/openvas_ssh_login.c (openvas_ssh_login_file_read):
Ignore error if keyword for password not found in keyfile (allows
seamless migration from older .logins).

* src/gui/ssh_key_info_form.h: Added new member (text entry for
password) to the ssh_key_info_form struct.

* src/gui/ssh_key_info_form.c: Extended GUI by text-entry for text
entry.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-02-27 08:08:04 UTC (rev 2598)
+++ trunk/openvas-client/ChangeLog	2009-02-27 08:17:13 UTC (rev 2599)
@@ -1,5 +1,28 @@
 2009-02-27  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Added client-side support for username/password authentification using
+	the OpenVAS SSH Key Manager. GUI is extended by a password text entry,
+	value is saved in .ssh/.logins. The current server will ignore these
+	values.
+	
+	* src/openvas-lib/openvas_ssh_login.h: Added new member userpassword,
+	adjusted the prototype to create a new login.
+
+	* src/openvas-lib/openvas_ssh_login.c: Added new keyword for key file
+	that saves the information for logins, respect the new userpassword.
+	
+	* src/openvas-lib/openvas_ssh_login.c (openvas_ssh_login_file_read):
+	Ignore error if keyword for password not found in keyfile (allows
+	seamless migration from older .logins).
+	
+	* src/gui/ssh_key_info_form.h: Added new member (text entry for
+	password) to the ssh_key_info_form struct.
+
+	* src/gui/ssh_key_info_form.c: Extended GUI by text-entry for text
+	entry.
+	
+2009-02-27  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	Improved doc in ssh_key_info_form module.
 
 	* src/gui/ssh_key_info_form.c: Improved doc and readability of doc.

Modified: trunk/openvas-client/src/gui/ssh_key_info_form.c
===================================================================
--- trunk/openvas-client/src/gui/ssh_key_info_form.c	2009-02-27 08:08:04 UTC (rev 2598)
+++ trunk/openvas-client/src/gui/ssh_key_info_form.c	2009-02-27 08:17:13 UTC (rev 2599)
@@ -66,6 +66,7 @@
   {
     gtk_entry_set_text(GTK_ENTRY(form->name), "");
     gtk_entry_set_text(GTK_ENTRY(form->username), "");
+    gtk_entry_set_text(GTK_ENTRY(form->userpassword), "");
     gtk_entry_set_text(GTK_ENTRY(form->public_key_path), "");
     gtk_entry_set_text(GTK_ENTRY(form->private_key_path), "");
     gtk_entry_set_text(GTK_ENTRY(form->comment), "");
@@ -75,6 +76,7 @@
   {
     gtk_entry_set_text(GTK_ENTRY(form->name), loginfo->name);
     gtk_entry_set_text(GTK_ENTRY(form->username), loginfo->username);
+    gtk_entry_set_text(GTK_ENTRY(form->userpassword), loginfo->userpassword);
     gtk_entry_set_text(GTK_ENTRY(form->public_key_path), loginfo->public_key_path);
     gtk_entry_set_text(GTK_ENTRY(form->private_key_path), loginfo->private_key_path);
     gtk_entry_set_text(GTK_ENTRY(form->comment), loginfo->comment);
@@ -83,6 +85,7 @@
   
   gtk_entry_set_editable(GTK_ENTRY(form->name), FALSE);
   gtk_entry_set_editable(GTK_ENTRY(form->username), FALSE);
+  gtk_entry_set_editable(GTK_ENTRY(form->userpassword), FALSE);
   gtk_entry_set_editable(GTK_ENTRY(form->public_key_path), FALSE);
   gtk_entry_set_editable(GTK_ENTRY(form->private_key_path), FALSE);
   gtk_entry_set_editable(GTK_ENTRY(form->comment), FALSE);
@@ -153,6 +156,10 @@
   form->username = gtk_entry_new();
   gtk_entry_set_text(GTK_ENTRY(form->username), "");
   
+  form->userpassword = gtk_entry_new();
+  gtk_entry_set_visibility(GTK_ENTRY(form->userpassword), FALSE);
+  gtk_entry_set_text(GTK_ENTRY(form->userpassword), "");
+  
   form->public_key_path = gtk_entry_new();
   gtk_entry_set_text(GTK_ENTRY(form->public_key_path), "");
   
@@ -188,6 +195,13 @@
   
   row++;
   col = 1;
+  label = gtk_label_new(_("SSH login password:"));
+  gtk_table_attach_defaults(GTK_TABLE(table), label, col, col+1, row, row+1);
+  col++;
+  gtk_table_attach_defaults(GTK_TABLE(table), form->userpassword, col, col+1, row, row+1);
+  
+  row++;
+  col = 1;
   label = gtk_label_new(_("SSH public key:"));
   gtk_table_attach_defaults(GTK_TABLE(table), label, col, col+1, row, row+1);
   col++;
@@ -236,7 +250,7 @@
   const char* comment = gtk_entry_get_text(GTK_ENTRY(form->comment));
   const char* uname = gtk_entry_get_text(GTK_ENTRY(form->username));
   const char* name = gtk_entry_get_text(GTK_ENTRY(form->name));
-
+  
   // Validate from top to bottom (in gui)
   if(strlen(name) < 4){
     show_info(_("Please provide a better name."));
@@ -287,10 +301,11 @@
   const char* comment = gtk_entry_get_text(GTK_ENTRY(form->comment));
   const char* uname = gtk_entry_get_text(GTK_ENTRY(form->username));
   const char* name = gtk_entry_get_text(GTK_ENTRY(form->name));
+  const char* upass = gtk_entry_get_text(GTK_ENTRY(form->userpassword));
 
   openvas_ssh_login* loginfo = openvas_ssh_login_new(estrdup(name), estrdup(pubkey_file),
       estrdup(privkey_file), estrdup(passphrase),
-      estrdup(comment), estrdup(uname));
+      estrdup(comment), estrdup(uname), estrdup(upass));
   return loginfo;
 }
 
@@ -309,6 +324,8 @@
     gtk_widget_destroy(form->name);
   if(form->username)
     gtk_widget_destroy(form->username);
+  if(form->userpassword)
+    gtk_widget_destroy(form->userpassword);
   if(form->public_key_path)
     gtk_widget_destroy(form->public_key_path);
   if(form->private_key_path)

Modified: trunk/openvas-client/src/gui/ssh_key_info_form.h
===================================================================
--- trunk/openvas-client/src/gui/ssh_key_info_form.h	2009-02-27 08:08:04 UTC (rev 2598)
+++ trunk/openvas-client/src/gui/ssh_key_info_form.h	2009-02-27 08:17:13 UTC (rev 2599)
@@ -46,6 +46,7 @@
   GtkWidget* name;
   GtkWidget* box;
   GtkWidget* username;
+  GtkWidget* userpassword;
   GtkWidget* public_key_path;
   GtkWidget* private_key_path;
   GtkWidget* ssh_key_passphrase;

Modified: trunk/openvas-client/src/openvas-lib/openvas_ssh_login.c
===================================================================
--- trunk/openvas-client/src/openvas-lib/openvas_ssh_login.c	2009-02-27 08:08:04 UTC (rev 2598)
+++ trunk/openvas-client/src/openvas-lib/openvas_ssh_login.c	2009-02-27 08:17:13 UTC (rev 2599)
@@ -39,6 +39,7 @@
 #include "openvas_ssh_login.h"
 
 #define KEY_SSHLOGIN_USERNAME     "username"
+#define KEY_SSHLOGIN_USERPASSWORD "userpassword"
 #define KEY_SSHLOGIN_PUBKEY_FILE  "pubkey_file"
 #define KEY_SSHLOGIN_PRIVKEY_FILE "privkey_file"
 #define KEY_SSHLOGIN_COMMENT      "comment"
@@ -81,18 +82,19 @@
  */
 openvas_ssh_login*
 openvas_ssh_login_new (char* name, char* pubkey_file, char* privkey_file,
-                       char* passphrase, char* comment, char* uname)
+                       char* passphrase, char* comment, char* uname, char* upass)
 {
   openvas_ssh_login* loginfo = emalloc(sizeof(openvas_ssh_login));
   loginfo->name = name;
   loginfo->username = uname;
+  loginfo->userpassword = upass;
   loginfo->public_key_path = pubkey_file;
   loginfo->private_key_path = privkey_file;
   loginfo->ssh_key_passphrase = passphrase;
   loginfo->comment = comment;
   
-  loginfo->valid = (file_check_exists(pubkey_file) == 1
-                    && file_check_exists(privkey_file) == 1);
+  loginfo->valid =  (file_check_exists(pubkey_file) == 1
+                     && file_check_exists(privkey_file) == 1);
   
   return loginfo;
 }
@@ -112,6 +114,8 @@
     efree(&loginfo->name);
   if(loginfo->username)
     efree(&loginfo->username);
+  if(loginfo->userpassword)
+    efree(&loginfo->userpassword);
   if(loginfo->public_key_path)
     efree(&loginfo->public_key_path);
   if(loginfo->private_key_path)
@@ -158,6 +162,8 @@
 
   g_key_file_set_string(key_file, loginfo->name, KEY_SSHLOGIN_USERNAME, 
                         loginfo->username);
+  g_key_file_set_string(key_file, loginfo->name, KEY_SSHLOGIN_USERPASSWORD,
+                        loginfo->userpassword);
   g_key_file_set_string(key_file, loginfo->name, KEY_SSHLOGIN_PUBKEY_FILE, 
                         loginfo->public_key_path);
   g_key_file_set_string(key_file, loginfo->name, KEY_SSHLOGIN_PRIVKEY_FILE, 
@@ -291,12 +297,26 @@
     char* name = names[i];
     char* username = g_key_file_get_string (key_file, names[i],
                                             KEY_SSHLOGIN_USERNAME, &err);
+    char* userpass   = NULL;
     char* pubkey     = NULL;
     char* privkey    = NULL;
     char* comment    = NULL;
     char* passphrase = NULL;
 
     if (err == NULL)
+      {
+        userpass = g_key_file_get_string (key_file, names[i],
+                                          KEY_SSHLOGIN_USERPASSWORD, &err);
+        // For Compatibility, ignore if key for password is not present
+        if (err != NULL)
+          {
+            userpass = "";
+            g_error_free (err);
+            err = NULL;
+          }
+      }
+
+    if (err == NULL)
       pubkey   = g_key_file_get_string (key_file, names[i],
                                         KEY_SSHLOGIN_PUBKEY_FILE, &err);
     if (err == NULL)

Modified: trunk/openvas-client/src/openvas-lib/openvas_ssh_login.h
===================================================================
--- trunk/openvas-client/src/openvas-lib/openvas_ssh_login.h	2009-02-27 08:08:04 UTC (rev 2598)
+++ trunk/openvas-client/src/openvas-lib/openvas_ssh_login.h	2009-02-27 08:17:13 UTC (rev 2599)
@@ -44,6 +44,7 @@
 typedef struct {
   char* name;
   char* username;
+  char* userpassword;
   char* public_key_path;
   char* private_key_path;
   char* ssh_key_passphrase;
@@ -53,7 +54,7 @@
 
 openvas_ssh_login* openvas_ssh_login_new(char* name, char* pubkey_file,
                                          char* privkey_file, char* passphrase,
-                                         char* comment, char* uname);
+                                         char* comment, char* uname, char* upass);
 
 void openvas_ssh_login_free(openvas_ssh_login* loginfo);
 



More information about the Openvas-commits mailing list