Skip to contentSkip to conversation

package/polkit: bump to version 0.116

PATCH Superseded aduskett at gmail.com 1 participant 6 messages Nov 29, 2019

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/6 package/polkit: bump to version 0.116

From: Adam Duskett <[email protected]>

Other changes:
- Add spidermonkey as a dependency.
- Add 0001-make-netgroup-support-optional.patch to allow building on musl.
- Add a runtime dependency on dbus.
- Add --disable-libelongind.
- Add --disable-libsystemd-login.
- Update dependencies for systemd pam support.
- Update dependencies for udisks.

---
 DEVELOPERS                                    |   1 +
 .../0001-make-netgroup-support-optional.patch | 232 ++++++++++++++++++
 package/polkit/Config.in                      |  23 +-
 package/polkit/polkit.hash                    |   2 +-
 package/polkit/polkit.mk                      |   8 +-
 package/systemd/Config.in                     |  14 +-
 package/udisks/Config.in                      |  25 +-
 7 files changed, 287 insertions(+), 18 deletions(-)
 create mode 100644 package/polkit/0001-make-netgroup-support-optional.patch
DEVELOPERS +1 -0
index 16e8510b0a..9b52295ad8 100644
@@ -53,6 +53,7 @@ F:	package/openjdk/
 F:	package/openjdk-bin/
 F:	package/php/
 F:	package/policycoreutils/
+F:	package/polkit/
 F:	package/python3/
 F:	package/python-aioredis/
 F:	package/python-asgiref/
package/polkit/0001-make-netgroup-support-optional.patch new file +232 -0

232 lines not on this page · raw message

package/polkit/Config.in +18 -5
index ac17cb4dc3..853f81347a 100644
@@ -1,11 +1,17 @@
 config BR2_PACKAGE_POLKIT
 	bool "polkit"
+	depends on BR2_INSTALL_LIBSTDCPP # spidermonkey
+	depends on BR2_PACKAGE_DBUS # runtime
+	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS # spidermonkey
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # spidermonkey
+	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # spidermonkey
 	depends on BR2_USE_MMU # libglib2
-	depends on BR2_TOOLCHAIN_HAS_THREADS # libglib2
-	depends on BR2_TOOLCHAIN_USES_GLIBC
 	depends on BR2_USE_WCHAR # libglib2
-	select BR2_PACKAGE_LIBGLIB2
+	depends on !BR2_STATIC_LIBS # spidermonkey
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # spidermonkey
 	select BR2_PACKAGE_EXPAT
+	select BR2_PACKAGE_LIBGLIB2
+	select BR2_PACKAGE_SPIDERMONKEY
 	help
 	  PolicyKit is a toolkit for defining and handling
 	  authorizations. It is used for allowing unprivileged
@@ -13,6 +19,13 @@ config BR2_PACKAGE_POLKIT
 
 	  http://www.freedesktop.org/wiki/Software/polkit
 
-comment "polkit needs a toolchain w/ wchar, threads"
+comment "polkit needs a glibc or musl toolchain with C++, wchar, dynamic library, NPTL, gcc >= 4.9"
 	depends on BR2_USE_MMU
-	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_PACKAGE_DBUS
+	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_USES_UCLIBC || \
+		!BR2_INSTALL_LIBSTDCPP || \
+		BR2_STATIC_LIBS || \
+		!BR2_TOOLCHAIN_HAS_THREADS_NPTL || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
+		!BR2_USE_WCHAR
package/polkit/polkit.hash +1 -1
index 6368091c4a..bacd682139 100644
@@ -1,5 +1,5 @@
 # Locally calculated after checking pgp signature
-sha256	8fdc7cc8ba4750fcce1a4db9daa759c12afebc7901237e1c993c38f08985e1df	polkit-0.105.tar.gz
+sha256	88170c9e711e8db305a12fdb8234fac5706c61969b94e084d0f117d8ec5d34b1	polkit-0.116.tar.gz
 
 # Locally calculated
 sha256	d2e2aa973e29c75e1b492e67ea7b7da9de2d501d49a934657971fd74f9a0b0a8	COPYING
