From fc67727692eb3389040bb154e859a662533886f4 Mon Sep 17 00:00:00 2001 From: lars Date: Fri, 10 Nov 2006 09:05:54 +0000 Subject: [PATCH] updated the Makefile (just a bit) --- Makefile | 26 +++++--------------------- bin/CryptoBoxSettings.py | 1 + bin/CryptoBoxWebserver.py | 4 ++-- bin/Plugins.py | 7 +++++++ bin/cryptobox.conf | 7 +++++-- bin/cryptoboxd | 32 ++++++++++++++++---------------- 6 files changed, 36 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index bb2f6c6..ee95511 100644 --- a/Makefile +++ b/Makefile @@ -19,52 +19,36 @@ OS_TYPE=$(shell uname -o | tr [:upper:] [:lower:] | sed s/[^a-z0-9\._\-]/_/g) build: $(INSTALL) -d -m 755 $(BUILD_DIR)/etc - $(INSTALL) -c -m 644 conf-examples/cryptobox.conf $(BUILD_DIR)/etc/ + $(INSTALL) -c -m 644 bin/cryptobox.conf $(BUILD_DIR)/etc/ @sed -i 's#^HTML_TEMPLATE_DIR=.*$$#HTML_TEMPLATE_DIR=$(SHARE_DIR)/templates#' $(BUILD_DIR)/etc/cryptobox.conf @sed -i 's#^LANGUAGE_DIR=.*$$#LANGUAGE_DIR=$(SHARE_DIR)/lang#' $(BUILD_DIR)/etc/cryptobox.conf @sed -i 's#^DOC_DIR=.*$$#DOC_DIR=$(DOC_DIR)/html#' $(BUILD_DIR)/etc/cryptobox.conf @sed -i 's#^CONFIG_DEFAULTS_DIR=.*$$#CONFIG_DEFAULTS_DIR=$(SHARE_DIR)/defaults#' $(BUILD_DIR)/etc/cryptobox.conf - # choose the appropriate program_locations.conf - if test -e conf-examples/distributions/$(OS_TYPE) ; \ - then cat conf-examples/distributions/$(OS_TYPE) ;\ - else cat conf-examples/distributions/default ;\ - fi >$(BUILD_DIR)/etc/distribution.conf - - # compile the suid wrapper - $(MAKE) -C bin LIB_DIR=$(LIB_DIR) @touch $(BUILD_DIR)-stamp install: $(BUILD_DIR)-stamp $(INSTALL) -d -m 755 $(LIB_DIR) - $(INSTALL) -c -m 755 bin/cbox-manage.sh $(LIB_DIR) - $(INSTALL) -c -m 755 bin/cbox-root-actions.sh $(LIB_DIR) - $(INSTALL) -c -m 755 bin/cryptobox.pl $(LIB_DIR) - $(INSTALL) -c -m 755 bin/cryptobox_cgi_wrapper $(LIB_DIR) - $(INSTALL) -c -m 4755 bin/cryptobox_root_wrapper $(LIB_DIR) + $(INSTALL) -c -m 755 bin/*.py $(LIB_DIR)/ $(INSTALL) -d -m 755 $(SHARE_DIR)/lang $(INSTALL) -c -m 644 lang/* $(SHARE_DIR)/lang/ $(INSTALL) -d -m 755 $(SHARE_DIR)/templates $(INSTALL) -c -m 644 templates/*.cs $(SHARE_DIR)/templates - $(INSTALL) -d -m 755 $(SHARE_DIR)/defaults - $(INSTALL) -c -m 644 conf-examples/default-settings/* $(SHARE_DIR)/defaults/ $(INSTALL) -d -m 755 $(SHARE_DIR)/html $(INSTALL) -c -m 644 www-data/*.css $(SHARE_DIR)/html/ $(INSTALL) -c -m 644 www-data/*.png $(SHARE_DIR)/html/ $(INSTALL) -c -m 644 www-data/*.gif $(SHARE_DIR)/html/ - #$(INSTALL) -d -m 755 $(SHARE_DIR)/html/screenshots - #$(INSTALL) -c -m 644 www-data/screenshots/*.png $(SHARE_DIR)/html/screenshots/ + $(INSTALL) -d -m 755 $(SHARE_DIR)/html/screenshots + $(INSTALL) -c -m 644 www-data/screenshots/*.png $(SHARE_DIR)/html/screenshots/ $(INSTALL) -d -m 755 $(DOC_DIR)/html/en $(INSTALL) -d -m 755 $(DOC_DIR)/html/de $(INSTALL) -c -m 644 doc/html/en/* $(DOC_DIR)/html/en/ $(INSTALL) -c -m 644 doc/html/de/* $(DOC_DIR)/html/de/ - $(INSTALL) -d -m 755 $(SHARE_DIR)/distributions - $(INSTALL) -c -m 644 conf-examples/distributions/* $(SHARE_DIR)/distributions/ clean: - $(MAKE) -C bin clean + #$(MAKE) -C bin clean -rm -rf $(BUILD_DIR) -rm -f $(BUILD_DIR)-stamp diff --git a/bin/CryptoBoxSettings.py b/bin/CryptoBoxSettings.py index 5c35e20..56e9f4f 100644 --- a/bin/CryptoBoxSettings.py +++ b/bin/CryptoBoxSettings.py @@ -355,6 +355,7 @@ DefaultVolumePrefix = string(min=1) DefaultCipher = string(default="aes-cbc-essiv:sha256") ConfigVolumeLabel = string(min=1, default="cbox_config") UseConfigPartition = integer(min=0, max=1, default=0) +DisabledPlugins = list(default=[]) [Locations] MountParentDir = directoryExists(default="/var/cache/cryptobox/mnt") diff --git a/bin/CryptoBoxWebserver.py b/bin/CryptoBoxWebserver.py index b841262..722438b 100755 --- a/bin/CryptoBoxWebserver.py +++ b/bin/CryptoBoxWebserver.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.4 +#!/usr/bin/python2.4 import os import WebInterfaceSites import sys @@ -17,7 +17,7 @@ class CryptoBoxWebserver: #expose static content: #I currently have no idea how to cleanly extract the stylesheet path from #the config object without an extra CryptoBox.CryptoBoxProps instance. - #perhaps put config handling into a seperate class in CryptoBox.py? + #perhaps put config handling into a separate class in CryptoBox.py? # # the following manual mapping is necessary, as we may not use relative # paths in the config file diff --git a/bin/Plugins.py b/bin/Plugins.py index 97a7e83..54b7757 100644 --- a/bin/Plugins.py +++ b/bin/Plugins.py @@ -50,8 +50,15 @@ class PluginManager: def __getPluginFiles(self): result = [] + if self.cbox and self.cbox.prefs["Main"]["DisabledPlugins"]: + disabled = self.cbox.prefs["Main"]["DisabledPlugins"] + else: + disabled = [] for dir in [os.path.abspath(e) for e in self.plugin_dirs if os.access(e, os.R_OK) and os.path.isdir(e)]: for plname in [f for f in os.listdir(dir)]: + if plname in disabled: + if self.cbox: self.cbox.log.info("skipped plugin '%s' (disabled via config)" % plname) + continue pldir = os.path.join(dir, plname) plfile = os.path.join(pldir, plname + ".py") if os.path.isfile(plfile) and os.access(plfile, os.R_OK): diff --git a/bin/cryptobox.conf b/bin/cryptobox.conf index 4a4f11e..5cb08ee 100644 --- a/bin/cryptobox.conf +++ b/bin/cryptobox.conf @@ -4,7 +4,7 @@ # beware: .e.g "/dev/hd" grants access to _all_ harddisks AllowedDevices = /dev/loop, /dev/ubdb -# use sepepate config partition? (1=yes / 0=no) +# use separate config partition? (1=yes / 0=no) UseConfigPartition = 1 # the default name prefix of not unnamed containers @@ -17,6 +17,9 @@ DefaultCipher = aes-plain # label of the configuration partition (you should never change this) ConfigVolumeLabel = cbox_config +# which plugins should be disabled? (comma seperated list) +#DisabledPlugins = network, shutdown, partition + [Locations] # where should we mount volumes? @@ -43,7 +46,7 @@ DocDir = ../doc/html PluginDir = ../plugins # path to the hook directory (e.g. containing some scripts) -#HookDir = /etc/cryptobox/hooks +#HookDir = /etc/cryptobox/hooks.d HookDir = ../hook-scripts diff --git a/bin/cryptoboxd b/bin/cryptoboxd index 85258bd..95ab559 100755 --- a/bin/cryptoboxd +++ b/bin/cryptoboxd @@ -1,37 +1,37 @@ #!/bin/sh -#TODO: CBXPATH=/usr/lib/cryptobox -CBXPATH=$(pwd) CBXSERVER=CryptoBoxWebserver.py -PIDFILE=/var/run/cryptobox.pid -DAEMON=/usr/bin/python2.4 -DAEMON_OPTS=${CBXPATH}/CryptoBoxWebserver.py -NAME=cryptoboxd -DESC="CryptoBox Daemon (webinterface)" -#TODO: RUNAS=cryptobox -RUNAS=$USERNAME -#test -x $DAEMON -a -f /etc/exports || exit 0 +if test -e "./$CBXSERVER" + then CBXPATH=$(pwd) + else CBXPATH=/usr/lib/cryptobox + fi + + set -e case "$1" in start) echo -n "Starting $DESC: " - start-stop-daemon --background --chdir "$CBXPATH" --chuid "$RUNAS" --start --quiet --oknodo --user "$RUNAS" --make-pidfile --pidfile "$PIDFILE" --exec "$DAEMON" \ - -- $DAEMON_OPTS + start-stop-daemon --background --chdir "$CBXPATH" --chuid "$RUNAS" --start --quiet --user "$RUNAS" --make-pidfile --pidfile "$PIDFILE" --exec "$DAEMON" -- $DAEMON_OPTS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " - #FIXME: this is the same as "killall python2.4" - # using a pid file instead prevents problems, but does not kill children??? - start-stop-daemon --stop --oknodo --exec "$DAEMON" + # does the pid file exist? + test ! -e "$PIDFILE" && echo "pid file ($PIDFILE) not found!" && exit 1 + # kill all process with the parent pid that we saved before + pkill -f -P "$(cat $PIDFILE)" -u "$RUNAS" && rm "$PIDFILE" echo "$NAME." ;; + restart ) + "$0" stop + "$0" start + ;; *) - echo "Usage: $(basename $0) {start|stop}" >&2 + echo "Usage: $(basename $0) {start|stop|restart}" >&2 exit 1 ;; esac