[PATCH] Add strlist support to hal-set-property for LUKS
W. Michael Petullo
mike at flyn.org
Tue Jul 26 18:01:32 PDT 2005
Attached you should find a new revision of the patch. I reverted to
the old configure.in technique.
The only known issue with the patch is that the volume MUST be unmounted
or hal-luks-remove will not succede. This is because the dm-crypt
device may not be removed until the volume it hosts is unmounted.
But hald won't unmount the volume until the dm-crypt device is removed.
A chicken and egg issue.
On a related note, it seems that there is a regression related to the
method interface. Hald does not seem to be acting upon the dbus method
request from gnome-volume-manager anymore. Did the interface change?
I have not yet had time to look at this closer. In the mean time,
I have been executing hal-luks-setup by hand.
--
Mike
:wq
-------------- next part --------------
diff -u --recursive --new-file hal-vanilla/ChangeLog hal/ChangeLog
--- hal-vanilla/ChangeLog 2005-07-26 19:33:58.000000000 -0500
+++ hal/ChangeLog 2005-07-26 18:37:13.000000000 -0500
@@ -1,3 +1,16 @@
+<<<<<<< ChangeLog
+2005-07-26 W. Michael Petullo <mike at flyn.org>
+
+ * tools/hal_set_property.c: Add --strlist-pre, --strlist-post
+ and --strlist-rem options to hal-set-property
+
+ * tools/hal-luks-setup.in: Use --strlist-pre to add hal-luks-remove to
+ a LUKS device's info.callouts.remove.
+
+ * tools/hal-luks-remove.in: New script to tear down dm-crypt
+ device.
+
+=======
2005-07-26 David Zeuthen <davidz at redhat.com>
* drive_id/ata.c, drive_id/drive_id.c, drive_id/scsi.c,
@@ -10,6 +23,7 @@
3.x and 4.x. Please review. Patch from Danny Kukawka
<danny.kukawka at web.de>.
+>>>>>>> 1.571
2005-07-25 David Zeuthen <davidz at redhat.com>
* hald/linux2/classdev.c (sound_add): Forgot to add alsa_.device_file
diff -u --recursive --new-file hal-vanilla/configure.in hal/configure.in
--- hal-vanilla/configure.in 2005-07-25 21:10:35.000000000 -0500
+++ hal/configure.in 2005-07-26 08:22:21.000000000 -0500
@@ -511,6 +511,7 @@
drive_id/Makefile
volume_id/Makefile
tools/hal-luks-setup
+tools/hal-luks-remove
])
dnl ==========================================================================
diff -u --recursive --new-file hal-vanilla/tools/hal-luks-remove.in hal/tools/hal-luks-remove.in
--- hal-vanilla/tools/hal-luks-remove.in 1969-12-31 18:00:00.000000000 -0600
+++ hal/tools/hal-luks-remove.in 2005-07-26 18:30:40.000000000 -0500
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# FILE: hal-luks-remove -- HAL method wrapper for cryptsetup remove
+# AUTHOR: W. Michael Petullo <mike at flyn.org>
+# DATE: 25 July 2005
+#
+# Copyright (C) 2005 W. Michael Petullo <mike at flyn.org>
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+CRYPTSETUP=/sbin/cryptsetup
+
+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 remove 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
diff -u --recursive --new-file hal-vanilla/tools/hal-luks-setup.in hal/tools/hal-luks-setup.in
--- hal-vanilla/tools/hal-luks-setup.in 2005-07-20 18:43:19.000000000 -0500
+++ hal/tools/hal-luks-setup.in 2005-07-26 08:08:10.000000000 -0500
@@ -23,16 +23,25 @@
read password
-if [ ! -f @SBINDIR@/luks-setup ]; then
+LUKSSETUP=@SBINDIR@/luks-setup
+HALSETPROPERTY=@BINDIR@/hal-set-property
+
+if [ ! -f $LUKSSETUP ]; then
echo org.freedesktop.Hal.Device.Volume.Crypto.SetupError >&2
- echo Error setting up $HAL_PROP_BLOCK_DEVICE - @SBINDIR@/luks-setup not found >&2
+ echo Error setting up $HAL_PROP_BLOCK_DEVICE - $LUKSSETUP not found >&2
exit 1
fi
-if ! echo $password | @SBINDIR@/luks-setup $HAL_PROP_BLOCK_DEVICE 2> /dev/null; then
- echo org.freedesktop.Hal.Device.Volume.Cryptoe.SetupError >&2
+if ! echo $password | $LUKSSETUP $HAL_PROP_BLOCK_DEVICE 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
+if ! $HALSETPROPERTY --udi="$HAL_PROP_INFO_UDI" --key="info.callouts.remove" --strlist-pre="hal-luks-remove" 2> /dev/null; then
+ echo org.freedesktop.Hal.Device.Volume.Crypto.SetupError >&2
+ echo Error setting info.callouts.remove >&2
+ exit 1
+fi
+
exit 0
diff -u --recursive --new-file hal-vanilla/tools/hal_set_property.c hal/tools/hal_set_property.c
--- hal-vanilla/tools/hal_set_property.c 2005-02-14 12:20:05.000000000 -0600
+++ hal/tools/hal_set_property.c 2005-07-25 21:45:35.000000000 -0500
@@ -38,6 +38,18 @@
static LibHalContext *hal_ctx;
+enum property_op {
+ PROP_INT,
+ PROP_UINT64,
+ PROP_STRING,
+ PROP_DOUBLE,
+ PROP_BOOL,
+ PROP_STRLIST_PRE,
+ PROP_STRLIST_POST,
+ PROP_STRLIST_REM,
+ PROP_INVALID
+};
+
/**
* @defgroup HalSetProperty Set HAL device property
* @ingroup HalMisc
@@ -59,7 +71,9 @@
"\n"
"usage : hal-set-property --udi <udi> --key <key>\n"
" (--int <value> | --string <value> | --bool <value> |\n"
- " --double <value> | --remove) [--help] [--version]\n");
+ " --strlist-pre <value> | --strlist-post <value> |\n"
+ " --strlist-rem <value> | --double <value> | --remove)\n"
+ " [--help] [--version]\n");
fprintf (stderr,
"\n" " --udi Unique Device Id\n"
" --key Key of the property to set\n"
@@ -70,6 +84,9 @@
" --string Set value to a string\n"
" --double Set value to a floating point number\n"
" --bool Set value to a boolean, ie. true or false\n"
+ " --strlist-pre Prepend a string to a list\n"
+ " --strlist-post Append a string to a list\n"
+ " --strlist-rem Remove a string from a list\n"
" --remove Indicates that the property should be removed\n"
" --verbose Be verbose\n"
" --version Show version and exit\n"
@@ -100,7 +117,7 @@
dbus_bool_t bool_value = TRUE;
dbus_bool_t remove = FALSE;
dbus_bool_t is_version = FALSE;
- int type = DBUS_TYPE_INVALID;
+ int type = PROP_INVALID;
DBusError error;
if (argc <= 1) {
@@ -120,6 +137,9 @@
{"string", 1, NULL, 0},
{"double", 1, NULL, 0},
{"bool", 1, NULL, 0},
+ {"strlist-pre", 1, NULL, 0},
+ {"strlist-post", 1, NULL, 0},
+ {"strlist-rem", 1, NULL, 0},
{"remove", 0, NULL, 0},
{"version", 0, NULL, 0},
{"help", 0, NULL, 0},
@@ -142,16 +162,16 @@
key = strdup (optarg);
} else if (strcmp (opt, "string") == 0) {
str_value = strdup (optarg);
- type = DBUS_TYPE_STRING;
+ type = PROP_STRING;
} else if (strcmp (opt, "int") == 0) {
int_value = strtol (optarg, NULL, 0);
- type = DBUS_TYPE_INT32;
+ type = PROP_INT;
} else if (strcmp (opt, "uint64") == 0) {
uint64_value = strtoull (optarg, NULL, 0);
- type = DBUS_TYPE_UINT64;
+ type = PROP_UINT64;
} else if (strcmp (opt, "double") == 0) {
double_value = (double) atof (optarg);
- type = DBUS_TYPE_DOUBLE;
+ type = PROP_DOUBLE;
} else if (strcmp (opt, "bool") == 0) {
if (strcmp (optarg, "true") == 0)
bool_value = TRUE;
@@ -161,7 +181,16 @@
usage (argc, argv);
return 1;
}
- type = DBUS_TYPE_BOOLEAN;
+ type = PROP_BOOL;
+ } else if (strcmp (opt, "strlist-pre") == 0) {
+ str_value = strdup (optarg);
+ type = PROP_STRLIST_PRE;
+ } else if (strcmp (opt, "strlist-post") == 0) {
+ str_value = strdup (optarg);
+ type = PROP_STRLIST_POST;
+ } else if (strcmp (opt, "strlist-rem") == 0) {
+ str_value = strdup (optarg);
+ type = PROP_STRLIST_REM;
} else if (strcmp (opt, "remove") == 0) {
remove = TRUE;
} else if (strcmp (opt, "udi") == 0) {
@@ -184,7 +213,7 @@
}
/* must have at least one, but not neither or both */
- if ((remove && type != DBUS_TYPE_INVALID) || ((!remove) && type == DBUS_TYPE_INVALID)) {
+ if ((remove && type != PROP_INVALID) || ((!remove) && type == PROP_INVALID)) {
usage (argc, argv);
return 1;
}
@@ -213,21 +242,30 @@
}
} else {
switch (type) {
- case DBUS_TYPE_STRING:
+ case PROP_STRING:
rc = libhal_device_set_property_string (hal_ctx, udi, key, str_value, &error);
break;
- case DBUS_TYPE_INT32:
+ case PROP_INT:
rc = libhal_device_set_property_int (hal_ctx, udi, key, int_value, &error);
break;
- case DBUS_TYPE_UINT64:
+ case PROP_UINT64:
rc = libhal_device_set_property_uint64 (hal_ctx, udi, key, uint64_value, &error);
break;
- case DBUS_TYPE_DOUBLE:
+ case PROP_DOUBLE:
rc = libhal_device_set_property_double (hal_ctx, udi, key, double_value, &error);
break;
- case DBUS_TYPE_BOOLEAN:
+ case PROP_BOOL:
rc = libhal_device_set_property_bool (hal_ctx, udi, key, bool_value, &error);
break;
+ case PROP_STRLIST_PRE:
+ rc = libhal_device_property_strlist_prepend (hal_ctx, udi, key, str_value, &error);
+ break;
+ case PROP_STRLIST_POST:
+ rc = libhal_device_property_strlist_append (hal_ctx, udi, key, str_value, &error);
+ break;
+ case PROP_STRLIST_REM:
+ rc = libhal_device_property_strlist_remove (hal_ctx, udi, key, str_value, &error);
+ break;
}
if (!rc) {
fprintf (stderr, "error: libhal_device_set_property: %s: %s\n", error.name, error.message);
diff -u --recursive --new-file hal-vanilla/tools/Makefile.am hal/tools/Makefile.am
--- hal-vanilla/tools/Makefile.am 2005-07-25 21:10:38.000000000 -0500
+++ hal/tools/Makefile.am 2005-07-25 21:47:10.000000000 -0500
@@ -43,7 +43,7 @@
endif
## FSTAB_SYNC_ENABLED end
-sbin_SCRIPTS = hal-luks-setup
+sbin_SCRIPTS = hal-luks-setup hal-luks-remove
EXTRA_DIST=$(man_MANS) $(MAN_IN_FILES) gen-libgphoto-hal-fdi
-------------- next part --------------
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal
More information about the Hal
mailing list