mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 21:21:31 +00:00
Fix file permissions again for zenmap.conf. Handle it in one place only.
This commit is contained in:
@@ -129,6 +129,7 @@ class UmitConfigParser(ConfigParser):
|
||||
|
||||
def __init__(self, *args):
|
||||
self.filenames = None
|
||||
self.failed = False
|
||||
ConfigParser.__init__(self, *args)
|
||||
|
||||
def set(self, section, option, value):
|
||||
@@ -149,7 +150,14 @@ class UmitConfigParser(ConfigParser):
|
||||
def save_changes(self):
|
||||
if self.filenames:
|
||||
log.debug("saving to %s" % self.filenames)
|
||||
self.write(open(self.filenames, 'w'))
|
||||
try:
|
||||
fp = open(self.filenames, 'w')
|
||||
except Exception as e:
|
||||
self.failed = e
|
||||
log.error(">>> Can't save to %s: %s" % (self.filenames, e))
|
||||
return
|
||||
self.write(fp)
|
||||
self.failed = False
|
||||
else:
|
||||
log.debug(">>> UmitConfigParser can't save changes: no filename")
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ from zenmapCore.RecentScans import recent_scans
|
||||
from zenmapCore.UmitLogging import log
|
||||
import zenmapCore.I18N
|
||||
import zenmapGUI.Print
|
||||
from zenmapCore.UmitConf import SearchConfig, is_maemo, WindowConfig
|
||||
from zenmapCore.UmitConf import SearchConfig, is_maemo, WindowConfig, config_parser
|
||||
from zenmapCore.NetworkInventory import FilteredNetworkInventory
|
||||
|
||||
UmitScanWindow = None
|
||||
@@ -906,23 +906,19 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
return True
|
||||
|
||||
window = WindowConfig()
|
||||
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
|
||||
window.x, window.y = self.get_position()
|
||||
window.width, window.height = self.get_size()
|
||||
window.save_changes()
|
||||
if config_parser.failed:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Can't save Zenmap configuration"),
|
||||
# newline before path to help avoid weird line wrapping
|
||||
secondary_text=_(
|
||||
'An error occurred when saving to\n%s'
|
||||
'\nThe error was: %s.'
|
||||
) % (Path.user_config_file, config_parser.failed))
|
||||
alert.run()
|
||||
alert.destroy()
|
||||
|
||||
self.destroy()
|
||||
|
||||
|
||||
@@ -126,7 +126,6 @@ import gtk
|
||||
import gtk.gdk
|
||||
import pango
|
||||
import re
|
||||
import errno
|
||||
|
||||
import zenmapCore.I18N
|
||||
from zenmapCore.UmitLogging import log
|
||||
@@ -264,20 +263,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
self.nmap_highlight.__setattr__(widget.property_name, wid_props)
|
||||
|
||||
nmap_out_prop.destroy()
|
||||
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.nmap_highlight.save_changes()
|
||||
self.apply_highlighting()
|
||||
|
||||
def apply_highlighting(self, start_iter=None, end_iter=None):
|
||||
|
||||
Reference in New Issue
Block a user