package/polkit/polkit.mk +5 -3
index fb4c171c52..507d1865fa 100644
@@ -4,20 +4,22 @@
 #
 ################################################################################
 
-POLKIT_VERSION = 0.105
+POLKIT_VERSION = 0.116
 POLKIT_SITE = http://www.freedesktop.org/software/polkit/releases
 POLKIT_LICENSE = GPL-2.0
 POLKIT_LICENSE_FILES = COPYING
 
 POLKIT_INSTALL_STAGING = YES
 
-POLKIT_DEPENDENCIES = libglib2 host-intltool expat
+POLKIT_DEPENDENCIES = libglib2 host-intltool expat spidermonkey
 
 # We could also support --with-authfw=pam
 POLKIT_CONF_OPTS = \
 	--with-authfw=shadow \
 	--with-os-type=unknown \
 	--disable-man-pages \
-	--disable-examples
+	--disable-examples \
+	--disable-libelogind \
+	--disable-libsystemd-login
 
 $(eval $(autotools-package))
package/systemd/Config.in +11 -3
index aef39abe27..abfe35d17b 100644
@@ -275,7 +275,11 @@ config BR2_PACKAGE_SYSTEMD_NETWORKD
 
 config BR2_PACKAGE_SYSTEMD_POLKIT
 	bool "enable polkit support"
-	depends on BR2_TOOLCHAIN_USES_GLIBC # polkit
+	depends on BR2_INSTALL_LIBSTDCPP # polkit -> spidermonkey
+	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS # polkit -> spidermonkey
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # polkit -> spidermonkey
+	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # polkit -> spidermonkey
+	depends on BR2_USE_WCHAR # libglib2
 	select BR2_PACKAGE_POLKIT
 	help
 	  If enabled, systemd is built with polkit support and policy
@@ -285,8 +289,12 @@ config BR2_PACKAGE_SYSTEMD_POLKIT
 
 	  http://wiki.freedesktop.org/www/Software/polkit/
 
-comment "polkit support needs a glibc toolchain"
-	depends on !BR2_TOOLCHAIN_USES_GLIBC
+comment "polkit support needs a toolchain with C++, wchar, NPTL, gcc >= 4.9"
+	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS
+	depends on !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_HAS_THREADS_NPTL || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
+		!BR2_USE_WCHAR
 
 config BR2_PACKAGE_SYSTEMD_QUOTACHECK
 	bool "enable quotacheck tools"
package/udisks/Config.in +19 -6
index c1e5538fb5..2a7f4c3776 100644
@@ -1,11 +1,14 @@
 config BR2_PACKAGE_UDISKS
 	bool "udisks"
+	depends on BR2_INSTALL_LIBSTDCPP # spidermonkey
 	depends on BR2_PACKAGE_HAS_UDEV
-	depends on BR2_TOOLCHAIN_HAS_THREADS # dbus-glib -> glib2
-	depends on BR2_TOOLCHAIN_USES_GLIBC # polkit, lvm2
+	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS # spidermonkey
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # spidermonkey
+	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # polkit
 	depends on BR2_USE_MMU # lvm2
-	depends on !BR2_STATIC_LIBS # lvm2
 	depends on BR2_USE_WCHAR # dbus-glib -> glib2
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC # polkit, lvm2
+	depends on !BR2_STATIC_LIBS # lvm2, spidermonkey
 	select BR2_PACKAGE_DBUS
 	select BR2_PACKAGE_DBUS_GLIB
 	select BR2_PACKAGE_SG3_UTILS
@@ -30,17 +33,27 @@ if BR2_PACKAGE_UDISKS
 
 config BR2_PACKAGE_UDISKS_LVM2
 	bool "lvm2 support"
+	# The lvm app library can't compile agianst musl
+	depends on BR2_TOOLCHAIN_USES_GLIBC
 	select BR2_PACKAGE_LVM2_APP_LIBRARY
 	help
 	  Enable LVM2 support
 
