From 2cac563bea5e6f023129e045dc7822652013347f Mon Sep 17 00:00:00 2001 From: lars Date: Fri, 2 Feb 2007 08:57:46 +0000 Subject: [PATCH] ignore non-readable or non-writeable block devices added sources for help_browser_disable icon --- design/icons/help_browser_disable.svg | 253 ++++++++++++++++++++++++++ src/cryptobox/core/main.py | 14 +- 2 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 design/icons/help_browser_disable.svg diff --git a/design/icons/help_browser_disable.svg b/design/icons/help_browser_disable.svg new file mode 100644 index 0000000..74299ba --- /dev/null +++ b/design/icons/help_browser_disable.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/cryptobox/core/main.py b/src/cryptobox/core/main.py index 59c568c..fe04c89 100644 --- a/src/cryptobox/core/main.py +++ b/src/cryptobox/core/main.py @@ -219,9 +219,18 @@ class CryptoBox: def is_device_allowed(self, devicename): - "check if a device is white-listed for being used as cryptobox containers" + """check if a device is white-listed for being used as cryptobox containers + + also check, if the device is readable and writeable for the current user + """ import types devicename = os.path.abspath(devicename) + if not os.access(devicename, os.R_OK): + self.log.debug("Skipping device without read permissions: %s" % devicename) + return False + if not os.access(devicename, os.W_OK): + self.log.debug("Skipping device without write permissions: %s" % devicename) + return False allowed = self.prefs["Main"]["AllowedDevices"] if type(allowed) == types.StringType: allowed = [allowed] @@ -234,7 +243,10 @@ class CryptoBox: ## it is not possible to check for 'realpath' - that does not work ## for the cryptobox as /dev/ is bind-mounted (real hda-name is /opt/...) if re.search('^%s' % a_dev, devicename): + self.log.debug("Adding valid device: %s" % devicename) return True + self.log.debug("Skipping device not listed in Main->AllowedDevices: %s" \ + % devicename) return False