From 3da483ffec964c37a8235ef68232f4544aedf83c Mon Sep 17 00:00:00 2001 From: lars Date: Wed, 17 May 2006 09:54:22 +0000 Subject: [PATCH] distributions specific config file introduced (for program locations) pmount added to debian dependencies --- Makefile | 10 ++++++++++ bin/Makefile | 4 ++-- bin/cbox-manage.sh | 9 ++++++++- bin/cbox-root-actions.sh | 6 ++++-- bin/cryptobox.pl | 2 ++ bin/init-script.sh | 4 ++-- conf-examples/cryptobox.conf | 11 +++-------- conf-examples/distributions/README | 11 +++++++++++ conf-examples/distributions/gnu_linux | 9 +++++++++ debian/control | 4 ++-- debian/rules | 3 ++- 11 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 conf-examples/distributions/README create mode 100644 conf-examples/distributions/gnu_linux diff --git a/Makefile b/Makefile index f9d275a..a3eedd1 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ DOC_DIR = $(PREFIX)/share/doc/cryptobox BUILD_DIR = build_dir INSTALL = install +OS_TYPE=$(shell uname -o | tr [:upper:] [:lower:] | sed s/[^a-z0-9\._\-]/_/g) + .PHONY: install clean build build: @@ -23,6 +25,12 @@ build: @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 @@ -51,6 +59,8 @@ install: $(BUILD_DIR)-stamp $(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: diff --git a/bin/Makefile b/bin/Makefile index 0f536ac..6023795 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -21,13 +21,13 @@ build: $(CGI_SUID_FILE) $(ROOT_SUID_FILE) $(CGI_SUID_FILE): $(SRC_FILE) - $(NOECHO) echo '#define EXEC_PATH "$(LIB_DIR)/$(CGI_FILENAME)"' >$(HEADER_FILE) + @echo '#define EXEC_PATH "$(LIB_DIR)/$(CGI_FILENAME)"' >$(HEADER_FILE) $(CC) -o $(CGI_SUID_FILE) $(SRC_FILE) -rm $(HEADER_FILE) $(ROOT_SUID_FILE): $(SRC_FILE) - $(NOECHO) echo '#define EXEC_PATH "$(LIB_DIR)/$(ROOT_SCRIPT_FILENAME)"' >$(HEADER_FILE) + @echo '#define EXEC_PATH "$(LIB_DIR)/$(ROOT_SCRIPT_FILENAME)"' >$(HEADER_FILE) $(CC) -o $(ROOT_SUID_FILE) $(SRC_FILE) -rm $(HEADER_FILE) diff --git a/bin/cbox-manage.sh b/bin/cbox-manage.sh index c8e686e..c11b3e8 100755 --- a/bin/cbox-manage.sh +++ b/bin/cbox-manage.sh @@ -32,8 +32,15 @@ CONFIG_DIR=~/config # read the default setting file, if it exists [ -e /etc/default/cryptobox ] && . /etc/default/cryptobox +[ ! -e "$CONF_FILE" ] && error_msg 1 "Could not find the configuration file: $CONF_FILE" + # parse config file -. "$CONF_FILE" +source "$CONF_FILE" + +[ ! -e "$CONF_FILE" ] && error_msg 1 "Could not find the distribution specific configuration file: $CONF_FILE" + +# parse the distribution specific file +source "$DISTRIBUTION_CONF" # check for writable log file [ -w "$LOG_FILE" ] || LOG_FILE=/tmp/$(basename "$LOG_FILE") diff --git a/bin/cbox-root-actions.sh b/bin/cbox-root-actions.sh index 0d33271..9f1ce6d 100755 --- a/bin/cbox-root-actions.sh +++ b/bin/cbox-root-actions.sh @@ -20,12 +20,14 @@ set -eu [ "$(id -u)" -ne 0 ] && echo "$(basename $0) - only root may call this script" >&2 && exit 100 # read the default setting file, if it exists -[ -e /etc/default/cryptobox ] && . /etc/default/cryptobox +[ -e /etc/default/cryptobox ] && source /etc/default/cryptobox # set CONF_FILE to default value, if not configured in /etc/default/cryptobox CONF_FILE=${CONF_FILE:-/etc/cryptobox/cryptobox.conf} # parse config file -. "$CONF_FILE" +source "$CONF_FILE" +# parse distribution specific file +source "$DISTRIBUTION_CONF" ############ some useful functions ############### diff --git a/bin/cryptobox.pl b/bin/cryptobox.pl index ff1c3bb..e3dfe45 100755 --- a/bin/cryptobox.pl +++ b/bin/cryptobox.pl @@ -737,5 +737,7 @@ $pagedata->setValue('Data.QueryString', "$querystring") if ($querystring ne ''); &render(); +close STDOUT; + exit 0; diff --git a/bin/init-script.sh b/bin/init-script.sh index 33b2cba..c9112b2 100755 --- a/bin/init-script.sh +++ b/bin/init-script.sh @@ -11,7 +11,7 @@ [ -e "/usr/lib/cryptobox/cbox-manage.sh" ] || exit 0 # read the default setting file, if it exists -[ -e /etc/default/cryptobox ] && . /etc/default/cryptobox +[ -e /etc/default/cryptobox ] && source /etc/default/cryptobox # startup switch defaults to zero (enabled) NO_START=${NO_START:-0} @@ -29,7 +29,7 @@ CONF_FILE=${CONF_FILE:-/etc/cryptobox/cryptobox.conf} # parse config file if [ -e "$CONF_FILE" ] - then . "$CONF_FILE" + then source "$CONF_FILE" else echo "[$(basename $0)] - configuration file ($CONF_FILE) not found!" >&2 exit 1 fi diff --git a/conf-examples/cryptobox.conf b/conf-examples/cryptobox.conf index 66211e4..13f5fb2 100644 --- a/conf-examples/cryptobox.conf +++ b/conf-examples/cryptobox.conf @@ -3,7 +3,6 @@ LANGUAGE=en NET_IFACE=eth0 -FILE_USER=cryptobox-data CRYPTOBOX_USER=cryptobox SCAN_DEVICES="sda" #SCAN_DEVICES="hda hdb hdc hdd hde hdf hdg scd sg sda sdb sdc sdd" @@ -30,10 +29,6 @@ CONFIG_MARKER=cryptobox.marker DEFAULT_CIPHER=aes-cbc-essiv:sha256 DEV_MAPPER_DIR=/dev/mapper -# some programs -SFDISK=/sbin/sfdisk -MKFS_DATA=/sbin/mkfs.ext3 -MKFS_CONFIG=/sbin/mkfs.ext2 -CRYPTSETUP=/sbin/cryptsetup -IFCONFIG=/sbin/ifconfig - +# distribution specific configuration +# examples can be found in /usr/local/share/cryptobox/distributions +DISTRIBUTION_CONF=/etc/cryptobox/distribution.conf diff --git a/conf-examples/distributions/README b/conf-examples/distributions/README new file mode 100644 index 0000000..7a9edfa --- /dev/null +++ b/conf-examples/distributions/README @@ -0,0 +1,11 @@ +You need to copy one of these files to /etc/cryptobox/distribution.conf. +Choose the one, that fits to your particular operating system - if you are +not sure which operation system you are using, then you should run + uname -o +to get to know yourself :) + +If the file for your specific operating system is not available, then you +may consider to send a copy of the one you wrote for yourself to + devel@systemausfall.org. +Thanks! + diff --git a/conf-examples/distributions/gnu_linux b/conf-examples/distributions/gnu_linux new file mode 100644 index 0000000..e50a928 --- /dev/null +++ b/conf-examples/distributions/gnu_linux @@ -0,0 +1,9 @@ +# program locations for debian +SFDISK=/sbin/sfdisk +MKFS_DATA=/sbin/mkfs.ext3 +MKFS_CONFIG=/sbin/mkfs.ext2 +CRYPTSETUP=/sbin/cryptsetup +IFCONFIG=/sbin/ifconfig +PMOUNT=/bin/pmount +PUMOUNT=/bin/pumount + diff --git a/debian/control b/debian/control index 3086226..6ef41aa 100644 --- a/debian/control +++ b/debian/control @@ -6,8 +6,8 @@ Build-Depends: debhelper (>>3.0.0), dpatch, gcc (>=2.95) Standards-Version: 3.6.2 Package: cryptobox -Architecture: all -Depends: bash (>=2.0), sed (>=4.0), coreutils, grep (>=2.0), perl, httpd-cgi, hashalot, libconfigfile-perl, cryptsetup (>=20050111), dmsetup, at +Architecture: any +Depends: bash (>=2.0), sed (>=4.0), coreutils, grep (>=2.0), perl, httpd-cgi, hashalot, libconfigfile-perl, cryptsetup (>=20050111), dmsetup, at, pmount Recommends: perl-clearsilver Suggests: stunnel, cron, iptables, samba Description: Web interface for an encrypting fileserver diff --git a/debian/rules b/debian/rules index d2c4205..19dfcef 100755 --- a/debian/rules +++ b/debian/rules @@ -20,7 +20,7 @@ DEB_BUILD_DIR=$(CURDIR)/debian/cryptobox configure: configure-stamp configure-stamp: patch dh_testdir - # PUT SOMETHING HERE + @# PUT SOMETHING HERE touch configure-stamp @@ -56,6 +56,7 @@ install: build dh_installdirs $(MAKE) install PREFIX=$(DEB_BUILD_DIR)/usr install -c -m 644 build_dir/etc/cryptobox.conf $(DEB_BUILD_DIR)/etc/cryptobox/ + install -c -m 644 build_dir/etc/distribution.conf $(DEB_BUILD_DIR)/etc/cryptobox/ install -c -m 644 conf-examples/defaults-cryptobox.conf $(DEB_BUILD_DIR)/etc/default/cryptobox install -c -m 755 bin/init-script.sh $(DEB_BUILD_DIR)/etc/init.d/cryptobox install -c -m 755 bin/cryptobox_cgi_wrapper $(DEB_BUILD_DIR)/usr/lib/cgi-bin/cryptobox