diff --git a/pythonrewrite/bin2/cryptoboxwebserver.conf b/pythonrewrite/bin2/cryptoboxwebserver.conf index 56c3f46..6c11617 100644 --- a/pythonrewrite/bin2/cryptoboxwebserver.conf +++ b/pythonrewrite/bin2/cryptoboxwebserver.conf @@ -9,5 +9,6 @@ server.logFile = "cryptoboxwebserver.log" [/favicon.ico] static_filter.on = True +# RFC why the cherry and not the ant? static_filter.file = "/usr/share/doc/python-cherrypy/cherrypy/favicon.ico" diff --git a/pythonrewrite/bin2/test.complete.CryptoBox.py b/pythonrewrite/bin2/test.complete.CryptoBox.py new file mode 100755 index 0000000..cdaeb50 --- /dev/null +++ b/pythonrewrite/bin2/test.complete.CryptoBox.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python2.4 + +""" +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): + # umount if necessary + try: + e.umount() + except "MountError": + pass + + 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" + + print "\tCapacity (size, free, used) [MB]:\t%s" % (e.getCapacity(), ) + + 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): + # umount if necessary + try: + e.umount() + except "MountError": + pass + + 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" + + print "\tCapacity (size, free, used) [MB]:\t%s" % (e.getCapacity(), ) + + 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()