lars
b951efdd9c
syslog support added moved program locations to config file removed obsolete CryptoBoxPreferences added some requests for comments (RFC)
99 lines
2.4 KiB
Python
99 lines
2.4 KiB
Python
"""
|
|
BEWARE: this script may overwrite the data of one of your loop devices. You
|
|
should restrict the AllowedDevices directive in cryptobox.conf to exclude
|
|
your precious black devices from being used by this script.
|
|
|
|
the following script runs a number of tests for different parts
|
|
"""
|
|
|
|
from CryptoBox import CryptoBoxProps
|
|
from CryptoBoxContainer import CryptoBoxContainer
|
|
import sys
|
|
|
|
|
|
def main():
|
|
cb = CryptoBoxProps()
|
|
|
|
print "Confguration:"
|
|
print "\tConfig file:\t\t%s" % (cb.cbxPrefs.filename, )
|
|
print "\tAllowed devices:\t%s" % (cb.cbxPrefs["Main"]["AllowedDevices"], )
|
|
|
|
"""for e in cb.getContainerList(filterType=CryptoBoxContainer.Types["luks"]):"""
|
|
for e in cb.getContainerList():
|
|
print "\t\t%d\t\t%s - %s - %d" % (cb.getContainerList().index(e), e.getDevice(), e.getName(), e.getType())
|
|
|
|
if not cb.getContainerList():
|
|
print "no loop devices found for testing"
|
|
sys.exit(1)
|
|
|
|
if len(cb.getContainerList()) > 1:
|
|
print "I found more than one available loop device - I will stop now to avoid risking data loss."
|
|
print "Please change the 'AllowedDevices' setting in 'cryptobox.conf' to reduce the number of allowed devices to only one."
|
|
sys.exit(1)
|
|
|
|
testElement = cb.getContainerList()[0]
|
|
print "\nRunning some tests now ..."
|
|
if not plain_tests(testElement):
|
|
print "some previous tests failed - we should stop now"
|
|
sys.exit(1)
|
|
luks_tests(testElement)
|
|
|
|
|
|
" ***************** some functions ******************** "
|
|
|
|
def luks_tests(e):
|
|
e.create(e.Types["luks"], "alt")
|
|
print "\tluks create:\tok"
|
|
|
|
e.changePassword("alt","neu")
|
|
print "\tluks changepw:\tok"
|
|
|
|
e.setName("lalla")
|
|
print "\tluks setName:\tok"
|
|
|
|
try:
|
|
e.mount("neu")
|
|
except "MountError":
|
|
pass
|
|
if e.isMounted(): print "\tluks mount:\tok"
|
|
else: print "\tluks mount:\tfailed"
|
|
|
|
try:
|
|
e.umount()
|
|
except "MountError":
|
|
pass
|
|
if e.isMounted(): print "\tluks umount:\tfailed"
|
|
else: print "\tluks umount:\tok"
|
|
|
|
if e.isMounted(): return False
|
|
else: return True
|
|
|
|
|
|
def plain_tests(e):
|
|
e.create(e.Types["plain"])
|
|
print "\tplain create:\tok"
|
|
|
|
e.setName("plain-lili")
|
|
print "\tplain setName:\tok"
|
|
|
|
try:
|
|
e.mount()
|
|
except "MountError":
|
|
pass
|
|
if e.isMounted(): print "\tplain mount:\tok"
|
|
else: print "\tplain mount:\tfailed"
|
|
|
|
try:
|
|
e.umount()
|
|
except "MountError":
|
|
pass
|
|
if e.isMounted(): print "\tplain umount:\tfailed"
|
|
else: print "\tplain umount:\tok"
|
|
|
|
if e.isMounted(): return False
|
|
else: return True
|
|
|
|
# ************ main ****************
|
|
|
|
main()
|