[PATCH] Add strlist support to hal-set-property for LUKS
W. Michael Petullo
mike at flyn.org
Mon Jul 25 20:44:16 PDT 2005
This patch makes the following changes:
1. Add --strlist-pre, --strlist-post and --strlist-rem options to hal-set-property.
2. hal-luks-setup now uses hal-set-property to add hal-luks-remove to
a LUKS device's info.callouts.remove.
3. Add a hal-luks-remove script.
4. Modify configure to look for luks-setup and cryptsetup to ensure
the paths are correct in hal-luks-setup and hal-luks-remove.
The patch is against hal CVS as of 25 July 2005.
--
Mike
:wq
-------------- next part --------------
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-25 21:54:25.000000000 -0500
@@ -466,6 +466,18 @@
AC_PROG_INTLTOOL([0.22])
AM_GLIB_GNU_GETTEXT
+AC_PATH_PROG(CRYPTSETUP, cryptsetup, no)
+if test x"$CRYPTSETUP" = xno; then
+ AC_MSG_WARN([cryptsetup executable not found in your path])
+fi
+AC_SUBST(CRYPTSETUP)
+
+AC_PATH_PROG(LUKSSETUP, luks-setup, no)
+if test x"$LUKSSETUP" = xno; then
+ AC_MSG_WARN([luks-setup executable not found in your path])
+fi
+AC_SUBST(LUKSSETUP)
+
AC_OUTPUT([
hal.pc
hal-storage.pc
@@ -511,6 +523,7 @@
drive_id/Makefile
volume_id/Makefile
tools/hal-luks-setup
+tools/hal-luks-remove
])
dnl ==========================================================================
Binary files hal-vanilla/po/da.gmo and hal/po/da.gmo differ
Binary files hal-vanilla/po/de.gmo and hal/po/de.gmo differ
Binary files hal-vanilla/po/es.gmo and hal/po/es.gmo differ
Binary files hal-vanilla/po/fr.gmo and hal/po/fr.gmo differ
Binary files hal-vanilla/po/hu.gmo and hal/po/hu.gmo differ
Binary files hal-vanilla/po/it.gmo and hal/po/it.gmo differ
Binary files hal-vanilla/po/nb.gmo and hal/po/nb.gmo differ
Binary files hal-vanilla/po/nl.gmo and hal/po/nl.gmo differ
Binary files hal-vanilla/po/pt.gmo and hal/po/pt.gmo differ
Binary files hal-vanilla/po/ru.gmo and hal/po/ru.gmo differ
Binary files hal-vanilla/po/zh_TW.gmo and hal/po/zh_TW.gmo differ
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-25 22:30:23.000000000 -0500
@@ -0,0 +1,34 @@
+#!/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
+
+if [ ! -f @CRYPTSETUP@ ]; then
+ echo Error removing $HAL_PROP_BLOCK_DEVICE - @CRYPTSETUP@ not found >&2
+ exit 1
+fi
+
+if ! @CRYPTSETUP@ remove $HAL_PROP_VOLUME_UUID 2> /dev/null; then
+ echo Error removing $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-25 22:14:46.000000000 -0500
@@ -23,16 +23,22 @@
read password
-if [ ! -f @SBINDIR@/luks-setup ]; then
+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 ! @BINDIR@/hal-set-property --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