diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b156e63..25412e6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "fuse") SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://cryfs.org") SET(CPACK_RPM_PACKAGE_LICENSE "LGPLv3") - +SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debfiles/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debfiles/postrm") INCLUDE(CPack) diff --git a/debfiles/postinst b/debfiles/postinst new file mode 100755 index 00000000..276c4182 --- /dev/null +++ b/debfiles/postinst @@ -0,0 +1,135 @@ +#!/bin/bash +# This script is called after the cryfs .deb package is installed. +# It sets up the package source so the user gets automatic updates for cryfs. + +# DEVELOPER WARNING: There is a lot of redundancy between this file and the install.sh script in the cryfs-web repository. Please port modifications to there! + +set -e + +DEBIAN_VERSIONS="jessie" +UBUNTU_VERSIONS="precise trusty vivid wily" + +DEBIAN_REPO_URL="http://apt.cryfs.org/debian" +UBUNTU_REPO_URL="http://apt.cryfs.org/ubuntu" + +DISTRIBUTION=`lsb_release -s -i` +DISTRIBUTION_VERSION=`lsb_release -s -c` + +containsElement () { + local e + for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done + return 1 +} + +get_repo_url () { + if [[ "$DISTRIBUTION" == "Debian" ]]; then + if ! containsElement $DISTRIBUTION_VERSION $DEBIAN_VERSIONS; then + echo Unsupported Debian Version: $DISTRIBUTION_VERSION 1>&2 + exit 1 + fi + echo $DEBIAN_REPO_URL + elif [[ "$DISTRIBUTION" == "Ubuntu" ]]; then + if ! containsElement $DISTRIBUTION_VERSION $UBUNTU_VERSIONS; then + echo Unsupported Ubuntu Version: $DISTRIBUTION_VERSION 1>&2 + exit 1 + fi + echo $UBUNTU_REPO_URL + else + echo Unsupported Operating System: $DISTRIBUTION 1>&2 + exit 1 + fi +} + +get_apt_config () { + apt-config dump|grep "$1 "|sed -e "s/^$1\ \"\([^\"]*\)\"\;/\1/g" +} + +sources_list_dir () { + root=$(get_apt_config "Dir") + etc=$(get_apt_config "Dir::Etc") + sourceparts=$(get_apt_config "Dir::Etc::sourceparts") + echo $root$etc$sourceparts +} + +add_repository () { + dir=$(sources_list_dir) + repo_url=$(get_repo_url) + echo "deb $repo_url $DISTRIBUTION_VERSION main" > $dir/cryfs.list +} + +install_key () { + # Key from http://www.cryfs.org/apt.key + apt-key add - > /dev/null <&2 + exit 1 + ;; +esac + +set +e + +exit 0 diff --git a/debfiles/postrm b/debfiles/postrm new file mode 100755 index 00000000..ac097bba --- /dev/null +++ b/debfiles/postrm @@ -0,0 +1,45 @@ +#!/bin/bash +# This script is called after the cryfs .deb package is uninstalled. +# It removes the package source that was used to get automatic updates. + +set -e + +get_apt_config () { + apt-config dump|grep "$1 "|sed -e "s/^$1\ \"\([^\"]*\)\"\;/\1/g" +} + +sources_list_dir () { + root=$(get_apt_config "Dir") + etc=$(get_apt_config "Dir::Etc") + sourceparts=$(get_apt_config "Dir::Etc::sourceparts") + echo $root$etc$sourceparts +} + +remove_repository () { + dir=$(sources_list_dir) + rm -f $dir/cryfs.list +} + +remove_key () { + # Don't fail if key was already removed + apt-key rm 549E65B2 2>&1 > /dev/null || true +} + +case "$1" in + purge) + remove_repository + remove_key + ;; + + abort-install|abort-upgrade|remove|upgrade|failed-upgrade) + ;; + + *) + echo "postrm called with unknown argument '$1'" >&2 + exit 1 + ;; +esac + +set +e + +exit 0 diff --git a/src/cli/Cli.cpp b/src/cli/Cli.cpp index be5ee85b..0604530b 100644 --- a/src/cli/Cli.cpp +++ b/src/cli/Cli.cpp @@ -28,6 +28,7 @@ #error The used libc implementation has a maximal password size for getpass(). We cannot use it to ask for passwords. #endif +//TODO Fails with gpg-homedir in filesystem: gpg --homedir gpg-homedir --gen-key //TODO Many functions accessing the ProgramOptions object. Factor out into class that stores it as a member. //TODO Factor out class handling askPassword