⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prefs_dialog_auth.c

📁 大国补丁后的nessus2.2.8的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $Id: prefs_dialog_auth.c,v 1.3 2005/09/14 13:22:16 renaud Exp $ * * Copyright (C) 2004 by Intevation GmbH * Author(s): * Thomas Arendsen Hein <thomas@intevation.de> * * This program is free software under the GNU GPL (>=v2) * Read the file COPYING coming with the software for details. * * In addition, as a special exception, Intevation GmbH gives * 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 <includes.h>#include "nessus_i18n.h"#ifdef USE_GTK#include <gtk/gtk.h>#include "nessus.h"#include "error_dialog.h"#include "context.h"#include "preferences.h"#include "prefs_context.h"#include "prefs_scope_tree.h"#include "prefs_help.h"#include "globals.h"#ifndef USE_AF_INET#undef ENABLE_CRYPTO_LAYER#endifstruct auth_fileselect {  struct auth_dialog *auth;  GtkWidget *box;  GtkWidget *entry;};struct auth_dialog {  struct context *context;  GtkWindow *parent;  GtkWidget *dialog;  GtkWidget *hostname;  GtkWidget *port;  GtkWidget *username;  GtkWidget *password;#ifdef NESSUS_ON_SSL  GtkWidget *use_ssl;  GtkWidget *use_client_cert;  struct auth_fileselect *trusted_ca;  struct auth_fileselect *cert_file;  struct auth_fileselect *key_file;#endif /* NESSUS_ON_SSL */};#ifdef USE_AF_INETconst gchar *prefs_dialog_auth_hostname(auth)  struct auth_dialog *auth;{  const gchar *text;  text = gtk_entry_get_text(GTK_ENTRY(auth->hostname));  if((!text) || (!strlen(text)))  {    gtk_widget_grab_focus(auth->hostname);    show_warning(_("You must enter a valid hostname or IP"));    return NULL;  }  return text;}intprefs_dialog_auth_port(auth)  struct auth_dialog *auth;{  int port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(auth->port));  if((port < 0) || (port > 65536))  {    gtk_widget_grab_focus(auth->port);    show_warning(_("The port number is out of range"));    return -1;  }  return port;}voidprefs_dialog_auth_defaultport_clicked(button, auth)  GtkButton *button;  struct auth_dialog *auth;{  gtk_spin_button_set_value(GTK_SPIN_BUTTON(auth->port),      (int)prefs_get_default(auth->context, "nessusd_port"));}#ifdef NESSUS_ON_SSLvoidprefs_dialog_auth_fileselect_popup(button, auth_fileselect)  GtkButton *button;  struct auth_fileselect *auth_fileselect;{  GtkWidget *dialog = gtk_file_selection_new(_("Select File"));  gtk_window_set_transient_for(GTK_WINDOW(dialog),      GTK_WINDOW(auth_fileselect->auth->dialog));  gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),    gtk_entry_get_text(GTK_ENTRY(auth_fileselect->entry)));  if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)  {    gchar *filename = g_strdup(	gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog)));    gtk_widget_hide(dialog);    if(check_is_dir(filename))      show_error(_("Please choose a filename."));    else if(!check_is_file(filename))      show_error(_("File \"%s\" doesn't exist."), filename);    else      gtk_entry_set_text(GTK_ENTRY(auth_fileselect->entry), filename);    g_free(filename);  }  gtk_widget_destroy(dialog);}#endif /* NESSUS_ON_SSL */#endif /* USE_AF_INET */const gchar *prefs_dialog_auth_username(auth)  struct auth_dialog *auth;{  const gchar *text;  text = gtk_entry_get_text(GTK_ENTRY(auth->username));  if((!text) || (!strlen(text)))  {    gtk_widget_grab_focus(auth->username);    show_warning(_("You must enter a valid username"));    return NULL;  }  return text;}const gchar *prefs_dialog_auth_password(auth)  struct auth_dialog *auth;{  const gchar *text;  text = gtk_entry_get_text(GTK_ENTRY(auth->password));  if(!(text && (strlen(text)#ifdef NESSUS_ON_SSL      || (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth->use_ssl)) &&	gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth->use_client_cert)))#endif /* NESSUS_ON_SSL */      )))  {    gtk_widget_grab_focus(auth->password);    show_warning(_("You must enter a valid password"));    return NULL;  }  return text;}#ifdef NESSUS_ON_SSLconst gchar *prefs_dialog_auth_trusted_ca(auth, context)  struct auth_dialog *auth;  struct context *context;{  const gchar *text;  int paranoia_level = prefs_get_int(context, "paranoia_level");  text = gtk_entry_get_text(GTK_ENTRY(auth->trusted_ca->entry));  if(!(text && strlen(text)) && (paranoia_level == 2 || paranoia_level == 3))  {    gtk_widget_grab_focus(auth->trusted_ca->entry);    show_warning(_("You must enter a filename for Trusted CA"));    return NULL;  }  return text;}const gchar *prefs_dialog_auth_cert_file(auth)  struct auth_dialog *auth;{  const gchar *text;  text = gtk_entry_get_text(GTK_ENTRY(auth->cert_file->entry));  if(!(text && strlen(text)))  {    gtk_widget_grab_focus(auth->cert_file->entry);    show_warning(_("You must enter a filename for the SSL Certificate"));    return NULL;  }  return text;}const gchar *prefs_dialog_auth_key_file(auth)  struct auth_dialog *auth;{  const gchar *text;  text = gtk_entry_get_text(GTK_ENTRY(auth->key_file->entry));  if(!(text && strlen(text)))  {    gtk_widget_grab_focus(auth->key_file->entry);    show_warning(_("You must enter a filename for the SSL Key"));    return NULL;  }  return text;}#endif /* NESSUS_ON_SSL */char *prefs_dialog_auth_do_connect(context, ctrls)  struct context *context;  gpointer ctrls;{  void *context_window = arg_get_value(MainDialog, "CONTEXT");  const char *hostname = prefs_get_string(context, "nessusd_host");  GtkWindow *window = NULL;  GtkWidget *dialog;  GtkWidget *vbox;  GtkWidget *label;  gchar *text;  char *err;  int i;  if(context_window)    window = GTK_WINDOW(context_window);  dialog = gtk_dialog_new_with_buttons(_("Connecting ..."),      window,      GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT      | GTK_DIALOG_NO_SEPARATOR,      NULL);  /* prevent the dialog from being closed */  g_signal_connect(G_OBJECT(dialog), "delete_event",      G_CALLBACK(gtk_true), NULL);  vbox = gtk_vbox_new(FALSE, 4);  gtk_widget_show(vbox);  gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);  gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox);  text = g_strdup_printf(_("Connecting to Nessus server \"%s\" ..."), hostname);  label = gtk_label_new(text);  gtk_widget_show(label);  gtk_box_pack_start_defaults(GTK_BOX(vbox), label);  context->pbar = gtk_progress_bar_new();  gtk_progress_bar_set_text(GTK_PROGRESS_BAR(context->pbar),      _("Initiating connection ..."));  gtk_widget_show(context->pbar);  gtk_box_pack_start_defaults(GTK_BOX(vbox), context->pbar);  gtk_widget_show(dialog);  arg_set_value(ctrls, "CONTEXT", -1, dialog);  for ( i = 0 ; i < 32 ; i ++ )  {   if (gtk_events_pending() )  	gtk_main_iteration();   else	break;  }  err = connect_to_nessusd(context);  arg_set_value(ctrls, "CONTEXT", -1, window);  gtk_widget_destroy(dialog);  g_free(text);  if(err)    return err;  else  {    /* FIXME plugin list is only filled if gtk_notebook_set_page is called */    gtk_notebook_set_page(	GTK_NOTEBOOK(arg_get_value(MainDialog, "NOTEBOOK")), 1);    prefs_context_update(context);    scopetreeview_connected_update(context);    return NULL;  }}GtkWidget *prefs_dialog_auth_vbox(text, content)  const gchar *text;  GtkWidget *content;{  GtkWidget *label;  GtkWidget *vbox;  vbox = gtk_vbox_new(FALSE, 0);  gtk_widget_show(vbox);  label = gtk_label_new(text);  gtk_widget_show(label);  gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);  gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);  gtk_box_pack_start(GTK_BOX(vbox), content, FALSE, FALSE, 0);  return vbox;}#ifdef NESSUS_ON_SSLstruct auth_fileselect *prefs_dialog_auth_fileselect(auth, text, pref_name, box)  struct auth_dialog *auth;  const gchar *text;  const gchar *pref_name;  GtkWidget *box;{  struct auth_fileselect *auth_fileselect;  GtkWidget *hbox;  GtkWidget *button;  const gchar *pref = prefs_get_string(auth->context, pref_name);  auth_fileselect = emalloc(sizeof(struct auth_fileselect));  auth_fileselect->auth = auth;  hbox = gtk_hbox_new(FALSE, 0);  gtk_widget_show(hbox);  auth_fileselect->entry = gtk_entry_new();  gtk_widget_show(auth_fileselect->entry);  if(pref)    gtk_entry_set_text(GTK_ENTRY(auth_fileselect->entry), pref);  gtk_box_pack_start_defaults(GTK_BOX(hbox), auth_fileselect->entry);  button = gtk_button_new_with_mnemonic(_("Select ..."));  gtk_widget_show(button);  gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);  g_signal_connect((gpointer)button, "clicked",                   G_CALLBACK(prefs_dialog_auth_fileselect_popup),                   auth_fileselect);  auth_fileselect->box = prefs_dialog_auth_vbox(text, hbox);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -