Skip to content

Commit b5868bb

Browse files
committed
do nothing if polkitd
1 parent f9ad3a8 commit b5868bb

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

programs/ziti-edge-tunnel/package/deb/postinst.in

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,32 @@ if [ "$1" = "configure" ]; then
4747
chmod 0770 "@ZITI_IDENTITY_DIR@"
4848
find "@ZITI_IDENTITY_DIR@" -maxdepth 1 -name "*.json" -type f -exec chown ziti:ziti "{}" + -exec chmod 0660 "{}" +
4949

50-
# sort ascending the installed and max policykit versions, saving the highest version, so we
51-
# can ensure the installed version is less than the max version
52-
policykit_version="$(dpkg-query -Wf '${Version}' policykit-1)"
53-
max_policykit_version="0.106"
54-
highest_policykit_version="$(printf '%s\n' ${policykit_version} ${max_policykit_version} | sort -V | tail -n1)"
55-
56-
# sort ascending the installed and min systemd versions, saving the lowest version, so we can ensure the installed
57-
# version is greater than or equal to the min version
58-
systemd_version=$(dpkg-query -Wf '${Version}' systemd)
59-
min_systemd_version="243"
60-
lowest_systemd_version="$(printf '%s\n' ${systemd_version} ${min_systemd_version} | sort -V | head -n1)"
61-
62-
# install PolicyKit policy if < v0.106 (https://askubuntu.com/questions/1287924/whats-going-on-with-policykit)
63-
if [ ${policykit_version} != ${max_policykit_version} ] && [ ${max_policykit_version} = ${highest_policykit_version} ]; then
64-
# run as root unless systemd >= v243 (required set-llmnr introduced v243 https://github.com/systemd/systemd/commit/52aaef0f5dc81b9a08d720f551eac53ac88aa596)
65-
if [ ${systemd_version} = ${min_systemd_version} ] || [ ${min_systemd_version} = ${lowest_systemd_version} ]; then
66-
cp "@CPACK_SHARE_DIR@/@[email protected]" "/var/lib/polkit-1/localauthority/10-vendor.d/@ZITI_POLKIT_PKLA_FILE@"
67-
db_set ziti_edge_tunnel/install_pkla true
68-
else
69-
service_user=root
70-
override_dir="@SYSTEMD_UNIT_DIR@/@[email protected]"
71-
mkdir -p "${override_dir}/"
72-
( echo '[Service]'; echo "User=root" ) > "${override_dir}/10-run-as-root.conf"
50+
# If polkitd is installed, skip PolicyKit-1 evaluation and do not place a .pkla file
51+
if dpkg-query -W -f='${Status}' polkitd 2>/dev/null | grep -q "install ok installed"; then
52+
: # no-op when polkitd is present
53+
else
54+
# determine PolicyKit-1 version robustly
55+
policykit_version="$(dpkg-query -Wf '${Version}' policykit-1 2>/dev/null || true)"
56+
max_policykit_version="0.106"
57+
highest_policykit_version="$(printf '%s\n' "${policykit_version}" "${max_policykit_version}" | sort -V | tail -n1)"
58+
59+
# determine installed systemd version robustly
60+
systemd_version="$(dpkg-query -Wf '${Version}' systemd 2>/dev/null || true)"
61+
min_systemd_version="243"
62+
lowest_systemd_version="$(printf '%s\n' "${systemd_version}" "${min_systemd_version}" | sort -V | head -n1)"
63+
64+
# install PolicyKit localauthority policy if PolicyKit-1 < v0.106 (https://askubuntu.com/questions/1287924/whats-going-on-with-policykit)
65+
if [ -n "${policykit_version}" ] && [ "${policykit_version}" != "${max_policykit_version}" ] && [ "${max_policykit_version}" = "${highest_policykit_version}" ]; then
66+
# run as root unless systemd >= v243 (required set-llmnr introduced v243 https://github.com/systemd/systemd/commit/52aaef0f5dc81b9a08d720f551eac53ac88aa596)
67+
if [ -n "${systemd_version}" ] && { [ "${systemd_version}" = "${min_systemd_version}" ] || [ "${min_systemd_version}" = "${lowest_systemd_version}" ]; }; then
68+
cp "@CPACK_SHARE_DIR@/@[email protected]" "/var/lib/polkit-1/localauthority/10-vendor.d/@ZITI_POLKIT_PKLA_FILE@"
69+
db_set ziti_edge_tunnel/install_pkla true
70+
else
71+
service_user=root
72+
override_dir="@SYSTEMD_UNIT_DIR@/@[email protected]"
73+
mkdir -p "${override_dir}/"
74+
( echo '[Service]'; echo "User=root" ) > "${override_dir}/10-run-as-root.conf"
75+
fi
7376
fi
7477
fi
7578

0 commit comments

Comments
 (0)