hal/hald-runner runner.c,1.1,1.2

David Zeuthen david at freedesktop.org
Fri Jan 20 22:36:53 PST 2006


Update of /cvs/hal/hal/hald-runner
In directory gabe:/tmp/cvs-serv10610/hald-runner

Modified Files:
	runner.c 
Log Message:
2006-01-21  David Zeuthen  <davidz at redhat.com>

        * hald-runner/runner.c: Search $PATH before searching allowed dirs;
        this is needed to make e.g. run-hald.sh work - note that passing
        "/bin/sh /path/to/evil/program" will _not_ work as we don't do
        shell-ish stuff. Also, don't force working dir to be "/" for
        same reasons.

        * hald/property.h: Export hal_property_strlist_clear

        * hald/property.c (hal_property_strlist_clear): New function

        * hald/hald_runner.c (hald_runner_start_runner): Pass $PATH to runner

        * hald/hald_dbus.c (hald_exec_method_cb): Fix up indenting

        * hald/device_info.c (handle_clear): New function
        (start): Check for new fdi tag "clear"

        * hald/device.h: Export hal_device_property_strlist_clear

        * hald/device.c (hal_device_property_strlist_clear): New function



Index: runner.c
===================================================================
RCS file: /cvs/hal/hal/hald-runner/runner.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- runner.c	21 Jan 2006 02:45:27 -0000	1.1
+++ runner.c	21 Jan 2006 06:36:51 -0000	1.2
@@ -197,14 +197,21 @@
 
   if (argv[0] == NULL) 
     return FALSE;
+
   program = g_path_get_basename(argv[0]);
-  for (i = 0; dirs[i] != NULL; i++) {
-    path = g_build_filename(dirs[i], program, NULL);
-    if (stat(path, &buf) == 0) {
-        break;
+
+  /* first search $PATH to make e.g. run-hald.sh work */
+  path = g_find_program_in_path (program);
+  /* otherwise check allowed paths */
+  if (path == NULL) {
+    for (i = 0; dirs[i] != NULL; i++) {
+      path = g_build_filename(dirs[i], program, NULL);
+      if (stat(path, &buf) == 0) {
+          break;
+      }
+      g_free(path);
+      path = NULL;
     }
-    g_free(path);
-    path = NULL;
   }
   g_free(program);
   if (path == NULL) 
@@ -214,6 +221,7 @@
     g_free(argv[0]);
     argv[0] = path;
   }
+  fprintf (stderr, "foobar '%s'!\n", argv[0]);
   return TRUE;
 }
 
@@ -240,7 +248,7 @@
   }
 
   if (!find_program(r->argv) ||
-      !g_spawn_async_with_pipes("/", r->argv, r->environment, 
+      !g_spawn_async_with_pipes(NULL, r->argv, r->environment, 
                                 G_SPAWN_DO_NOT_REAP_CHILD,
                                 NULL, NULL, &pid, 
                                 stdin_p, NULL, stderr_p, &error)) {




More information about the hal-commit mailing list