implemented root actions for plugins

finished network and date plugins
renamed old 'bin' direcory
This commit is contained in:
lars 2006-09-13 10:38:05 +00:00
parent 2b4180a83b
commit e80b8874ff
13 changed files with 211 additions and 23 deletions

View file

@ -1,4 +1,6 @@
from CryptoBoxExceptions import CBPluginActionError
import subprocess
import os
def prepareForm(hdf, cbox):
@ -19,9 +21,19 @@ def doAction(cbox, store=None, year=0, month=0, day=0, hour=0, minute=0):
new_date = datetime.datetime(year, month, day, hour, minute)
except ValueError:
raise CBPluginActionError, "InvalidDate"
# TODO: how to set the current time? (and how to become root?)
## we will continue with the system menue
return "form_system"
proc = subprocess.Popen(
shell = False,
args = [
cbox.prefs["Programs"]["super"],
cbox.prefs["Programs"]["CryptoBoxRootActions"],
"plugin",
os.path.join(os.path.dirname(__file__), "root_action.py"),
"%02d%02d%02d%02d%d" % (month, day, hour, minute, year)])
proc.communicate()
if proc.returncode == 0:
return "form_system"
else:
raise CBPluginActionError, "InvalidDate"
else:
return "form_date"

View file

@ -0,0 +1,35 @@
#!/usr/bin/env python2.4
## necessary: otherwise CryptoBoxRootActions.py will refuse to execute this script
PLUGIN_TYPE = "cryptobox"
DATE_BIN = "/bin/date"
import subprocess
import re
import sys
import os
if __name__ == "__main__":
args = sys.argv[1:]
self_bin = sys.argv[0]
if len(args) > 1:
sys.stderr.write("%s: too many arguments (%s)\n" % (self_bin, args))
sys.exit(1)
if len(args) == 0:
sys.stderr.write("%s: no argument supplied\n" % self_bin)
sys.exit(1)
if re.search(u'\D', args[0]):
sys.stderr.write("%s: illegal argument (%s)\n" % (self_bin, args[0]))
sys.exit(1)
proc = subprocess.Popen(
shell = False,
args = [DATE_BIN, args[0]])
proc.communicate()
sys.exit(proc.returncode)