cryptonas/plugins/volume_check_fs/volume_check_fs.py

97 lines
2.6 KiB
Python

#
# 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.
"""