new plugins: 'format_fs', 'volume_mount', 'volume_props', 'shutdown' and 'volume_details'
new plugin attribute: "requestAuth"
This commit is contained in:
parent
0e8a5daa73
commit
ca13aebdc8
27 changed files with 920 additions and 45 deletions
57
pythonrewrite/plugins/volume_mount/lang/en.hdf
Normal file
57
pythonrewrite/plugins/volume_mount/lang/en.hdf
Normal file
|
@ -0,0 +1,57 @@
|
|||
Name = Mount and umount volumes
|
||||
Link = Main
|
||||
Rank = 0
|
||||
|
||||
|
||||
Title {
|
||||
Mount = Activate volume
|
||||
Umount = Deactivate volume
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
Mount = Activate volume
|
||||
Umount = Deactivate volume
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
MountDone {
|
||||
Title = Encrypted filesystem activated
|
||||
Text = The encrypted filesystem is now available.
|
||||
}
|
||||
|
||||
UmountDone {
|
||||
Title = Encrypted filesystem deactivated
|
||||
Text = The encrypted filesystem is now secured from all forms of access.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WarningMessage {
|
||||
MountFailed {
|
||||
Title = Activation failed
|
||||
Text = The encrypted filesystem could not be activated. Probably the given password was wrong. Please try again.
|
||||
}
|
||||
|
||||
MountCryptoFailed {
|
||||
Title = Activation failed
|
||||
Text = Maybe you entered the wrong password?
|
||||
}
|
||||
|
||||
UmountFailed {
|
||||
Title = Deactivation failed
|
||||
Text = The encrypted filesystem could not be deactivated. Probably some files are still in use. Close all unclean programs (for example that widely used word processor). In case of emergency just shut down the CryptoBox!
|
||||
}
|
||||
|
||||
IsAlreadyMounted {
|
||||
Title = Already active
|
||||
Text = The volume is already active.
|
||||
}
|
||||
|
||||
IsNotMounted {
|
||||
Title = Inactive
|
||||
Text = The volume is currently not active.
|
||||
}
|
||||
|
||||
}
|
16
pythonrewrite/plugins/volume_mount/volume_mount.cs
Normal file
16
pythonrewrite/plugins/volume_mount/volume_mount.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Mount) ?></h2>
|
||||
|
||||
<p><?cs call:print_form_header("plugins/volume_mount") ?>
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<?cs if:Data.CurrentDisk.encryption ?>
|
||||
<input type="hidden" name="action" value="mount_luks" />
|
||||
<?cs else ?>
|
||||
<input type="hidden" name="action" value="mount_plain" />
|
||||
<?cs /if ?>
|
||||
<?cs if:Data.CurrentDisk.encryption ?>
|
||||
<label for="pw"><?cs var:html_escape(Lang.Text.EnterCurrentCryptoPassword) ?>: </label>
|
||||
<input type="password" tabindex="1" id="pw" name="pw" size="20" maxlength="60" />
|
||||
<?cs /if ?>
|
||||
<button type="submit" tabindex="2"><?cs var:html_escape(Lang.Plugins.volume_mount.Button.Mount) ?></button>
|
||||
</form></p>
|
||||
|
102
pythonrewrite/plugins/volume_mount/volume_mount.py
Normal file
102
pythonrewrite/plugins/volume_mount/volume_mount.py
Normal file
|
@ -0,0 +1,102 @@
|
|||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
class volume_mount(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
requestAuth = False
|
||||
|
||||
|
||||
def doAction(self, action=None, pw=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if action == "mount_plain":
|
||||
return self.__doMountPlain()
|
||||
elif action == "mount_luks":
|
||||
return self.__doMountLuks(pw)
|
||||
elif action == "umount":
|
||||
return self.__doUmount()
|
||||
elif not action:
|
||||
return "volume_status"
|
||||
else:
|
||||
self.cbox.log.info("plugin 'volume_mount' - unknown action: %s" % action)
|
||||
return None
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return "invalid device"
|
||||
if container.isMounted():
|
||||
return "active"
|
||||
else:
|
||||
return "passive"
|
||||
|
||||
|
||||
def __doMountPlain(self):
|
||||
if self.container.isMounted():
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.IsAlreadyMounted"
|
||||
self.cbox.log.info("the device (%s) is already mounted" % device)
|
||||
return "volume_status"
|
||||
if self.container.getType() != self.container.Types["plain"]:
|
||||
## not a plain container - fail silently
|
||||
self.cbox.log.info("plugin 'volume_mount' - invalid container type")
|
||||
return "volume_status"
|
||||
try:
|
||||
self.container.mount()
|
||||
except CBMountError, errMsg:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.MountFailed"
|
||||
self.cbox.log.warn("failed to mount the device (%s): %s" % (self.device, errMsg))
|
||||
return "volume_status"
|
||||
except CBContainerError, errMsg:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.MountFailed"
|
||||
self.cbox.log.warn("failed to mount the device (%s): %s" % (self.device, errMsg))
|
||||
return "volume_status"
|
||||
self.cbox.log.info("successfully mounted the volume: %s" % self.device)
|
||||
self.hdf["Data.Success"] = "Plugins.volume_mount.MountDone"
|
||||
return "volume_status"
|
||||
|
||||
|
||||
def __doMountLuks(self, pw):
|
||||
if self.container.isMounted():
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.IsAlreadyMounted"
|
||||
self.cbox.log.info("the device (%s) is already mounted" % device)
|
||||
return "volume_status"
|
||||
if not pw:
|
||||
self.dataset["Data.Warning"] = "EmptyCryptoPassword"
|
||||
self.log.info("no password was supplied for mounting of device: '%s'" % device)
|
||||
return "volume_status"
|
||||
if self.container.getType() != self.container.Types["luks"]:
|
||||
## not a luks container - fail silently
|
||||
self.cbox.log.info("plugin 'volume_mount' - invalid container type")
|
||||
return "volume_status"
|
||||
try:
|
||||
self.container.mount(pw)
|
||||
except CBMountError, errMsg:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.MountCryptoFailed"
|
||||
self.cbox.log.warn("failed to mount the device (%s): %s" % (self.device, errMsg))
|
||||
return "volume_status"
|
||||
except CBContainerError, errMsg:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.MountCryptoFailed"
|
||||
self.cbox.log.warn("failed to mount the device (%s): %s" % (self.device, errMsg))
|
||||
return "volume_status"
|
||||
self.cbox.log.info("successfully mounted the volume: %s" % self.device)
|
||||
self.hdf["Data.Success"] = "Plugins.volume_mount.MountDone"
|
||||
return "volume_status"
|
||||
|
||||
|
||||
def __doUmount(self):
|
||||
if not self.container.isMounted():
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_mount.IsNotMounted"
|
||||
self.cbox.log.info("the device (%s) is currently not mounted" % self.device)
|
||||
return "volume_status"
|
||||
try:
|
||||
self.container.umount()
|
||||
except CBUmountError, errMsg:
|
||||
self.hdf["Data.Warning"] = "InvalidType"
|
||||
self.cbox.log.warn("could not umount the volume (%s): %s" % (self.device, errMsg))
|
||||
return "volume_status"
|
||||
self.cbox.log.info("successfully unmounted the container: %s" % self.device)
|
||||
self.hdf["Data.Success"] = "Plugins.volume_mount.UmountDone"
|
||||
return "volume_status"
|
||||
|
9
pythonrewrite/plugins/volume_mount/volume_status.cs
Normal file
9
pythonrewrite/plugins/volume_mount/volume_status.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs include:Settings.PluginDir + "/volume_mount/volume_umount.cs" ?>
|
||||
<?cs else ?>
|
||||
<?cs include:Settings.PluginDir + "/volume_mount/volume_mount.cs" ?>
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
8
pythonrewrite/plugins/volume_mount/volume_umount.cs
Normal file
8
pythonrewrite/plugins/volume_mount/volume_umount.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Umount) ?></h2>
|
||||
|
||||
<?cs call:print_form_header("plugins/volume_mount") ?>
|
||||
<p><input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="action" value="umount" />
|
||||
<button type="submit" tabindex="2"><?cs var:html_escape(Lang.Button.Umount) ?></button></p>
|
||||
</form>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue