summaryrefslogtreecommitdiff
path: root/tools/hal-luks-teardown
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2007-03-27 02:33:05 -0400
committerDavid Zeuthen <davidz@redhat.com>2007-03-27 02:33:05 -0400
commit28fc2fa7c6bbde540d4f17e810ab59fda0c186ba (patch)
treef717d3a84d9317407466281050aec6ea9915b8ee /tools/hal-luks-teardown
parent583de1e89c8043180814921c860f85c4cd9ed58b (diff)
make LUKS setup/teardown respect the standard .Volume and .Storage locks
This required a new tool hal-is-caller-locked-out. Also add a manual page for this tool.
Diffstat (limited to 'tools/hal-luks-teardown')
-rwxr-xr-xtools/hal-luks-teardown23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/hal-luks-teardown b/tools/hal-luks-teardown
index f6e83590..387cdfa9 100755
--- a/tools/hal-luks-teardown
+++ b/tools/hal-luks-teardown
@@ -6,6 +6,12 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.
+locked_out() {
+ echo "org.freedesktop.Hal.Device.InterfaceLocked" >&2
+ echo "Enclosing drive/volume is locked" >&2
+ exit 1
+}
+
# Check for environment variables
if [ -z "$HAL_PROP_BLOCK_DEVICE" ] || [ -z "$HAL_PROP_INFO_UDI" ] || [ -z "$HAL_PROP_VOLUME_UUID" ] ; then
echo "org.freedesktop.Hal.Device.UnknownError" >&2
@@ -14,6 +20,23 @@ if [ -z "$HAL_PROP_BLOCK_DEVICE" ] || [ -z "$HAL_PROP_INFO_UDI" ] || [ -z "$HAL_
exit 1
fi
+# Respect the same locks as Mount()/Unmount() etc.
+if [ -n "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME" ] ; then
+ hal-is-caller-locked-out --udi $HAL_PROP_INFO_UDI \
+ --interface org.freedesktop.Hal.Volume \
+ --caller $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME
+ RET=$?
+ if [ "$RET" != "1" ] ; then
+ locked_out
+ fi
+ hal-is-caller-locked-out --udi $HAL_PROP_STORAGE_ORIGINATING_DEVICE \
+ --interface org.freedesktop.Hal.Storage \
+ --caller $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME
+ RET=$?
+ if [ "$RET" != "1" ] ; then
+ locked_out
+ fi
+fi
if [ -n "$HALD_UNAME_S" -a -x ./$HALD_UNAME_S/hal-luks-teardown-$HALD_UNAME_S ]; then
exec ./$HALD_UNAME_S/hal-luks-teardown-$HALD_UNAME_S $@