From 4c9b4e5a5bf2a276eb558d306ce8f010abb56db2 Mon Sep 17 00:00:00 2001 From: lars Date: Sun, 6 Apr 2008 14:56:56 +0000 Subject: [PATCH] init of a filesystem checker plugin - not finished, yet --- plugins/volume_check_fs/language.hdf | 31 +++++++ plugins/volume_check_fs/volume_check_fs.py | 97 ++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 plugins/volume_check_fs/language.hdf create mode 100644 plugins/volume_check_fs/volume_check_fs.py diff --git a/plugins/volume_check_fs/language.hdf b/plugins/volume_check_fs/language.hdf new file mode 100644 index 0000000..e2c87fd --- /dev/null +++ b/plugins/volume_check_fs/language.hdf @@ -0,0 +1,31 @@ +Name = Plugin template +Link = Template + +Title = This is a plugin template + +Text.Example = Think before you code. +Text.SecondExample = And while probably won't hurt! + +Help.Example = This template should help you with starting to write your own plugins. Please take a look in plugin-interfaces.txt for further assistance. + +SuccessMessage { + TemplateLaunched { + Title = You see ... + Text = an empty example for a plugin. + } +} + +WarningMessage { + SomeError { + Title = Invalid value + Text = This message will never appear. + } +} + +EnvironmentWarning { + MissingFoo { + Title = Plugin template warning example + Text = Use this to print some important warnings. + } +} + diff --git a/plugins/volume_check_fs/volume_check_fs.py b/plugins/volume_check_fs/volume_check_fs.py new file mode 100644 index 0000000..d5435f5 --- /dev/null +++ b/plugins/volume_check_fs/volume_check_fs.py @@ -0,0 +1,97 @@ +# +# Copyright 2006-2007 sense.lab e.V. +# +# This file is part of the CryptoBox. +# +# The CryptoBox is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# The CryptoBox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the CryptoBox; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +"""This is a plugin for automatic filesystem checks during mount + +TODO: the plugin is not implemented, yet! + +requires: + - e2fsck (debian: e2fsprogs package) +""" + +__revision__ = "" + +import cryptobox.plugins.base +import os + +DEFAULT_E2FSCK_BIN = "/sbin/e2fsck" + + +class volume_check_fs(cryptobox.plugins.base.CryptoBoxPlugin): + """a template for CryptoBox plugins + """ + + plugin_capabilities = [ "system" ] + #plugin_visibility = [ "preferences" ] + # TODO: enable, when the plugin is working + plugin_visibility = [ ] + request_auth = False + rank = 99 + + def do_action(self): + """The action handler. + """ + # TODO: not implemented, yet + return "form_plugin" + + + def get_status(self): + """Retrieve the status of the feature. + """ + if self.__check_e2fsck_availability(): + return "installed" + else: + return "missing" + + + def get_warnings(self): + warnings = [] + if not self.__check_e2fsck_availability(): + warnings.append((32, "Plugins.%s.MissingProgramE2fsck" \ + % self.get_name())) + return warnings + + + def __check_e2fsck_availability(self): + """Test if the program e2fsck is installed + """ + if os.access(self.__get_e2fsck_location(), os.X_OK): + return True + else: + self.cbox.log.warn("The recommended program 'e2fsck' is not " \ + + "available - please install it!") + return False + + + def __get_e2fsck_location(self): + """get the location of the e2fsck binary + + this setting may be changed in cryptobox.conf + """ + if "e2fsck_bin" in self.defaults: + return self.defaults["e2fsck_bin"] + else: + return DEFAULT_E2FSCK_BIN + + + def __prepare_form_data(self): + """Set some hdf values. + """ +