hal/tools Makefile.am, 1.31, 1.32 hal-luks-remove, NONE, 1.1 hal-luks-remove.in, 1.3, NONE hal-luks-setup, NONE, 1.1 hal-luks-setup.in, 1.4, NONE hal-luks-teardown, NONE, 1.1 hal-system-storage-unmount, 1.6, 1.7

David Zeuthen david at freedesktop.org
Sun Feb 12 23:29:47 PST 2006


Update of /cvs/hal/hal/tools
In directory gabe:/tmp/cvs-serv8530/tools

Modified Files:
	Makefile.am hal-system-storage-unmount 
Added Files:
	hal-luks-remove hal-luks-setup hal-luks-teardown 
Removed Files:
	hal-luks-remove.in hal-luks-setup.in 
Log Message:
2006-02-13  David Zeuthen  <davidz at redhat.com>

        * configure.in: Don't generate tools/hal-luks-remove.in,
        tools/hal-luks-setup.in

        * fdi/policy/10osvendor/15-storage-luks.fdi: Also export Teardown
        method

        * tools/hal-luks-remove.in, tools/hal-luks-setup.in: Remove, just
        use hardcoded paths

        * tools/hal-luks-teardown: New file for tearing down the mapping

        * tools/hal-luks-remove: Use cryptsetup rather than luks-setup,
        add to CVS

        * tools/hal-luks-setup: Use cryptsetup rather than luks-setup,
        add to CVS

        * tools/Makefile.am (script_SCRIPTS): Add hal-luks-teardown



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/Makefile.am,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- Makefile.am	12 Feb 2006 22:38:45 -0000	1.31
+++ Makefile.am	13 Feb 2006 07:29:44 -0000	1.32
@@ -42,7 +42,9 @@
 scriptdir = $(datadir)/hal/scripts
 
 script_SCRIPTS =				\
-	hal-luks-setup hal-luks-remove		\
+	hal-luks-setup                          \
+	hal-luks-teardown                       \
+	hal-luks-remove		                \
 	hal-system-power-suspend		\
 	hal-system-power-hibernate		\
 	hal-system-power-shutdown		\

--- NEW FILE: hal-luks-remove ---
#!/bin/bash

# Copyright (C) 2005 W. Michael Petullo <mike at flyn.org>
# Copyright (C) 2006 David Zeuthen <davidz at redhat.com>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.

if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] || [ "$HAL_PROP_VOLUME_UUID" == "" ] ; then
        echo "Missing or empty environment variable(s)." >&2
        echo "This script should be started by hald." >&2
        exit 1
fi

CRYPTSETUP=/sbin/cryptsetup

# make sure that the cleartext volume is unmounted
CLEARTEXT_VOLUME_UDI=`hal-find-by-property --key volume.crypto_luks.clear.backing_volume --string $HAL_PROP_INFO_UDI`
RET=$?
if [ x$RET = x0 ]; then
    MOUNT_POINT=`hal-get-property --udi $CLEARTEXT_VOLUME_UDI --key volume.mount_point`
    if [ ! x${#MOUNT_POINT} = x0 ]; then
	/bin/umount -l "$MOUNT_POINT"
        # remove directory only if HAL has created it
	if [ -e "$MOUNT_POINT/.created-by-hal" ]; then
	    rm -f "$MOUNT_POINT/.created-by-hal"
	    rmdir --ignore-fail-on-non-empty "$MOUNT_POINT"
	fi
	
    fi
fi

if [ ! -f $CRYPTSETUP ]; then
	echo Error removing $HAL_PROP_BLOCK_DEVICE - $CRYPTSETUP not found >&2
	exit 1
fi

if [ -z $HAL_PROP_VOLUME_UUID ]; then
	echo Error determining UUID of $HAL_PROP_BLOCK_DEVICE >&2
	exit 1
fi

if ! $CRYPTSETUP luksClose luks_crypto_$HAL_PROP_VOLUME_UUID 2> /dev/null; then
	echo Error removing luks_crypto_$HAL_PROP_VOLUME_UUID >&2
	exit 1
fi

exit 0

--- hal-luks-remove.in DELETED ---

--- NEW FILE: hal-luks-setup ---
#!/bin/bash

# Copyright (C) 2005 W. Michael Petullo <mike at flyn.org>
# Copyright (C) 2006 David Zeuthen <davidz at redhat.com>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.

if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] || [ "$HAL_PROP_VOLUME_UUID" == "" ] ; then
        echo "Missing or empty environment variable(s)." >&2
        echo "This script should be started by hald." >&2
        exit 1
fi

read password
PASSWORD=${PASSWORD//[^[:alnum:]_=[:space:]:.+-]/@}

CRYPTSETUP=/sbin/cryptsetup

if [ ! -f $CRYPTSETUP ]; then
	echo org.freedesktop.Hal.Device.Volume.Crypto.SetupError >&2
	echo Error setting up $HAL_PROP_BLOCK_DEVICE - $CRYPTSETUP not found >&2
	exit 1
fi

if ! echo $password | $CRYPTSETUP luksOpen $HAL_PROP_BLOCK_DEVICE luks_crypto_$HAL_PROP_VOLUME_UUID  2> /dev/null; then
	echo org.freedesktop.Hal.Device.Volume.Crypto.SetupError >&2
	echo Error setting up $HAL_PROP_BLOCK_DEVICE - bad password? >&2
	exit 1
fi

hal-set-property --udi=$UDI --key="info.callouts.remove" --strlist-pre="hal-luks-remove" > /dev/null 2>&1

exit 0

--- hal-luks-setup.in DELETED ---

--- NEW FILE: hal-luks-teardown ---
#!/bin/bash

# Copyright (C) 2005 W. Michael Petullo <mike at flyn.org>
# Copyright (C) 2006 David Zeuthen <davidz at redhat.com>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.

# Check for environment variables
if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] || [ "$HAL_PROP_VOLUME_UUID" == "" ] ; then
        echo "Missing or empty environment variable(s)." >&2
        echo "This script should be started by hald." >&2
        exit 1
fi

CRYPTSETUP=/sbin/cryptsetup

if [ ! -f $CRYPTSETUP ]; then
	echo org.freedesktop.Hal.Device.Volume.Crypto.TeardownError >&2
	echo Error tearing down $HAL_PROP_BLOCK_DEVICE - $CRYPTSETUP not found >&2
	exit 1
fi

if ! $CRYPTSETUP luksClose luks_crypto_$HAL_PROP_VOLUME_UUID  2> /dev/null; then
	echo org.freedesktop.Hal.Device.Volume.Crypto.TeardownError >&2
	echo Error tearing down $HAL_PROP_BLOCK_DEVICE - fs still mounted? >&2
	exit 1
fi

Index: hal-system-storage-unmount
===================================================================
RCS file: /cvs/hal/hal/tools/hal-system-storage-unmount,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- hal-system-storage-unmount	12 Feb 2006 21:47:28 -0000	1.6
+++ hal-system-storage-unmount	13 Feb 2006 07:29:44 -0000	1.7
@@ -103,8 +103,8 @@
 fi
 
 # remove directory only if HAL has created it
-if [ -e $MOUNT_POINT/.created-by-hal ]; then
-  rm -f $MOUNT_POINT/.created-by-hal
+if [ -e "$MOUNT_POINT/.created-by-hal" ]; then
+  rm -f "$MOUNT_POINT/.created-by-hal"
   rmdir --ignore-fail-on-non-empty "$MOUNT_POINT"
 fi
 




More information about the hal-commit mailing list