hal: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Sat Jul 29 15:44:49 PDT 2006


 configure.in                     |   51 +++++++++++++++++++++++++++------------
 hald-runner/Makefile.am          |    4 +--
 hald/Makefile.am                 |    4 +--
 hald/dummy/Makefile.am           |    2 -
 hald/hald_runner.c               |    3 ++
 hald/linux2/Makefile.am          |    2 -
 hald/linux2/addons/Makefile.am   |    8 +++---
 hald/linux2/probing/Makefile.am  |    8 +++---
 tools/Makefile.am                |    4 +--
 tools/hal-storage-eject.c        |   28 ++++++++++++++++++---
 tools/hal-storage-mount.c        |   31 ++++++++++++++++++++---
 tools/hal-storage-shared.c       |    6 +++-
 tools/hal-storage-shared.h       |    8 +++++-
 tools/hal-storage-unmount.c      |   18 ++++++++++++-
 tools/hal-system-power-hibernate |   20 ++++++++-------
 tools/hal-system-power-reboot    |   20 ++++++++-------
 tools/hal-system-power-shutdown  |   20 ++++++++-------
 tools/hal-system-power-suspend   |   20 ++++++++-------
 18 files changed, 178 insertions(+), 79 deletions(-)

New commits:
diff-tree b412caf1175bf3fcea51ef1b5ed3db1e946bf0d8 (from parents)
Merge: 590dd4f8d51a78be27573d720bb82c92f68f6f93 97fa1003bebc4cf74573aaaccd62d23cd9721dde
Author: David Zeuthen <davidz at redhat.com>
Date:   Sat Jul 29 18:44:07 2006 -0400

    Merge branch 'master' of ssh://david@git.freedesktop.org/git/hal

