[gnome-power-manager] Remove hardcoded paths from pkexec setup.



commit cba7cb8cf52286b84e3985bce9bd79369837b5dd
Author: Brian Hutsell <bhut_ooto yahoo com>
Date:   Mon May 17 23:49:08 2010 +0800

    Remove hardcoded paths from pkexec setup.
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 configure.ac                                       |   10 ++++++++++
 policy/Makefile.am                                 |    7 +++++--
 ....power.policy.in => org.gnome.power.policy.in2} |    2 +-
 src/Makefile.am                                    |    1 +
 src/gpm-brightness.c                               |    4 ++--
 5 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 07ae219..e5e0407 100644
--- a/configure.ac
+++ b/configure.ac
@@ -366,4 +366,14 @@ echo "
         dbus-1 services dir:       $DBUS_SERVICES_DIR
         gconf-schema dir:          $GCONF_SCHEMA_FILE_DIR
 "
+if [[ "${prefix}" != "/usr" ]] ; then
+	echo '
+WARNING!!!  GNOME Power Manager uses the "pkexec" utility to provide root
+permissions necessary for the "gnome-power-backlight-helper" executable to run.
+
+A link should be provided from the file
+"/usr/share/polkit-1/actions/org.gnome.power.policy" to the installed version
+"${prefix}/share/polkit-1/actions/org.gnome.power.policy" after installation.
+'
+fi
 
diff --git a/policy/Makefile.am b/policy/Makefile.am
index f7c03d1..25df27d 100644
--- a/policy/Makefile.am
+++ b/policy/Makefile.am
@@ -6,8 +6,11 @@ dist_polkit_policy_DATA =					\
 # http://bugzilla.gnome.org/show_bug.cgi?id=462312
 @INTLTOOL_POLICY_RULE@
 
-EXTRA_DIST = org.gnome.power.policy.in
-DISTCLEANFILES = org.gnome.power.policy
+.in2.in:
+	sed "s|[ ]sbindir@|${sbindir}|" $< > $@
+
+EXTRA_DIST = org.gnome.power.policy.in2
+DISTCLEANFILES = org.gnome.power.policy org.gnome.power.policy.in
 
 clean-local :
 	rm -f *~
diff --git a/policy/org.gnome.power.policy.in b/policy/org.gnome.power.policy.in2
similarity index 90%
rename from policy/org.gnome.power.policy.in
rename to policy/org.gnome.power.policy.in2
index 2135ba8..f54ff62 100644
--- a/policy/org.gnome.power.policy.in
+++ b/policy/org.gnome.power.policy.in2
@@ -25,7 +25,7 @@
       <allow_inactive>no</allow_inactive>
       <allow_active>yes</allow_active>
     </defaults>
-    <annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/gnome-power-backlight-helper</annotate>
+    <annotate key="org.freedesktop.policykit.exec.path">@sbindir@/gnome-power-backlight-helper</annotate>
   </action>
 
 </policyconfig>
diff --git a/src/Makefile.am b/src/Makefile.am
index 4db3e03..74682b0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,7 @@ INCLUDES =						\
 	-DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE \
 	$(UPOWER_CFLAGS)				\
 	-DBINDIR=\"$(bindir)\"			 	\
+	-DSBINDIR=\"$(sbindir)\"			 \
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"	\
 	-DDATADIR=\"$(datadir)\"			\
 	-DPREFIX=\""$(prefix)"\" 			\
diff --git a/src/gpm-brightness.c b/src/gpm-brightness.c
index c39cad9..46357f6 100644
--- a/src/gpm-brightness.c
+++ b/src/gpm-brightness.c
@@ -101,7 +101,7 @@ gpm_brightness_helper_get_value (const gchar *argument)
 	gchar *command = NULL;
 
 	/* get the data */
-	command = g_strdup_printf ("pkexec /usr/sbin/gnome-power-backlight-helper --%s", argument);
+	command = g_strdup_printf ("pkexec " SBINDIR "/gnome-power-backlight-helper --%s", argument);
 	ret = g_spawn_command_line_sync (command,
 					 &stdout_data, NULL, &exit_status, &error);
 	if (!ret) {
@@ -133,7 +133,7 @@ gpm_brightness_helper_set_value (const gchar *argument, gint value)
 	gchar *command = NULL;
 
 	/* get the data */
-	command = g_strdup_printf ("pkexec /usr/sbin/gnome-power-backlight-helper --%s %i", argument, value);
+	command = g_strdup_printf ("pkexec " SBINDIR "/gnome-power-backlight-helper --%s %i", argument, value);
 	ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error);
 	if (!ret) {
 		egg_error ("failed to get value: %s", error->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]