summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-08-15 19:00:41 -0400
committerJason Woodward2019-08-15 23:14:11 -0400
commit5f2b3c24b42b7b8f711e3345c758e07c2447fd04 (patch)
tree26c8ea144d2f72979e5046d6759c54368e6de25f
parent43845d87166b91f1f66a804ec63b3d09c6760b64 (diff)
downloadgslapt-5f2b3c24b42b7b8f711e3345c758e07c2447fd04.tar.gz
Use polkit pkexec to open gslapt from the .desktop files or with gslapt-polkit helperHEADpolkitmaster
-rw-r--r--Makefile.am10
-rw-r--r--acinclude.m441
-rw-r--r--configure.ac16
-rw-r--r--org.jaos.gslapt.policy20
4 files changed, 86 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 160fe43..58c2bf3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,11 @@ SUBDIRS = src po ui
PKGDIR = `pwd`/pkg
PKGREL = 1
+if POLKIT
+INSTALL_GSLAPT_POLKIT = mkdir -p $(DESTDIR)/$(bindir); echo -e "\#!/bin/sh\npkexec --disable-internal-agent /usr/sbin/gslapt \$$@" > $(DESTDIR)/$(bindir)/gslapt-polkit; chmod +x $(DESTDIR)/$(bindir)/gslapt-polkit
+else
+INSTALL_GSLAPT_POLKIT =
+endif
EXTRA_DIST = \
FAQ \
@@ -36,9 +41,12 @@ install-data-local:
$(INSTALL_DATA) AUTHORS ChangeLog COPYING FAQ README $(DESTDIR)/$(datadir)/doc/@PACKAGE@ ; \
$(INSTALL_DATA) gslapt.desktop $(DESTDIR)/$(datadir)/applications/gslapt.desktop; \
$(INSTALL_DATA) gslapt-kde.desktop $(DESTDIR)/$(datadir)/applications/gslapt-kde.desktop; \
+ $(mkinstalldirs) $(DESTDIR)/$(POLKIT_SYSTEM_ACTIONS_DIR); \
+ $(INSTALL_DATA) org.jaos.gslapt.policy $(DESTDIR)/$(POLKIT_SYSTEM_ACTIONS_DIR)/org.jaos.gslapt.policy; \
$(INSTALL_DATA) series_map.rc $(DESTDIR)/$(pkgdatadir)/; \
$(mkinstalldirs) $(DESTDIR)/$(datadir)/pixmaps; \
$(INSTALL_DATA) ui/gslapt.png $(DESTDIR)/$(datadir)/pixmaps/
+ $(INSTALL_GSLAPT_POLKIT)
pkg: all
@make install DESTDIR=$(PKGDIR)
@@ -51,7 +59,7 @@ pkg: all
@echo -n "$(DESTDIR)/$(datadir)/applications/gslapt.desktop " |sed -re "s/^\/+//" >> $(PKGDIR)/install/doinst.sh
@echo "$(DESTDIR)/$(datadir)/applications/gslapt-kde.desktop" |sed -re "s/^\/+//" >> $(PKGDIR)/install/doinst.sh
@echo "do" >> $(PKGDIR)/install/doinst.sh
- @echo 'if [ -f $$DESKTOPFILE ]; then if [ -x usr/bin/gksudo ]; then sed -i.bak -re "s/(Exec=)(\/usr\/sbin\/gslapt)/\1gksudo \2/" $$DESKTOPFILE; elif [ -x usr/bin/gksu ]; then sed -i.bak -re "s/(Exec=)(\/usr\/sbin\/gslapt)/\1gksu \2/" $$DESKTOPFILE; elif [ -x usr/bin/gnomesu ]; then sed -i.bak -re "s/(Exec=)(\/usr\/sbin\/gslapt)/\1gnomesu \2/" $$DESKTOPFILE; elif [ -x usr/bin/kdesu ]; then sed -i.bak -re "s/(Exec=)(\/usr\/sbin\/gslapt)/\1kdesu \2/" $$DESKTOPFILE; fi; fi' >> $(PKGDIR)/install/doinst.sh
+ @echo 'if [ -f $$DESKTOPFILE ]; then for privprog in usr/bin/pkexec usr/bin/gksudo usr/bin/gksu usr/bin/gnomesu usr/bin/kdesu;do if [ -x $$privprog ]; then shortprivprog=$$(basename $$privprog); sed -i.bak -re "s/(Exec=)(\/usr\/sbin\/gslapt)/\1$$shortprivprog \2/" $$DESKTOPFILE; fi; done; fi' >> $(PKGDIR)/install/doinst.sh
@echo "done" >> $(PKGDIR)/install/doinst.sh
@echo 'if [ -x usr/bin/update-desktop-database ]; then usr/bin/update-desktop-database &>/dev/null; fi' >> $(PKGDIR)/install/doinst.sh
strip --strip-unneeded $(PKGDIR)/$(sbindir)/@PACKAGE@
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000..5fc5c4e
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,41 @@
+dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
+dnl
+dnl example
+dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
+
+AC_DEFUN([AS_AC_EXPAND],
+[
+ EXP_VAR=[$1]
+ FROM_VAR=[$2]
+
+ dnl first expand prefix and exec_prefix if necessary
+ prefix_save=$prefix
+ exec_prefix_save=$exec_prefix
+
+ dnl if no prefix given, then use /usr/local, the default prefix
+ if test "x$prefix" = "xNONE"; then
+ prefix=$ac_default_prefix
+ fi
+ dnl if no exec_prefix given, then use prefix
+ if test "x$exec_prefix" = "xNONE"; then
+ exec_prefix=$prefix
+ fi
+
+ full_var="$FROM_VAR"
+ dnl loop until it doesn't change anymore
+ while true; do
+ new_full_var="`eval echo $full_var`"
+ if test "x$new_full_var"="x$full_var"; then break; fi
+ full_var=$new_full_var
+ done
+
+ dnl clean up
+ full_var=$new_full_var
+ AC_SUBST([$1], "$full_var")
+
+ dnl restore prefix and exec_prefix
+ prefix=$prefix_save
+ exec_prefix=$exec_prefix_save
+])
+
diff --git a/configure.ac b/configure.ac
index 36b57d5..5437638 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,6 +72,22 @@ fi
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
+AS_AC_EXPAND(DATADIR, $datadir)
+POLKIT_SYSTEM_ACTIONS_DIR="$DATADIR/polkit-1/actions"
+AC_SUBST(POLKIT_SYSTEM_ACTIONS_DIR)
+AC_DEFINE_UNQUOTED(POLKIT_SYSTEM_ACTIONS_DIR, "$POLKIT_SYSTEM_ACTIONS_DIR", [Where system actions dir for POLKIT is])
+AM_CONDITIONAL(POLKIT, false)
+
+AC_ARG_WITH(
+ [polkit],
+ AC_HELP_STRING([--with-polkit], [use Polkit pkexec to start gslapt (default is auto)]),
+ [ac_cv_prog_PKEXEC=$withval],
+ [AC_CHECK_PROG([PKEXEC], [pkexec], yes, [no])]
+)
+if test x"$ac_cv_prog_PKEXEC" = x"yes"; then
+ AM_CONDITIONAL(POLKIT, true)
+fi
+
GETTEXT_PACKAGE=gslapt
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
diff --git a/org.jaos.gslapt.policy b/org.jaos.gslapt.policy
new file mode 100644
index 0000000..a7fc461
--- /dev/null
+++ b/org.jaos.gslapt.policy
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
+<policyconfig>
+ <vendor>jaos.org</vendor>
+ <vendor_url>https://software.jaos.org</vendor_url>
+ <icon_name>gslapt</icon_name>
+ <action id="org.jaos.gslapt">
+ <description>Run Gslapt as root</description>
+ <message>Authentication is required to run Gslapt</message>
+ <defaults>
+ <allow_any>no</allow_any>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin</allow_active>
+ </defaults>
+ <annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/gslapt</annotate>
+ <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
+ </action>
+</policyconfig>