+comment "lvm2 support needs a glibc toolchain"
+	depends on !BR2_TOOLCHAIN_USES_GLIBC
+
 endif
 
 comment "udisks needs udev /dev management"
 	depends on BR2_USE_MMU
 	depends on !BR2_PACKAGE_HAS_UDEV
 
-comment "udisks needs a glibc toolchain w/ wchar, threads, dynamic library"
+comment "udisks needs a glibc or musl toolchain with C++, wchar, dynamic library, NPTL, gcc >= 4.9"
 	depends on BR2_USE_MMU
-	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
-		BR2_STATIC_LIBS || !BR2_TOOLCHAIN_USES_GLIBC
+	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_USES_UCLIBC || \
+		!BR2_INSTALL_LIBSTDCPP || \
+		BR2_STATIC_LIBS || \
+		!BR2_TOOLCHAIN_HAS_THREADS_NPTL || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
+		!BR2_USE_WCHAR
Signature · 1 line
2.23.0
#1 lore raw

PATCH v5 2/6 package/polkit: support different authentication frameworks

From: Adam Duskett <[email protected]>

Use pam if available, otherwise use shadow.

---
 package/polkit/polkit.mk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/polkit/polkit.mk +6 -2
index 507d1865fa..7791d23d19 100644
@@ -13,13 +13,17 @@ POLKIT_INSTALL_STAGING = YES
 
 POLKIT_DEPENDENCIES = libglib2 host-intltool expat spidermonkey
 
-# We could also support --with-authfw=pam
 POLKIT_CONF_OPTS = \
-	--with-authfw=shadow \
 	--with-os-type=unknown \
 	--disable-man-pages \
 	--disable-examples \
 	--disable-libelogind \
 	--disable-libsystemd-login
 
+ifeq ($(BR2_PACKAGE_LINUX_PAM),y)
+POLKIT_CONF_OPTS += --with-authfw=pam
+else
+POLKIT_CONF_OPTS += --with-authfw=shadow
+endif
+
 $(eval $(autotools-package))
Signature · 1 line
2.23.0
#2 lore raw

PATCH v5 3/6 package/polkit: add systemd service file.

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

- Add polkit.service for systemd based systems.
- Add a polkitd user upon which /usr/lib/polkit-1/polkitd relies.
- Set appropriate directory permissions to allow the polkitd user to access rules and actions.
- Set appropriate default attributes for the pkexec binary.

---
Changes v1 -> v5:
- Add a [install] section to the servie file (J?r?my)

 package/polkit/polkit.mk      | 18 ++++++++++++++++++
 package/polkit/polkit.service | 10 ++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 package/polkit/polkit.service
package/polkit/polkit.mk +18 -0
index 7791d23d19..b440cd2f1c 100644
@@ -26,4 +26,22 @@ else
 POLKIT_CONF_OPTS += --with-authfw=shadow
 endif
 
+define POLKIT_USERS
+	polkitd -1 polkitd -1 * - - - Polkit Daemon
+endef
+
+define POLKIT_PERMISSIONS
+	/etc/polkit-1 r 750 root polkitd - - - - -
+	/usr/share/polkit-1 r 750 root polkitd - - - - -
+	/usr/bin/pkexec f 4755 root root - - - - -
+endef
+
+define POLKIT_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 644 package/polkit/polkit.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/polkit.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -sf ../../../../usr/lib/systemd/system/polkit.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/polkit.service
+endef
+
 $(eval $(autotools-package))
package/polkit/polkit.service new file +10 -0
new file mode 100644
index 0000000000..977b4acc5f
@@ -0,0 +1,10 @@
+[Unit]
+Description=Authorization Manager
+
+[Service]
+Type=dbus
+BusName=org.freedesktop.PolicyKit1
+ExecStart=/usr/lib/polkit-1/polkitd --no-debug
+
+[Install]
+WantedBy=multi-user.target
Signature · 1 line
2.23.0
#3 lore raw

PATCH v5 4/6 support/testing: add polkit systemd test

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

This test is a simple integration test of the polkit package on systems running systemd.

It consists of the following:
- The brtest user attempts to restart the systemd-timesyncd service and is denied.

