diff --git a/certbot.wrapper b/certbot.wrapper index 63be01675..973f8c6ac 100755 --- a/certbot.wrapper +++ b/certbot.wrapper @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh -x set -e # This code is based on snapcraft's own patch to work around this problem at @@ -27,25 +27,9 @@ case "${SNAP_ARCH}" in exit 1 esac -snap_connections=$(snap connections certbot) +export CERTBOT_AUGEAS_PATH="${SNAP}/usr/lib/${ARCH_TRIPLET}/libaugeas.so.0" -PARTIAL_LIBRARY_PATH="${SNAP}/usr/lib/${ARCH_TRIPLET}/" -export LD_LIBRARY_PATH="${PARTIAL_LIBRARY_PATH}:${LD_LIBRARY_PATH}" -export CERTBOT_AUGEAS_PATH="${PARTIAL_LIBRARY_PATH}libaugeas.so.0" +CERTBOT_PLUGIN_PATH="$(curl -s --unix /run/snapd.socket "http://localhost/v2/connections?snap=certbot&interface=content" | jq -r '.result.established | map(select(.plug.plug == "plugin" and ."plug-attrs".content == "certbot-1") | "/snap/"+.slot.snap+"/current/lib/python3.8/site-packages" ) | join(":")')" +export CERTBOT_PLUGIN_PATH -# Below this line, all invoked programs must be provided by the snap rather than the host (#8245) - -join() { - sep=$1 - first=$2 - if [ "$first" != "" ]; then - shift 2 - echo -n "${first}" - for item in "$@"; do echo -n "${sep}${item}"; done - echo - fi -} - -paths=$(for plugin_snap in $(gawk 'NR>1 { if ($1 == "content[certbot-1]") { split($3,a,":"); print a[1]; } }'<<<"$snap_connections"); do echo /snap/$plugin_snap/current/lib/python3.8/site-packages; done) -export CERTBOT_PLUGIN_PATH=$(join : $paths) exec certbot "$@" diff --git a/snap/hooks/configure b/snap/hooks/configure index 2678c47b2..9545f8b8a 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -1,3 +1,3 @@ -#!/bin/bash -e +#!/bin/sh -e exit 0 diff --git a/snap/hooks/prepare-plug-plugin b/snap/hooks/prepare-plug-plugin index ee309addf..f2f7ff86b 100644 --- a/snap/hooks/prepare-plug-plugin +++ b/snap/hooks/prepare-plug-plugin @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/sh -e if [ "$(snapctl get trust-plugin-with-root)" = "ok" ]; then # allow the connection, but reset config to allow for other slots to go through this auth flow diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 342f32a08..c32e8c6b3 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -72,7 +72,8 @@ parts: - python3-pkg-resources - python3.8-minimal # added for certbot.wrapper script: - - gawk + - curl + - jq # To build cryptography and cffi if needed build-packages: [gcc, libffi-dev, libssl-dev, git, libaugeas-dev, python3-dev] build-environment: