diff --git a/zenmap/zenmapGUI/MainWindow.py b/zenmap/zenmapGUI/MainWindow.py index 4e7766f1a..8dc6a3aec 100644 --- a/zenmap/zenmapGUI/MainWindow.py +++ b/zenmap/zenmapGUI/MainWindow.py @@ -124,6 +124,7 @@ import gtk import sys import os from os.path import split, isfile, join, abspath, exists +import errno # Prevent loading PyXML import xml @@ -905,9 +906,23 @@ This scan has not been run yet. Start the scan with the "Scan" button first.')) return True window = WindowConfig() - window.x, window.y = self.get_position() - window.width, window.height = self.get_size() - window.save_changes() + try: + window.x, window.y = self.get_position() + window.width, window.height = self.get_size() + window.save_changes() + except IOError as e: + if e.errno == errno.EACCES: + alert = HIGAlertDialog( + message_format=_("Can't save Zenmap configuration"), + # newline before path to help avoid weird line wrapping + secondary_text=_( + 'Permission denied when writing to\n%s' + '\nMake sure the file exists and is writable.' + ) % (Path.user_config_file)) + alert.run() + alert.destroy() + else: + raise self.destroy() diff --git a/zenmap/zenmapGUI/NmapOutputViewer.py b/zenmap/zenmapGUI/NmapOutputViewer.py index 26b5cc9d2..2e8f30d35 100644 --- a/zenmap/zenmapGUI/NmapOutputViewer.py +++ b/zenmap/zenmapGUI/NmapOutputViewer.py @@ -126,6 +126,7 @@ import gtk import gtk.gdk import pango import re +import errno import zenmapCore.I18N from zenmapCore.UmitLogging import log @@ -263,7 +264,20 @@ class NmapOutputViewer (gtk.VBox): self.nmap_highlight.__setattr__(widget.property_name, wid_props) nmap_out_prop.destroy() - self.nmap_highlight.save_changes() + try: + self.nmap_highlight.save_changes() + except IOError as e: + if e.errno == errno.EACCES: + alert = HIGAlertDialog( + message_format=_("Can't save Zenmap configuration"), + secondary_text=_( + 'Permission denied when writing to \n%s' + '\nMake sure the file exists and is writable.' + ) % (Path.user_config_file)) + alert.run() + alert.destroy() + else: + raise self.apply_highlighting() def apply_highlighting(self, start_iter=None, end_iter=None):