- A systemd-timesyncd-restart.rules file provided by polkit-rules-test-systemd is copied from /root/ to /etc/polkit-1/rules.d

- The brtest user attempts to restart the systemd-timesyncd service and should now succeed.

---
Changes v1 -> v5:
- Reorder this patch in the series.
- Add test to .gitlab-ci.yml
- Instead of a seperate test file for both systemd and initd, use just a single file called test_polkit.py.

 .gitlab-ci.yml                                |  1 +
 DEVELOPERS                                    |  2 +
 .../package/br2-external/polkit/Config.in     |  1 +
 .../package/br2-external/polkit/external.desc |  1 +
 .../package/br2-external/polkit/external.mk   |  1 +
 .../polkit-rules-test-systemd/Config.in       |  6 +++
 .../polkit-rules-test-systemd.mk              | 20 ++++++++
 .../systemd-timesyncd-restart.rules           |  7 +++
 support/testing/tests/package/test_polkit.py  | 51 +++++++++++++++++++
 9 files changed, 90 insertions(+)
 create mode 100644 support/testing/tests/package/br2-external/polkit/Config.in
 create mode 100644 support/testing/tests/package/br2-external/polkit/external.desc
 create mode 100644 support/testing/tests/package/br2-external/polkit/external.mk
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-systemd/Config.in
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-systemd/polkit-rules-test-systemd.mk
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-systemd/systemd-timesyncd-restart.rules
 create mode 100644 support/testing/tests/package/test_polkit.py
