Make Certbot find externally snapped plugins (#8054)

* Add snap plugin support

Switch to a PoC branch of certbot that supports the new
CERTBOT_PLUGIN_PATH and wrap the snap to set this variable correctly
based on the content interfaces connected.

(cherry picked from commit 7076a55fd82116d068e2aca7239209b7203917d2)

* Modify certbot.wrapper to append to PYTHONPATH instead of separate CERTBOT_PLUGIN_PATH variable

* Update certbot-wrapper to python3.6 version

* add source field

* Update changelog

* Use bash instead of sh

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>

* Exit if something goes wrong

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>

* No leading : when modifying empty PYTHONPATH

* Improve bash handling of PYTHONPATH manipulation

Co-authored-by: Robie Basak <robie.basak@canonical.com>
Co-authored-by: Brad Warren <bmw@eff.org>
Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
This commit is contained in:
ohemorange
2020-06-10 13:52:56 -07:00
committed by GitHub
co-authored by Brad Warren Robie Basak Brad Warren
parent 50fa04ba0c
commit 8d776fb7ac
3 changed files with 26 additions and 2 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
set -e
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 $(snap connections certbot|sed -n '2,$p'|awk '$1=="content[certbot-1]"{print $3}'|cut -d: -f1); do echo /snap/$plugin_snap/current/lib/python3.6/site-packages; done)
export PYTHONPATH=$(join : $PYTHONPATH $paths)
if [ -z "$PYTHONPATH" ]; then
unset PYTHONPATH
fi
exec certbot "$@"
+1
View File
@@ -7,6 +7,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
### Added ### Added
* Add minimal code to run Nginx plugin on NetBSD. * Add minimal code to run Nginx plugin on NetBSD.
* Make Certbot snap find externally snapped plugins
* Function `certbot.compat.filesystem.umask` is a drop-in replacement for `os.umask` * Function `certbot.compat.filesystem.umask` is a drop-in replacement for `os.umask`
implementing umask for both UNIX and Windows systems. implementing umask for both UNIX and Windows systems.
+6 -2
View File
@@ -7,7 +7,7 @@ description: |
browser-trusted certificate, without any human intervention. This is browser-trusted certificate, without any human intervention. This is
accomplished by running a certificate management agent on the web accomplished by running a certificate management agent on the web
server. server.
This agent is used to: This agent is used to:
- Automatically prove to the Let's Encrypt CA that you control the website - Automatically prove to the Let's Encrypt CA that you control the website
- Obtain a browser-trusted certificate and set it up on your web server - Obtain a browser-trusted certificate and set it up on your web server
@@ -20,7 +20,7 @@ adopt-info: certbot
apps: apps:
certbot: certbot:
command: certbot command: certbot.wrapper
environment: environment:
PATH: "$SNAP/bin:$SNAP/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" PATH: "$SNAP/bin:$SNAP/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
AUGEAS_LENS_LIB: "$SNAP/usr/share/augeas/lenses/dist" AUGEAS_LENS_LIB: "$SNAP/usr/share/augeas/lenses/dist"
@@ -85,6 +85,10 @@ parts:
# After certbot-apache to not rebuild duplicates (essentially sharing what was already staged, # After certbot-apache to not rebuild duplicates (essentially sharing what was already staged,
# like zope) # like zope)
after: [certbot-apache] after: [certbot-apache]
wrappers:
plugin: dump
source: .
stage: [certbot.wrapper]
plugs: plugs:
plugin: plugin: