hal/hald/linux2 blockdev.c, 1.30, 1.31 classdev.c, 1.40,
1.41 osspec.c, 1.39, 1.40
David Zeuthen
david at freedesktop.org
Fri Jan 20 18:45:29 PST 2006
- Previous message: hal/doc/spec hal-spec.html,1.71,1.72
- Next message: hal/hald Makefile.am, 1.52, 1.53 debug-hald.sh, 1.4, 1.5 hald.c,
1.45, 1.46 hald_dbus.c, 1.48, 1.49 hald_dbus.h, 1.10,
1.11 hald_runner.c, NONE, 1.1 hald_runner.h, NONE,
1.1 haldaemon.in, 1.6, 1.7 run-hald.sh, 1.7, 1.8 util.c, 1.34,
1.35 util.h, 1.15, 1.16 valgrind-hald.sh, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv12741/hald/linux2
Modified Files:
blockdev.c classdev.c osspec.c
Log Message:
2006-01-20 David Zeuthen <davidz at redhat.com>
Great patch from Sjoerd Simons <sjoerd at luon.net>: As most people
probably know by now, various people don't really like that hal
running as root. We'd much rather see only a small process running
as root and the main hal process running unpriviledged. Which is
exactly what this patch does :)
How does it work? Just before drops it's root privs. a small
program is startup which will remain running as root and does the
real execution of the addons/probes/callouts on hals
behalf. Communication between hald and hald-runner is done via a
p2p dbus connection. Resulting in a process tree like this:
hal /usr/sbin/hald
root \_ /usr/lib/hal/hald-runner
root \_ /usr/lib/hal/hald-addon-acpi
root \_ /usr/lib/hal/hald-addon-storage
root \_ /usr/lib/hal/hald-addon-storage
The patch consists out of two parts. First the implementation of
hald-runner, which is about 700 lines of code. And then a part
transforming the hald code from the current spawning code in utils
to an interface that can talk to the runner.
* AUTHORS: Add Sjoerd Simons <sjoerd at luon.net>. Revise my own
email address.
* configure.in (AC_OUTPUT): Add hald-runner
* Makefile.am (SUBDIRS): Add hald-runner
* hald/Makefile.am (hald_SOURCES): add hald_runner.[ch]
* hald-runner/utils.c, hald-runner/utils.h, hald-runner/runner.c,
hald-runner/runner.h, hald-runner/main.c, hald-runner/Makefile.am,
hald/linux2/osspec.c, hald/linux2/classdev.c,
hald/linux2/blockdev.c, hald/util.[ch], hald/hald_dbus.c,
hald/hald.c, hald/hald_runner.[ch]: New and changed files with
slight changes. See the descriptive text above and discussion at
http://lists.freedesktop.org/archives/hal/2006-January/004327.html
for details.
Changed function hald_runner_start_runner() in hald/hald_runner.c
to print out runner path and improve error handling when runner
is not found. Also removed dbus_server_unref (server) in
handle_connection() in same file.
* hald/haldaemon.in: Remove --retain-privileges as this is no longer
needed
* hald/run-hald.sh, hald/debug-hald.sh, hald/valgrind-hald.sh:
Remove --retain-privileges and use --with-runner pointing to
../hald-runner/hald-runner
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- blockdev.c 20 Jan 2006 15:40:03 -0000 1.30
+++ blockdev.c 21 Jan 2006 02:45:27 -0000 1.31
@@ -60,6 +60,7 @@
#include "../device_info.h"
#include "../hald_dbus.h"
#include "../util.h"
+#include "../hald_runner.h"
#include "osspec_linux.h"
@@ -269,15 +270,16 @@
}
static void
-add_blockdev_probing_helper_done (HalDevice *d, gboolean timed_out, gint return_code,
- gpointer data1, gpointer data2, HalHelperData *helper_data)
+add_blockdev_probing_helper_done (HalDevice *d, guint32 exit_type,
+ gint return_code, char **error,
+ gpointer data1, gpointer data2)
{
void *end_token = (void *) data1;
gboolean is_volume;
/* helper_data may be null if probing is skipped */
- HAL_INFO (("entering; timed_out=%d, return_code=%d", timed_out, return_code));
+ HAL_INFO (("entering; exit_type=%d, return_code=%d", exit_type, return_code));
if (d == NULL) {
HAL_INFO (("Device object already removed"));
@@ -291,7 +293,8 @@
*
* (return code 2 means fs found on main block device (for non-volumes))
*/
- if (timed_out || !(return_code == 0 || (!is_volume && return_code == 2))) {
+ if (exit_type != HALD_RUN_SUCCESS
+ || !(return_code == 0 || (!is_volume && return_code == 2))) {
hal_device_store_remove (hald_get_tdl (), d);
g_object_unref (d);
hotplug_event_end (end_token);
@@ -369,15 +372,12 @@
HAL_INFO (("Probing PC floppy %s to see if it is present",
hal_device_property_get_string (d, "block.device")));
- if (hal_util_helper_invoke ("hald-probe-pc-floppy", NULL, d, (gpointer) end_token,
- NULL, add_blockdev_probing_helper_done,
- HAL_HELPER_TIMEOUT) == NULL) {
- hal_device_store_remove (hald_get_tdl (), d);
- g_object_unref (d);
- hotplug_event_end (end_token);
- }
+ hald_runner_run(d,
+ "hald-probe-pc-floppy", NULL,
+ HAL_HELPER_TIMEOUT,
+ add_blockdev_probing_helper_done,
+ (gpointer) end_token, NULL);
goto out;
-
} else {
HAL_INFO (("Not probing storage device %s",
hal_device_property_get_string (d, "block.device")));
@@ -397,14 +397,12 @@
HAL_INFO (("Probing storage device %s", hal_device_property_get_string (d, "block.device")));
/* probe the device */
- if (hal_util_helper_invoke ("hald-probe-storage", NULL, d, (gpointer) end_token,
- NULL, add_blockdev_probing_helper_done,
- HAL_HELPER_TIMEOUT) == NULL) {
- hal_device_store_remove (hald_get_tdl (), d);
- g_object_unref (d);
- hotplug_event_end (end_token);
- }
-
+ hald_runner_run(d,
+ "hald-probe-storage", NULL,
+ HAL_HELPER_TIMEOUT,
+ add_blockdev_probing_helper_done,
+ (gpointer) end_token, NULL);
+
out:
;
}
@@ -434,14 +432,11 @@
}
/* probe the device */
- if (hal_util_helper_invoke ("hald-probe-volume", NULL, d, (gpointer) end_token,
- NULL, add_blockdev_probing_helper_done,
- HAL_HELPER_TIMEOUT) == NULL) {
- hal_device_store_remove (hald_get_tdl (), d);
- g_object_unref (d);
- hotplug_event_end (end_token);
- }
-
+ hald_runner_run (d,
+ "hald-probe-volume", NULL,
+ HAL_HELPER_TIMEOUT,
+ add_blockdev_probing_helper_done,
+ (gpointer) end_token, NULL);
out:
;
}
@@ -1142,14 +1137,15 @@
}
static void
-block_rescan_storage_done (HalDevice *d, gboolean timed_out, gint return_code,
- gpointer data1, gpointer data2, HalHelperData *helper_data)
+block_rescan_storage_done (HalDevice *d, guint32 exit_type,
+ gint return_code, gchar **error,
+ gpointer data1, gpointer data2)
{
const char *sysfs_path;
HalDevice *fakevolume;
char fake_sysfs_path[HAL_PATH_MAX];
- HAL_INFO (("hald-probe-storage --only-check-for-media returned %d (timed_out=%d)", return_code, timed_out));
+ HAL_INFO (("hald-probe-storage --only-check-for-media returned %d (exit_type=%d)", return_code, exit_type));
if (d == NULL) {
HAL_INFO (("Device object already removed"));
@@ -1200,13 +1196,11 @@
}
/* now see if we got a file system on the main block device */
- if (hal_util_helper_invoke ("hald-probe-storage --only-check-for-media", NULL, d, NULL,
- NULL, block_rescan_storage_done,
- HAL_HELPER_TIMEOUT) == NULL) {
- HAL_INFO (("Could not invoke 'hald-probe-storage --only-check-for-media'"));
- goto out;
- }
-
+ hald_runner_run (d,
+ "hald-probe-storage --only-check-for-media", NULL,
+ HAL_HELPER_TIMEOUT,
+ block_rescan_storage_done,
+ NULL, NULL);
ret = TRUE;
out:
Index: classdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/classdev.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- classdev.c 13 Jan 2006 16:40:31 -0000 1.40
+++ classdev.c 21 Jan 2006 02:45:27 -0000 1.41
@@ -65,6 +65,7 @@
#include "../device_info.h"
#include "../device_store.h"
#include "../util.h"
+#include "../hald_runner.h"
#include "osspec_linux.h"
@@ -1282,13 +1283,14 @@
}
static void
-add_classdev_probing_helper_done (HalDevice *d, gboolean timed_out, gint return_code,
- gpointer data1, gpointer data2, HalHelperData *helper_data)
+add_classdev_probing_helper_done (HalDevice *d, guint32 exit_type,
+ gint return_code, char **error,
+ gpointer data1, gpointer data2)
{
void *end_token = (void *) data1;
ClassDevHandler *handler = (ClassDevHandler *) data2;
- HAL_INFO (("entering; timed_out=%d, return_code=%d", timed_out, return_code));
+ HAL_INFO (("entering; exit_type=%d, return_code=%d", exit_type, return_code));
if (d == NULL) {
HAL_INFO (("Device object already removed"));
@@ -1297,7 +1299,7 @@
}
/* Discard device if probing reports failure */
- if (return_code != 0) {
+ if (exit_type != HALD_RUN_SUCCESS || return_code != 0) {
hal_device_store_remove (hald_get_tdl (), d);
g_object_unref (d);
hotplug_event_end (end_token);
@@ -1350,20 +1352,16 @@
prober = NULL;
if (prober != NULL) {
/* probe the device */
- if (hal_util_helper_invoke (prober, NULL, d, (gpointer) end_token,
- (gpointer) handler, add_classdev_probing_helper_done,
- HAL_HELPER_TIMEOUT) == NULL) {
- hal_device_store_remove (hald_get_tdl (), d);
- g_object_unref (d);
- hotplug_event_end (end_token);
- }
- goto out;
+ hald_runner_run(d,
+ prober, NULL,
+ HAL_HELPER_TIMEOUT,
+ add_classdev_probing_helper_done,
+ (gpointer) end_token, (gpointer) handler);
} else {
add_classdev_after_probing (d, handler, end_token);
- goto out;
}
out:
- ;
+ ;
}
void
Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- osspec.c 12 Jan 2006 17:48:44 -0000 1.39
+++ osspec.c 21 Jan 2006 02:45:27 -0000 1.40
@@ -66,6 +66,7 @@
#include "../logger.h"
#include "../hald.h"
#include "../hald_dbus.h"
+#include "../hald_runner.h"
#include "../device_info.h"
#include "../util.h"
@@ -457,8 +458,9 @@
}
static void
-computer_probing_pcbios_helper_done (HalDevice *d, gboolean timed_out, gint return_code,
- gpointer data1, gpointer data2, HalHelperData *helper_data)
+computer_probing_pcbios_helper_done (HalDevice *d, guint32 exit_type,
+ gint return_code, gchar **error,
+ gpointer data1, gpointer data2)
{
const char *chassis_type;
const char *system_manufacturer;
@@ -635,16 +637,15 @@
/* TODO: add prober for PowerMac's */
if (should_decode_dmi) {
- if (hal_util_helper_invoke ("hald-probe-smbios", NULL, root, NULL, NULL,
- computer_probing_pcbios_helper_done,
- HAL_HELPER_TIMEOUT) != NULL)
- goto out;
- }
+ hald_runner_run (root, "hald-probe-smbios", NULL,
+ HAL_HELPER_TIMEOUT,
+ computer_probing_pcbios_helper_done,
+ NULL, NULL);
+ } else {
+ /* no probing */
+ computer_probing_helper_done (root);
+ }
- /* no probing or probing failed */
- computer_probing_helper_done (root);
-out:
- ;
}
DBusHandlerResult
- Previous message: hal/doc/spec hal-spec.html,1.71,1.72
- Next message: hal/hald Makefile.am, 1.52, 1.53 debug-hald.sh, 1.4, 1.5 hald.c,
1.45, 1.46 hald_dbus.c, 1.48, 1.49 hald_dbus.h, 1.10,
1.11 hald_runner.c, NONE, 1.1 hald_runner.h, NONE,
1.1 haldaemon.in, 1.6, 1.7 run-hald.sh, 1.7, 1.8 util.c, 1.34,
1.35 util.h, 1.15, 1.16 valgrind-hald.sh, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list