.gitlab-ci.yml +1 -0
index 22befa0427..05f717344a 100644
@@ -425,6 +425,7 @@ tests.package.test_perl_libwww_perl.TestPerllibwwwperl: { extends: .runtime_test
 tests.package.test_perl_mail_dkim.TestPerlMailDKIM: { extends: .runtime_test }
 tests.package.test_perl_x10.TestPerlX10: { extends: .runtime_test }
 tests.package.test_perl_xml_libxml.TestPerlXMLLibXML: { extends: .runtime_test }
+tests.package.test_polkit.TestPolkitSystemd: { extends: .runtime_test }
 tests.package.test_prosody.TestProsodyLua51: { extends: .runtime_test }
 tests.package.test_prosody.TestProsodyLuajit: { extends: .runtime_test }
 tests.package.test_python.TestPython2: { extends: .runtime_test }
DEVELOPERS +2 -0
index 9b52295ad8..916655b0c4 100644
@@ -76,6 +76,8 @@ F:	package/setools/
 F:	package/sngrep/
 F:	package/spidermonkey/
 F:	package/systemd/
+F:	support/testing/tests/package/br2-external/polkit/
+F:	support/testing/tests/package/test_polkit.py
 
 N:	Adam Heinrich <[email protected]>
 F:	package/jack1/
support/testing/tests/package/br2-external/polkit/Config.in new file +1 -0
new file mode 100644
index 0000000000..bb555b5097
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_POLKIT_PATH/package/polkit-rules-test-systemd/Config.in"
support/testing/tests/package/br2-external/polkit/external.desc new file +1 -0
new file mode 100644
index 0000000000..ecef48692b
@@ -0,0 +1 @@
+name: POLKIT
support/testing/tests/package/br2-external/polkit/external.mk new file +1 -0
new file mode 100644
index 0000000000..64e369cce4
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_POLKIT_PATH)/package/*/*.mk))
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-systemd/Config.in new file +6 -0
new file mode 100644
index 0000000000..662b991d3b
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_POLKIT_RULES_TEST_SYSTEMD
+	bool "polkit rules test for systemd"
+	depends on BR2_PACKAGE_POLKIT
+	help
+	  Simple test to ensure polkit is loading and enforcing rules
+	  correctly using a rules file meant for systemd.
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-systemd/polkit-rules-test-systemd.mk new file +20 -0
new file mode 100644
index 0000000000..19a6be2b2f
@@ -0,0 +1,20 @@
+################################################################################
+#
+# polkit-rules-test-systemd
+#
+################################################################################
+
+POLKIT_RULES_TEST_SYSTEMD_DEPENDENCIES = polkit
+
+define POLKIT_RULES_TEST_SYSTEMD_USERS
+	brtest  -1  brtest  -1   =password  /home/brtest /bin/sh brtest
+endef
+
+define POLKIT_RULES_TEST_SYSTEMD_INSTALL_TARGET_CMDS
+	mkdir -p $(TARGET_DIR)/etc/polkit-1/rules.d
+
+	$(INSTALL) -D $(POLKIT_RULES_TEST_SYSTEMD_PKGDIR)/systemd-timesyncd-restart.rules \
+		$(TARGET_DIR)/root/systemd-timesyncd-restart.rules
+endef
+
+$(eval $(generic-package))
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-systemd/systemd-timesyncd-restart.rules new file +7 -0
new file mode 100644
index 0000000000..9461195091
@@ -0,0 +1,7 @@
+polkit.addRule(function(action, subject) {
+    if (action.id == "org.freedesktop.systemd1.manage-units" &&
+        action.lookup("unit") == "systemd-timesyncd.service" &&
+        subject.user == "brtest") {
+        return polkit.Result.YES;
+    }
+});
support/testing/tests/package/test_polkit.py new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.23.0
#4 lore raw

PATCH v5 5/6 package/polkit: add init service file

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

Add a S50polkit file which starts polkit for non-systemd based systems.

---
Changes v1 -> v5:
- Reorder this patch in the series.

 package/polkit/S50polkit | 15 +++++++++++++++
 package/polkit/polkit.mk |  5 +++++
 2 files changed, 20 insertions(+)
 create mode 100644 package/polkit/S50polkit
package/polkit/S50polkit new file +15 -0
new file mode 100644
index 0000000000..55c10e99ae
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# start polkitd
+#
+
+case "$1" in
+	start)
+		start-stop-daemon -q -S -x /usr/lib/polkit-1/polkitd -- --no-debug &
+		;;
+	*)
+  echo "Usage: $0 {start}"
+		exit 1
+esac
+
+exit $?
package/polkit/polkit.mk +5 -0
index b440cd2f1c..8bb4512aee 100644
@@ -44,4 +44,9 @@ define POLKIT_INSTALL_INIT_SYSTEMD
 		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/polkit.service
 endef
 
+define POLKIT_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 0755 package/polkit/S50polkit \
+		$(TARGET_DIR)/etc/init.d/S50polkit
+endef
+
 $(eval $(autotools-package))
Signature · 1 line
2.23.0
#5 lore raw

PATCH v5 6/6 support/testing: add polkit initd test

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

This test is a simple integration test of the polkit package on systems running systemd.

It consists of the following:
- The brtest user attempts to restart the systemd-timesyncd service and is denied.

- A systemd-timesyncd-restart.rules file provided by polkit-rules-test-systemd is copied from /root/ to /etc/polkit-1/rules.d

- The brtest user attempts to restart the systemd-timesyncd service and should now succeed.

---
Changes v1 -> v5:
- Reorder this patch in the series.
- Add test to .gitlab-ci.yml
- Instead of a seperate test file, add the test to test_polkit.py in another class.

 .gitlab-ci.yml                                |  1 +
 .../package/br2-external/polkit/Config.in     |  1 +
 .../package/polkit-rules-test-initd/Config.in |  6 +++
 .../polkit-rules-test-initd/hello-polkit.c    |  6 +++
 .../hello-polkit.policy                       | 14 ++++++
 .../hello-polkit.rules                        |  6 +++
 .../polkit-rules-test-initd.mk                | 31 ++++++++++++
 support/testing/tests/package/test_polkit.py  | 49 +++++++++++++++++++
 8 files changed, 114 insertions(+)
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/Config.in
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/hello-polkit.c
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/hello-polkit.policy
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/hello-polkit.rules
 create mode 100644 support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/polkit-rules-test-initd.mk
.gitlab-ci.yml +1 -0
index 05f717344a..e9e1d193ad 100644
@@ -426,6 +426,7 @@ tests.package.test_perl_mail_dkim.TestPerlMailDKIM: { extends: .runtime_test }
 tests.package.test_perl_x10.TestPerlX10: { extends: .runtime_test }
 tests.package.test_perl_xml_libxml.TestPerlXMLLibXML: { extends: .runtime_test }
 tests.package.test_polkit.TestPolkitSystemd: { extends: .runtime_test }
+tests.package.test_polkit.TestPolkitInitd: { extends: .runtime_test }
 tests.package.test_prosody.TestProsodyLua51: { extends: .runtime_test }
 tests.package.test_prosody.TestProsodyLuajit: { extends: .runtime_test }
 tests.package.test_python.TestPython2: { extends: .runtime_test }
support/testing/tests/package/br2-external/polkit/Config.in +1 -0
index bb555b5097..97309b9fca 100644
@@ -1 +1,2 @@
+source "$BR2_EXTERNAL_POLKIT_PATH/package/polkit-rules-test-initd/Config.in"
 source "$BR2_EXTERNAL_POLKIT_PATH/package/polkit-rules-test-systemd/Config.in"
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/Config.in new file +6 -0
new file mode 100644
index 0000000000..f19fc2660d
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_POLKIT_RULES_TEST_INITD
+	bool "polkit rules test for initd"
+	depends on BR2_PACKAGE_POLKIT
+	help
+	  Simple test to ensure polkit is loading and enforcing rules
+	  correctly using initd.
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/hello-polkit.c new file +6 -0
new file mode 100644
index 0000000000..cf5343cd75
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void){
+    printf("Hello polkit!\n");
+    return 0;
+}
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/hello-polkit.policy new file +14 -0
new file mode 100644
index 0000000000..8220293175
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
+<policyconfig>
+  <action id="org.freedesktop.policykit.pkexec.hello-polkit">
+    <message>Authentication is required to run the hello world test program</message>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>no</allow_active>
+    </defaults>
+    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/hello-polkit</annotate>
+  </action>
+</policyconfig>
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/hello-polkit.rules new file +6 -0
new file mode 100644
index 0000000000..a0a66f644d
@@ -0,0 +1,6 @@
+polkit.addRule(function(action, subject) {
+   if (action.id == "org.freedesktop.policykit.pkexec.hello-polkit" &&
+       subject.user == "brtest") {
+       return polkit.Result.YES;
+   }
+});
support/testing/tests/package/br2-external/polkit/package/polkit-rules-test-initd/polkit-rules-test-initd.mk new file +31 -0
new file mode 100644
index 0000000000..394c3e4405
@@ -0,0 +1,31 @@
+################################################################################
+#
+# polkit-rules-test-initd
+#
+################################################################################
+
+POLKIT_RULES_TEST_INITD_DEPENDENCIES = polkit
+
+define POLKIT_RULES_TEST_INITD_USERS
+	brtest  -1  brtest  -1   =password  /home/brtest /bin/sh brtest
+endef
+
+define POLKIT_RULES_TEST_INITD_BUILD_CMDS
+	$(INSTALL) -D $(POLKIT_RULES_TEST_INITD_PKGDIR)/hello-polkit.c $(@D)/hello-polkit.c
+	$(TARGET_CC) $(@D)/hello-polkit.c -o $(@D)/hello-polkit
+endef
+
+
+define POLKIT_RULES_TEST_INITD_INSTALL_TARGET_CMDS
+	mkdir -p $(TARGET_DIR)/usr/share/polkit-1/actions/
+	$(INSTALL) -D $(@D)/hello-polkit $(TARGET_DIR)/usr/bin/hello-polkit
+
+	$(INSTALL) -D $(POLKIT_RULES_TEST_INITD_PKGDIR)/hello-polkit.policy \
+		$(TARGET_DIR)/usr/share/polkit-1/actions/hello-polkit.policy
+
+	$(INSTALL) -D $(POLKIT_RULES_TEST_INITD_PKGDIR)/hello-polkit.rules \
+		$(TARGET_DIR)/root/hello-polkit.rules
+
+endef
+
+$(eval $(generic-package))
support/testing/tests/package/test_polkit.py +49 -0

52 lines not on this page · raw message

Signature · 1 line
2.23.0