Skip to content

Commit 06ffd21

Browse files
authored
Merge pull request #1197 from openziti/allow-polkit
let polkitd satisfy the package dependency for policy kit
2 parents 1610a49 + f3374b8 commit 06ffd21

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

programs/ziti-edge-tunnel/package/CPackGenConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ if(CPACK_GENERATOR MATCHES "DEB")
3939
# specify "libssl3 if it exists in the repos, or nothing" as a dependency.
4040
# systemd package on older distros does not contain `systemd-sysusers`, so include passwd for `useradd`, `groupadd`.
4141
# login provides `/usr/sbin/nologin`.
42-
set(CPACK_DEBIAN_PACKAGE_DEPENDS "debconf, iproute2, sed, systemd, libatomic1, libjson-c3 | libjson-c4 | libjson-c5 , libprotobuf-c1, libssl3 | libssl1.1 | libssl1.0.0, login, passwd, policykit-1, zlib1g")
42+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "debconf, iproute2, sed, systemd, libatomic1, libjson-c3 | libjson-c4 | libjson-c5 , libprotobuf-c1, libssl3 | libssl1.1 | libssl1.0.0, login, passwd, policykit-1 | polkitd, zlib1g")
4343
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEB_CONFFILES};${CPACK_DEB_PRE_INSTALL};${CPACK_DEB_POST_INSTALL};${CPACK_DEB_PRE_UNINSTALL};${CPACK_DEB_POST_UNINSTALL};${CPACK_DEB_TEMPLATES}")
4444
endif(CPACK_GENERATOR MATCHES "DEB")

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

scripts/ziti-builder.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function set_workspace(){
7070
--volume "${REPODIR}:${WORKSPACE}" \
7171
"${ZITI_SDK_DIR:+--volume=${ZITI_SDK_DIR}:${ZITI_SDK_DIR}}" \
7272
--platform "linux/amd64" \
73-
--env "VCPKG_DEFAULT_BINARY_CACHE=${WORKSPACE}/.cache" \
73+
--env "VCPKG_BINARY_SOURCES=clear;files,${WORKSPACE}/vcpkg_cache,readwrite" \
7474
--env "TLSUV_TLSLIB" \
7575
--env "ZITI_SDK_DIR" \
7676
--env "ZITI_SDK_VERSION" \
@@ -119,10 +119,10 @@ function main() {
119119
exec "${@}"
120120
else
121121
[[ -d ./build ]] && rm -rf ./build
122-
[[ -d ./.cache ]] || mkdir -v ./.cache
122+
mkdir -pv ./vcpkg_cache
123123
cmake \
124124
-E make_directory \
125-
./build
125+
./build
126126
cmake \
127127
--preset "${CMAKE_PRESET:-ci-linux-x64}" \
128128
-DCMAKE_BUILD_TYPE="${CMAKE_CONFIG:-Release}" \

0 commit comments

Comments
 (0)