diff --cc tools/hal-storage-eject.c
index a5e9611,b347ad9..cb6316a
@@@ -174,9 -167,9 +175,10 @@@
  	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
  	if (system_bus == NULL) {
  		printf ("Cannot connect to the system bus\n");
+ 		LIBHAL_FREE_DBUS_ERROR (&error);
  		usage ();
  	}
 +#ifdef HAVE_POLKIT
  	pol_ctx = libpolkit_new_context (system_bus);
  	if (pol_ctx == NULL) {
  		printf ("Cannot get libpolkit context\n");
diff --cc tools/hal-storage-mount.c
index 6084eb2,d24d748..53e45a2
@@@ -948,9 -934,9 +947,10 @@@
  	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
  	if (system_bus == NULL) {
  		printf ("Cannot connect to the system bus\n");
+ 		LIBHAL_FREE_DBUS_ERROR (&error);
  		usage ();
  	}
 +#ifdef HAVE_POLKIT
  	pol_ctx = libpolkit_new_context (system_bus);
  	if (pol_ctx == NULL) {
  		printf ("Cannot get libpolkit context\n");
diff --cc tools/hal-storage-unmount.c
index f7e885d,99a3fb4..6b1ec1d
@@@ -115,9 -112,9 +116,10 @@@
  	system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
  	if (system_bus == NULL) {
  		printf ("Cannot connect to the system bus\n");
+ 		LIBHAL_FREE_DBUS_ERROR (&error);
  		usage ();
  	}
 +#ifdef HAVE_POLKIT
  	pol_ctx = libpolkit_new_context (system_bus);
  	if (pol_ctx == NULL) {
  		printf ("Cannot get libpolkit context\n");
diff-tree 590dd4f8d51a78be27573d720bb82c92f68f6f93 (from 15376ac7c17fa31033adefcfe106935e09b5b0df)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sat Jul 29 18:43:07 2006 -0400

    introduce new option --disable-policy-kit and streamline the build
    
    You explicitly have to pass --disable-policy-kit to configure and/or
    autogen.sh and if you do, a big fat warning will be displayed:
    
    NOTE: WARNING! WARNING! WARNING! PolicyKit is not enabled. HAL will
          allow any user to invoke any method. THIS IS A SECURITY RISK.
          Use this only if you really know what you are doing. Bugs,
          security issues and similar filed against HAL versions built
          without PolicyKit may be ignored by the HAL maintainers.
    
          Disable PolicyKit usage only if you really know what you are doing.
    
    This option might be removed in the future. Also clean up the build
    system by removing PACKAGE_CFLAGS and PACKAGE_LIBS. Binaries now have
    to specify exactly what libs they want.

diff --git a/configure.in b/configure.in
index 166657b..565b504 100644
--- a/configure.in
+++ b/configure.in
@@ -12,6 +12,11 @@ AM_INIT_AUTOMAKE(hal, 0.5.8)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
+glib_module="glib-2.0 >= 2.6.0 dbus-glib-1 >= 0.61"
+dbus_module="dbus-1 >= 0.61"
+volume_id_module="libvolume_id >= 0.66"
+polkit_module="polkit >= 0.2"
+
 # libtool versioning - this applies to libhal and libhal-storage
 #
 # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
@@ -177,12 +182,6 @@ fi
 
 AM_CONDITIONAL(GCOV, test x$enable_gcov = xyes)
 
-glib_module="glib-2.0 >= 2.6.0"
-dbus_module="dbus-1 >= 0.33"
-polkit_module="polkit >= 0.2"
-volume_id_module="libvolume_id >= 0.66"
-pkg_modules="$glib_module, gobject-2.0 >= 2.6.0, dbus-glib-1 >= 0.33, $dbus_module, $polkit_module, $volume_id_module"
-PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
 
 EXPAT_LIB=""
 AC_ARG_WITH(expat, [  --with-expat=<dir>      ese expat from here],
@@ -245,12 +244,26 @@ AC_SUBST(HALD_BACKEND)
 
 dnl DBUS API is subject to changes
 AC_DEFINE_UNQUOTED(DBUS_API_SUBJECT_TO_CHANGE, ,DBUS API is subject to change)
-AC_SUBST(PACKAGE_CFLAGS)
-AC_SUBST(PACKAGE_LIBS)
 
-# Now just the D-BUS libs
-PKG_CHECK_MODULES(DBUS, [$dbus_module])
+# check for PolicyKit
+AM_CONDITIONAL(HAVE_POLKIT, false)
+AC_ARG_ENABLE(policy-kit, [  --disable-policy-kit    Build without PolicyKit (strongly discouraged)])
+msg_polkit=no
+if test "x$enable_policy_kit" != "xno"; then
+	PKG_CHECK_MODULES(POLKIT, polkit >= 0.2,
+		  	[AM_CONDITIONAL(HAVE_POLKIT, true)
+		   	AC_DEFINE(HAVE_POLKIT, [], [Set if we use PolicyKit])]
+                        msg_polkit=yes,
+	          	[AM_CONDITIONAL(HAVE_POLKIT, false)])
+	AC_SUBST(POLKIT_CFLAGS)
+	AC_SUBST(POLKIT_LIBS)
+	if test "x$msg_polkit" != "xyes"; then
+	   AC_MSG_ERROR([PolicyKit not explicitly disabled and no PolicyKit found])
+	fi
+fi
 
+# D-Bus libs
+PKG_CHECK_MODULES(DBUS, [$dbus_module])
 AC_SUBST(DBUS_CFLAGS)
 AC_SUBST(DBUS_LIBS)
 
@@ -259,11 +272,6 @@ PKG_CHECK_MODULES(GLIB, [$glib_module])
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
-# polkit libs
-PKG_CHECK_MODULES(POLKIT, [$polkit_module])
-AC_SUBST(POLKIT_CFLAGS)
-AC_SUBST(POLKIT_LIBS)
-
 # volume_id
 PKG_CHECK_MODULES(VOLUME_ID, [$volume_id_module])
 AC_SUBST(VOLUME_ID_CFLAGS)
@@ -497,6 +505,8 @@ echo "
         use libusb:                 ${USE_LIBUSB}
         use libpci:                 ${USE_LIBPCI}
 
+        use PolicyKit:              ${msg_polkit}
+
         Maintainer mode:            ${USE_MAINTAINER_MODE}
         Building verbose mode:      ${enable_verbose_mode}
         Building api docs:          ${enable_gtk_doc}
@@ -509,6 +519,17 @@ if test x$enable_verbose_mode = xyes; th
    echo
 fi
 
+if test x$msg_polkit = xno; then
+   echo "NOTE: WARNING! WARNING! WARNING! PolicyKit is not enabled. HAL will "
+   echo "      allow any user to invoke any method. THIS IS A SECURITY RISK. "
+   echo "      Use this only if you really know what you are doing. Bugs, "
+   echo "      security issues and similar filed against HAL versions built"
+   echo "      without PolicyKit may be ignored by the HAL maintainers."
+   echo
+   echo "      Disable PolicyKit usage only if you really know what you are doing."
+   echo
+fi
+
 # (distro-tweaks required)
 if test x$with_os_type = xredhat; then
    echo "NOTE: Red Hat style init scripts and policy will be installed"
diff --git a/hald-runner/Makefile.am b/hald-runner/Makefile.am
index e834178..280d48c 100644
--- a/hald-runner/Makefile.am
+++ b/hald-runner/Makefile.am
@@ -8,9 +8,9 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_SCRIPT_DIR=\""$(datadir)/hal/scripts"\" \
 	-I$(top_srcdir) \
-	@PACKAGE_CFLAGS@
+	@DBUS_CFLAGS@ @GLIB_CFLAGS@
 
 libexec_PROGRAMS = hald-runner
 
 hald_runner_SOURCES = main.c runner.c runner.h utils.h utils.c
-hald_runner_LDADD = @PACKAGE_LIBS@ @DBUS_LIBS@
+hald_runner_LDADD = @GLIB_LIBS@ @DBUS_LIBS@
diff --git a/hald/Makefile.am b/hald/Makefile.am
index 28ec7ce..a5827d5 100644
--- a/hald/Makefile.am
+++ b/hald/Makefile.am
@@ -11,7 +11,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_SCRIPT_DIR=\""$(libdir)/hal/scripts"\" \
 	-I$(top_srcdir) \
-	@PACKAGE_CFLAGS@
+	@GLIB_CFLAGS@ @DBUS_CFLAGS@
 
 ## check_PROGRAMS = hald-test
 
@@ -50,7 +50,7 @@ hald_SOURCES =                          
 	osspec.h							\
 	property.h			property.c
 
-hald_LDADD = @PACKAGE_LIBS@ -lm @EXPAT_LIB@ $(top_builddir)/hald/$(HALD_BACKEND)/libhald_$(HALD_BACKEND).la
+hald_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ -lm @EXPAT_LIB@ $(top_builddir)/hald/$(HALD_BACKEND)/libhald_$(HALD_BACKEND).la
 
 #### Init scripts fun
 SCRIPT_IN_FILES=haldaemon.in
diff --git a/hald/dummy/Makefile.am b/hald/dummy/Makefile.am
index b060207..d5eba31 100644
--- a/hald/dummy/Makefile.am
+++ b/hald/dummy/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-I$(top_srcdir) -I.. \
-	@PACKAGE_CFLAGS@
+	@GLIB_CFLAGS@ @DBUS_CFLAGS@
 
 noinst_LTLIBRARIES = libhald_dummy.la
 libhald_dummy_la_SOURCES =                                      \
diff --git a/hald/hald_runner.c b/hald/hald_runner.c
index 575d4dd..6a259ff 100644
--- a/hald/hald_runner.c
+++ b/hald/hald_runner.c
@@ -180,6 +180,9 @@ add_basic_env(DBusMessageIter *iter, con
   }
   add_env(iter, "UDI", udi);
   add_env(iter, "HALD_DIRECT_ADDR", hald_dbus_local_server_addr());
+#ifdef HAVE_POLKIT
+  add_env(iter, "HAVE_POLKIT", "1");
+#endif
 
   if (uname(&un) == 0) {
     char *sysname;
diff --git a/hald/linux2/Makefile.am b/hald/linux2/Makefile.am
index 4845c4d..d7b90a3 100644
--- a/hald/linux2/Makefile.am
+++ b/hald/linux2/Makefile.am
@@ -8,7 +8,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-I$(top_srcdir) -I.. \
-	@PACKAGE_CFLAGS@
+	@GLIB_CFLAGS@ @DBUS_CFLAGS@
 
 if HALD_COMPILE_LINUX2
 noinst_LTLIBRARIES = libhald_linux2.la
diff --git a/hald/linux2/addons/Makefile.am b/hald/linux2/addons/Makefile.am
index 1af58df..33cdd9c 100644
--- a/hald/linux2/addons/Makefile.am
+++ b/hald/linux2/addons/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-I$(top_srcdir) \
-	@PACKAGE_CFLAGS@
+	@GLIB_CFLAGS@ @DBUS_CFLAGS@
 
 if HALD_COMPILE_LINUX2
 libexec_PROGRAMS  = \
@@ -35,7 +35,7 @@ hald_addon_pmu_SOURCES = addon-pmu.c
 hald_addon_pmu_LDADD = $(top_builddir)/libhal/libhal.la
 
 hald_addon_acpi_buttons_toshiba_SOURCES = addon-acpi-buttons-toshiba.c
-hald_addon_acpi_buttons_toshiba_LDADD = $(top_builddir)/libhal/libhal.la @PACKAGE_LIBS@
+hald_addon_acpi_buttons_toshiba_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@
 
 hald_addon_storage_SOURCES = addon-storage.c
 hald_addon_storage_LDADD = $(top_builddir)/libhal/libhal.la
@@ -45,11 +45,11 @@ hald_addon_keyboard_LDADD = $(top_buildd
 
 if HAVE_LIBUSB
 hald_addon_usb_csr_SOURCES = addon-usb-csr.c
-hald_addon_usb_csr_LDADD = $(top_builddir)/libhal/libhal.la -lusb @PACKAGE_LIBS@
+hald_addon_usb_csr_LDADD = $(top_builddir)/libhal/libhal.la -lusb @GLIB_LIBS@
 endif
 
 
 if HAVE_LIBPCI
 hald_addon_macbookpro_backlight_SOURCES = addon-macbookpro-backlight.c
-hald_addon_macbookpro_backlight_LDADD = $(top_builddir)/libhal/libhal.la -lpci @PACKAGE_LIBS@
+hald_addon_macbookpro_backlight_LDADD = $(top_builddir)/libhal/libhal.la -lpci @GLIB_LIBS@
 endif
diff --git a/hald/linux2/probing/Makefile.am b/hald/linux2/probing/Makefile.am
index ba73991..d50f44e 100644
--- a/hald/linux2/probing/Makefile.am
+++ b/hald/linux2/probing/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-I$(top_srcdir) \
-	@PACKAGE_CFLAGS@
+	@GLIB_CFLAGS@ @DBUS_CFLAGS@
 
 if HALD_COMPILE_LINUX2
 libexec_PROGRAMS = hald-probe-input hald-probe-hiddev hald-probe-storage hald-probe-volume hald-probe-printer \
@@ -17,7 +17,7 @@ hald_probe_smbios_SOURCES = probe-smbios
 hald_probe_smbios_LDADD = $(top_builddir)/libhal/libhal.la
 
 hald_probe_printer_SOURCES = probe-printer.c shared.h
-hald_probe_printer_LDADD = $(top_builddir)/libhal/libhal.la @PACKAGE_LIBS@
+hald_probe_printer_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@
 #TODO : get rid of glib in hald_probe_printer
 
 hald_probe_input_SOURCES = probe-input.c shared.h
@@ -30,10 +30,10 @@ hald_probe_serial_SOURCES = probe-serial
 hald_probe_serial_LDADD = $(top_builddir)/libhal/libhal.la
 
 hald_probe_storage_SOURCES = probe-storage.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h shared.h
-hald_probe_storage_LDADD = $(top_builddir)/libhal/libhal.la @PACKAGE_LIBS@
+hald_probe_storage_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@ @VOLUME_ID_LIBS@
 
 hald_probe_pc_floppy_SOURCES = probe-pc-floppy.c
 
 hald_probe_volume_SOURCES = probe-volume.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h shared.h 
-hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la @PACKAGE_LIBS@
+hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@ @VOLUME_ID_LIBS@
 
diff --git a/tools/Makefile.am b/tools/Makefile.am
index a065331..888d03e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -21,7 +21,7 @@ INCLUDES = \
 	-DPACKAGE_SCRIPT_DIR=\""$(datadir)/hal/scripts"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-I$(top_srcdir) -I$(top_srcdir)/libhal \
-	@PACKAGE_CFLAGS@
+	@DBUS_CFLAGS@ @GLIB_CFLAGS@ @POLKIT_CFLAGS@
 
 bin_PROGRAMS =                    \
 	lshal                     \
@@ -32,7 +32,7 @@ bin_PROGRAMS =                    \
 	hal-device
 
 lshal_SOURCES = lshal.c
-lshal_LDADD = @PACKAGE_LIBS@ $(top_builddir)/libhal/libhal.la
+lshal_LDADD = @GLIB_LIBS@ $(top_builddir)/libhal/libhal.la
 
 hal_get_property_SOURCES = hal_get_property.c
 hal_get_property_LDADD = @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la
diff --git a/tools/hal-storage-eject.c b/tools/hal-storage-eject.c
index e7163d6..a5e9611 100644
--- a/tools/hal-storage-eject.c
+++ b/tools/hal-storage-eject.c
@@ -36,7 +36,9 @@
 
 #include <libhal/libhal.h>
 #include <libhal-storage/libhal-storage.h>
+#ifdef HAVE_POLKIT
 #include <libpolkit.h>
+#endif
 
 #include "hal-storage-shared.h"
 
@@ -63,7 +65,11 @@ invalid_eject_option (const char *option
 #define EJECT "/usr/bin/eject"
 
 static void
-handle_eject (LibHalContext *hal_ctx, LibPolKitContext *pol_ctx, const char *udi,
+handle_eject (LibHalContext *hal_ctx, 
+#ifdef HAVE_POLKIT
+	      LibPolKitContext *pol_ctx, 
+#endif
+	      const char *udi,
 	      LibHalDrive *drive, const char *device, 
 	      const char *invoked_by_uid, const char *invoked_by_syscon_name)
 {
@@ -134,7 +140,9 @@ main (int argc, char *argv[])
 	DBusError error;
 	LibHalContext *hal_ctx = NULL;
 	DBusConnection *system_bus = NULL;
+#ifdef HAVE_POLKIT
 	LibPolKitContext *pol_ctx = NULL;
+#endif
 	char *invoked_by_uid;
 	char *invoked_by_syscon_name;
 	char **volume_udis;
@@ -168,11 +176,13 @@ main (int argc, char *argv[])
 		printf ("Cannot connect to the system bus\n");
 		usage ();
 	}
+#ifdef HAVE_POLKIT
 	pol_ctx = libpolkit_new_context (system_bus);
 	if (pol_ctx == NULL) {
 		printf ("Cannot get libpolkit context\n");
 		unknown_error ("Cannot get libpolkit context");
 	}
+#endif
 
 	/* read from stdin */
 	fgets (eject_options, sizeof (eject_options), stdin);
@@ -220,7 +230,10 @@ main (int argc, char *argv[])
 			/* TODO: should try to unmount? */
 
 			/* attempt the eject */
-			handle_eject (hal_ctx, pol_ctx, 
+			handle_eject (hal_ctx, 
+#ifdef HAVE_POLKIT
+				      pol_ctx, 
+#endif
 				      libhal_drive_get_udi (drive),
 				      drive,
 				      libhal_drive_get_device_file (drive),
@@ -270,7 +283,11 @@ main (int argc, char *argv[])
 				if (!lock_hal_mtab ()) {
 					unknown_error ("Cannot obtain lock on /media/.hal-mtab");
 				}
-				handle_unmount (hal_ctx, pol_ctx, udi, volume_to_unmount, drive, 
+				handle_unmount (hal_ctx, 
+#ifdef HAVE_POLKIT
+						pol_ctx, 
+#endif
+						udi, volume_to_unmount, drive, 
 						libhal_volume_get_device_file (volume_to_unmount), 
 						invoked_by_uid, invoked_by_syscon_name,
 						FALSE, FALSE); /* use neither lazy nor force */
@@ -287,7 +304,10 @@ main (int argc, char *argv[])
 		libhal_free_string_array (volume_udis);
 
 		/* now attempt the eject */
-		handle_eject (hal_ctx, pol_ctx, 
+		handle_eject (hal_ctx, 
+#ifdef HAVE_POLKIT
+			      pol_ctx, 
+#endif
 			      libhal_drive_get_udi (drive),
 			      drive,
 			      libhal_drive_get_device_file (drive),
diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c
index 2dfcb3d..6084eb2 100644
--- a/tools/hal-storage-mount.c
+++ b/tools/hal-storage-mount.c
@@ -48,7 +48,9 @@
 
 #include <libhal/libhal.h>
 #include <libhal-storage/libhal-storage.h>
+#ifdef HAVE_POLKIT
 #include <libpolkit.h>
+#endif
 
 #include "hal-storage-shared.h"
 
@@ -124,6 +126,7 @@ mount_point_not_available (const char *m
 }
 
 
+#ifdef HAVE_POLKIT
 static void
 permission_denied_privilege (const char *privilege, const char *uid)
 {
@@ -131,7 +134,7 @@ permission_denied_privilege (const char 
 	fprintf (stderr, "%s refused uid %s\n", privilege, uid);
 	exit (1);
 }
-
+#endif
 
 
 /* borrowed from gtk/gtkfilesystemunix.c in GTK+ on 02/23/2006 */
@@ -411,7 +414,11 @@ map_fstype (const char *fstype)
 }
 
 static void
-handle_mount (LibHalContext *hal_ctx, LibPolKitContext *pol_ctx, const char *udi,
+handle_mount (LibHalContext *hal_ctx, 
+#ifdef HAVE_POLKIT
+	      LibPolKitContext *pol_ctx, 
+#endif
+	      const char *udi,
 	      LibHalVolume *volume, LibHalDrive *drive, const char *device, 
 	      const char *invoked_by_uid, const char *invoked_by_syscon_name)
 {
@@ -434,8 +441,10 @@ handle_mount (LibHalContext *hal_ctx, Li
 	gboolean pol_is_fixed;
 	gboolean pol_change_uid;
 	char *privilege;
+#ifdef HAVE_POLKIT
 	gboolean allowed_by_privilege;
 	gboolean is_temporary_privilege;
+#endif
 	gboolean explicit_mount_point_given;
 	const char *end;
 #ifdef __FreeBSD__
@@ -687,6 +696,7 @@ handle_mount (LibHalContext *hal_ctx, Li
 		invoked_by_syscon_name);
 #endif
 
+#ifdef HAVE_POLKIT
 	if (libpolkit_is_uid_allowed_for_privilege (pol_ctx, 
 						    invoked_by_syscon_name,
 						    invoked_by_uid,
@@ -703,6 +713,7 @@ handle_mount (LibHalContext *hal_ctx, Li
 		printf ("caller don't possess privilege\n");
 		permission_denied_privilege (privilege, invoked_by_uid);
 	}
+#endif
 
 #ifdef DEBUG
 	printf ("passed privilege\n");
@@ -905,7 +916,9 @@ main (int argc, char *argv[])
 	DBusError error;
 	LibHalContext *hal_ctx = NULL;
 	DBusConnection *system_bus = NULL;
+#ifdef HAVE_POLKIT
 	LibPolKitContext *pol_ctx = NULL;
+#endif
 	char *invoked_by_uid;
 	char *invoked_by_syscon_name;
 
@@ -937,11 +950,13 @@ main (int argc, char *argv[])
 		printf ("Cannot connect to the system bus\n");
 		usage ();
 	}
+#ifdef HAVE_POLKIT
 	pol_ctx = libpolkit_new_context (system_bus);
 	if (pol_ctx == NULL) {
 		printf ("Cannot get libpolkit context\n");
 		unknown_error ("Cannot get libpolkit context");
 	}
+#endif
 
 	volume = libhal_volume_from_udi (hal_ctx, udi);
 	if (volume == NULL) {
@@ -951,7 +966,11 @@ main (int argc, char *argv[])
 		if (drive == NULL) {
 			usage ();
 		} else {
-			handle_mount (hal_ctx, pol_ctx, udi, NULL, drive, device, invoked_by_uid, 
+			handle_mount (hal_ctx, 
+#ifdef HAVE_POLKIT
+				      pol_ctx, 
+#endif
+				      udi, NULL, drive, device, invoked_by_uid, 
 				      invoked_by_syscon_name);
 		}
 
@@ -967,7 +986,11 @@ main (int argc, char *argv[])
 		if (drive == NULL)
 			unknown_error ("Cannot get drive from hal");
 
-		handle_mount (hal_ctx, pol_ctx, udi, volume, drive, device, invoked_by_uid, 
+		handle_mount (hal_ctx, 
+#ifdef HAVE_POLKIT
+			      pol_ctx, 
+#endif
+			      udi, volume, drive, device, invoked_by_uid, 
 			      invoked_by_syscon_name);
 
 	}
diff --git a/tools/hal-storage-shared.c b/tools/hal-storage-shared.c
index c49c106..e5fcc94 100644
--- a/tools/hal-storage-shared.c
+++ b/tools/hal-storage-shared.c
@@ -217,7 +217,11 @@ permission_denied_volume_ignore (const c
 }
 
 void
-handle_unmount (LibHalContext *hal_ctx, LibPolKitContext *pol_ctx, const char *udi,
+handle_unmount (LibHalContext *hal_ctx, 
+#ifdef HAVE_POLKIT
+		LibPolKitContext *pol_ctx, 
+#endif
+		const char *udi,
 		LibHalVolume *volume, LibHalDrive *drive, const char *device, 
 		const char *invoked_by_uid, const char *invoked_by_syscon_name,
 		gboolean option_lazy, gboolean option_force)
diff --git a/tools/hal-storage-shared.h b/tools/hal-storage-shared.h
index b952251..34b9f1e 100644
--- a/tools/hal-storage-shared.h
+++ b/tools/hal-storage-shared.h
@@ -26,7 +26,9 @@
 
 #include <libhal/libhal.h>
 #include <libhal-storage/libhal-storage.h>
+#ifdef HAVE_POLKIT
 #include <libpolkit.h>
+#endif
 
 /*#define DEBUG*/
 #define DEBUG
@@ -44,7 +46,11 @@ void unlock_hal_mtab (void);
 
 void unknown_error (const char *detail);
 
-void handle_unmount (LibHalContext *hal_ctx, LibPolKitContext *pol_ctx, const char *udi,
+void handle_unmount (LibHalContext *hal_ctx, 
+#ifdef HAVE_POLKIT
+		     LibPolKitContext *pol_ctx, 
+#endif
+		     const char *udi,
 		     LibHalVolume *volume, LibHalDrive *drive, const char *device, 
 		     const char *invoked_by_uid, const char *invoked_by_syscon_name,
 		     gboolean option_lazy, gboolean option_force);
diff --git a/tools/hal-storage-unmount.c b/tools/hal-storage-unmount.c
index 5af680a..f7e885d 100644
--- a/tools/hal-storage-unmount.c
+++ b/tools/hal-storage-unmount.c
@@ -46,7 +46,9 @@
 
 #include <libhal/libhal.h>
 #include <libhal-storage/libhal-storage.h>
+#ifdef HAVE_POLKIT
 #include <libpolkit.h>
+#endif
 
 #include "hal-storage-shared.h"
 
@@ -75,7 +77,9 @@ main (int argc, char *argv[])
 	DBusError error;
 	LibHalContext *hal_ctx = NULL;
 	DBusConnection *system_bus = NULL;
+#ifdef HAVE_POLKIT
 	LibPolKitContext *pol_ctx = NULL;
+#endif
 	char *invoked_by_uid;
 	char *invoked_by_syscon_name;
 	int i;
@@ -113,11 +117,13 @@ main (int argc, char *argv[])
 		printf ("Cannot connect to the system bus\n");
 		usage ();
 	}
+#ifdef HAVE_POLKIT
 	pol_ctx = libpolkit_new_context (system_bus);
 	if (pol_ctx == NULL) {
 		printf ("Cannot get libpolkit context\n");
 		unknown_error ("Cannot get libpolkit context");
 	}
+#endif
 
 	/* read from stdin */
 	fgets (unmount_options, sizeof (unmount_options), stdin);
@@ -164,7 +170,11 @@ main (int argc, char *argv[])
 		if (drive == NULL) {
 			usage ();
 		} else {
-			handle_unmount (hal_ctx, pol_ctx, udi, NULL, drive, device, invoked_by_uid, 
+			handle_unmount (hal_ctx, 
+#ifdef HAVE_POLKIT
+					pol_ctx, 
+#endif
+					udi, NULL, drive, device, invoked_by_uid, 
 					invoked_by_syscon_name, use_lazy, use_force);
 		}
 
@@ -180,7 +190,11 @@ main (int argc, char *argv[])
 		if (drive == NULL)
 			unknown_error ("Cannot get drive from hal");
 
-		handle_unmount (hal_ctx, pol_ctx, udi, volume, drive, device, invoked_by_uid, 
+		handle_unmount (hal_ctx, 
+#ifdef HAVE_POLKIT
+				pol_ctx, 
+#endif
+				udi, volume, drive, device, invoked_by_uid, 
 				invoked_by_syscon_name, use_lazy, use_force);
 
 	}
diff --git a/tools/hal-system-power-hibernate b/tools/hal-system-power-hibernate
index 6ee018a..ab8ce9d 100755
--- a/tools/hal-system-power-hibernate
+++ b/tools/hal-system-power-hibernate
@@ -1,15 +1,17 @@
 #!/bin/sh
 
 PRIVILEGE=hal-power-hibernate
-if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
-    RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
-                                  --user $HAL_METHOD_INVOKED_BY_UID \
-	                          --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
-    IS_PRIVILEGED=$?
-    if [ "$IS_PRIVILEGED" != "0" ] ; then
-	echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
-	echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
-	exit 1
+if [ "$HAVE_POLKIT" == "1" ] ; then
+    if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
+	RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
+	    --user $HAL_METHOD_INVOKED_BY_UID \
+	    --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
+	IS_PRIVILEGED=$?
+	if [ "$IS_PRIVILEGED" != "0" ] ; then
+	    echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
+	    echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
+	    exit 1
+	fi
     fi
 fi
 
diff --git a/tools/hal-system-power-reboot b/tools/hal-system-power-reboot
index f3a9f7c..dec4b0b 100755
--- a/tools/hal-system-power-reboot
+++ b/tools/hal-system-power-reboot
@@ -1,15 +1,17 @@
 #!/bin/sh
 
 PRIVILEGE=hal-power-reboot
-if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
-    RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
-                                  --user $HAL_METHOD_INVOKED_BY_UID \
-	                          --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
-    IS_PRIVILEGED=$?
-    if [ "$IS_PRIVILEGED" != "0" ] ; then
-	echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
-	echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
-	exit 1
+if [ "$HAVE_POLKIT" == "1" ] ; then
+    if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
+	RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
+	    --user $HAL_METHOD_INVOKED_BY_UID \
+	    --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
+	IS_PRIVILEGED=$?
+	if [ "$IS_PRIVILEGED" != "0" ] ; then
+	    echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
+	    echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
+	    exit 1
+	fi
     fi
 fi
 
diff --git a/tools/hal-system-power-shutdown b/tools/hal-system-power-shutdown
index 9ca4a24..33a3226 100755
--- a/tools/hal-system-power-shutdown
+++ b/tools/hal-system-power-shutdown
@@ -1,15 +1,17 @@
 #!/bin/sh
 
 PRIVILEGE=hal-power-poweroff
-if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
-    RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
-                                  --user $HAL_METHOD_INVOKED_BY_UID \
-	                          --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
-    IS_PRIVILEGED=$?
-    if [ "$IS_PRIVILEGED" != "0" ] ; then
-	echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
-	echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
-	exit 1
+if [ "$HAVE_POLKIT" == "1" ] ; then
+    if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
+	RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
+	    --user $HAL_METHOD_INVOKED_BY_UID \
+	    --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
+	IS_PRIVILEGED=$?
+	if [ "$IS_PRIVILEGED" != "0" ] ; then
+	    echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
+	    echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
+	    exit 1
+	fi
     fi
 fi
 
diff --git a/tools/hal-system-power-suspend b/tools/hal-system-power-suspend
index 10084d9..8199689 100755
--- a/tools/hal-system-power-suspend
+++ b/tools/hal-system-power-suspend
@@ -1,15 +1,17 @@
 #!/bin/sh
 
 PRIVILEGE=hal-power-suspend
-if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
-    RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
-                                  --user $HAL_METHOD_INVOKED_BY_UID \
-	                          --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
-    IS_PRIVILEGED=$?
-    if [ "$IS_PRIVILEGED" != "0" ] ; then
-	echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
-	echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
-	exit 1
+if [ "$HAVE_POLKIT" == "1" ] ; then
+    if [ "$HAL_METHOD_INVOKED_BY_UID" != "0" ] ; then
+	RESULT=$(polkit-is-privileged --privilege $PRIVILEGE \
+	    --user $HAL_METHOD_INVOKED_BY_UID \
+	    --system-bus-unique-name $HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME 2>&1)
+	IS_PRIVILEGED=$?
+	if [ "$IS_PRIVILEGED" != "0" ] ; then
+	    echo org.freedesktop.Hal.Device.PermissionDeniedByPolicy >&2
+	    echo $PRIVILEGE refused uid $HAL_METHOD_INVOKED_BY_UID >&2
+	    exit 1
+	fi
     fi
 fi
 



More information about the hal-commit mailing list