From 9ee4859558b868f01012c39dd98bf292d64e09f0 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Mon, 5 Mar 2018 17:55:29 +0100 Subject: [pkg] minor adjustments for riseupvpn osx bundle - duplicate the scripts folder for riseupvpn - fix renaming of helper - set openvpn path for riseupvpn --- pkg/build_osx_bundle_riseupvpn_with_venv.sh | 3 +-- pkg/bundles/build.mk | 12 +++++----- pkg/osx/scripts-riseupvpn/postinstall | 13 +++++++++++ pkg/osx/scripts-riseupvpn/preinstall | 12 ++++++++++ .../scripts-riseupvpn/se.leap.bitmask-helper.plist | 26 ++++++++++++++++++++++ src/leap/bitmask/vpn/launchers/darwin.py | 24 ++++++++------------ 6 files changed, 67 insertions(+), 23 deletions(-) create mode 100755 pkg/osx/scripts-riseupvpn/postinstall create mode 100755 pkg/osx/scripts-riseupvpn/preinstall create mode 100644 pkg/osx/scripts-riseupvpn/se.leap.bitmask-helper.plist diff --git a/pkg/build_osx_bundle_riseupvpn_with_venv.sh b/pkg/build_osx_bundle_riseupvpn_with_venv.sh index 7f819849..2e7ec759 100755 --- a/pkg/build_osx_bundle_riseupvpn_with_venv.sh +++ b/pkg/build_osx_bundle_riseupvpn_with_venv.sh @@ -20,8 +20,7 @@ echo "[+] Using venv in" $VIRTUAL_ENV $VIRTUAL_ENV/bin/pip install -U pyinstaller $VIRTUAL_ENV/bin/pip install zope.interface zope.proxy - -$VIRTUAL_ENV/bin/pip install -r pkg/requirements-osx.pip +$VIRTUAL_ENV/bin/pip install -r pkg/requirements-vpn.pip # Get the bundled libzmq $VIRTUAL_ENV/bin/pip install -I pyzmq --install-option="--zmq=bundled" diff --git a/pkg/bundles/build.mk b/pkg/bundles/build.mk index e93199db..aa411239 100644 --- a/pkg/bundles/build.mk +++ b/pkg/bundles/build.mk @@ -169,16 +169,16 @@ bundle_anonvpn_osx_missing: mv $(OSX_ANON_CON)/anonvpn $(OSX_ANON_CON)/bitmask-app cp pkg/osx/bitmask-wrapper $(OSX_ANON_CON)/anonvpn mkdir -p $(OSX_ANON_RES)/bitmask-helper - cp -r pkg/osx/daemon $(OSX_ANON_RES)/bitmask-helper/ - cp -r pkg/osx/openvpn $(OSX_ANON_RES)/bitmask-helper/ + cp -r pkg/osx/openvpn/* $(OSX_ANON_RES)/ + cp -r pkg/osx/daemon/* $(OSX_ANON_RES)/bitmask-helper/ mkdir -p $(OSX_ANON_RES)/../apps/providers cp -r src/leap/bitmask/bonafide/providers/* $(OSX_ANON_RES)/../apps/providers/ cp -r $(ANONVPN_DIST_VERSION)/apps/providers/* $(OSX_ANON_RES)/../apps/providers cp src/leap/bitmask/vpn/helpers/osx/bitmask-helper $(OSX_ANON_RES)/bitmask-helper/ - sed "s/.*Bitmask.app.*/APP_PATH='\/Applications\/RiseupVPN\.app\/'/" $(OSX_ANON_RES)/bitmask-helper/bitmask-helper2 - mv $(OSX_ANON_RES)/bitmask-helper/bitmask-helper2 $(OSX_ANON_RES)/bitmask-helper/bitmask-helper + chmod +x $(OSX_ANON_RES)/bitmask-helper/bitmask-helper + sed "s/.*Bitmask.app.*/APP_PATH='\/Applications\/RiseupVPN\.app\/'/" $(OSX_ANON_RES)/bitmask-helper/bitmask-helper > $(OSX_ANON_RES)/bitmask-helper/bitmask-helper2 && mv $(OSX_ANON_RES)/bitmask-helper/bitmask-helper2 $(OSX_ANON_RES)/bitmask-helper/bitmask-helper cp src/leap/bitmask/vpn/helpers/osx/bitmask.pf.conf $(OSX_ANON_RES)/bitmask-helper/ - cp pkg/osx/scripts/se.leap.bitmask-helper.plist $(OSX_ANON_RES)/bitmask-helper/ + cp pkg/osx/scripts-riseupvpn/se.leap.bitmask-helper.plist $(OSX_ANON_RES)/bitmask-helper/ wget https://downloads.leap.se/thirdparty/osx/openvpn/openvpn -O $(OSX_ANON_RES)/openvpn.leap chmod +x $(OSX_ANON_RES)/openvpn.leap @@ -187,7 +187,7 @@ bundle_anonvpn_osx_pkg: cp ../bitmask-systray/bitmask-systray $(OSX_ANON_CON)/bitmask-systray cp /usr/local/opt/zeromq/lib/libzmq.5.dylib $(OSX_ANON_CON)/libzmq.5.dylib install_name_tool -change /usr/local/opt/zeromq/lib/libzmq.5.dylib "@loader_path/libzmq.5.dylib" $(OSX_ANON_CON)/bitmask-systray - pkg/osx/quickpkg --output dist/RiseupVPN-$(NEXT_VERSION)_pre.pkg --scripts pkg/osx/scripts/ dist/RiseupVPN.app/ + pkg/osx/quickpkg --output dist/RiseupVPN-$(NEXT_VERSION)_pre.pkg --scripts pkg/osx/scripts-riseupvpn/ dist/RiseupVPN.app/ @if [ $(BUILD_RELEASE) = no ]; then\ echo "[!] BUILD_RELEASE=no, skipping signature";\ else\ diff --git a/pkg/osx/scripts-riseupvpn/postinstall b/pkg/osx/scripts-riseupvpn/postinstall new file mode 100755 index 00000000..93430390 --- /dev/null +++ b/pkg/osx/scripts-riseupvpn/postinstall @@ -0,0 +1,13 @@ +#!/bin/sh +# Bitmask Post-Instalation script +# (c) LEAP Encryption access Project +# We copy the bitmask-helper plist to the LaunchDaemons folder, and load the bitmask-helper that runs as root. + +LOG=/tmp/bitmask-install.log + +chmod +x /Applications/RiseupVPN.app/Contents/Resources/bitmask-helper/bitmask-helper +cp se.leap.bitmask-helper.plist /Library/LaunchDaemons/ \ + && echo `date` ":: Bitmask post-install: copied bitmask-helper Plist." >> $LOG +launchctl load /Library/LaunchDaemons/se.leap.bitmask-helper.plist && echo `date` ":: Bitmask post-install: loaded bitmask-helper." >> $LOG +echo `date` ":: Bitmask post-install: ok." >> $LOG +exit 0 diff --git a/pkg/osx/scripts-riseupvpn/preinstall b/pkg/osx/scripts-riseupvpn/preinstall new file mode 100755 index 00000000..1ae68f9c --- /dev/null +++ b/pkg/osx/scripts-riseupvpn/preinstall @@ -0,0 +1,12 @@ +#!/bin/sh +# Bitmask Pre-Instalation script +# (c) LEAP Encryption access Project +# We unload the bitmask-helper if it is running, because we can be installing an upgrade. + +LOG=/tmp/bitmask-install.log + +ps aux | grep [b]itmask-helper \ + && launchctl unload /Library/LaunchDaemons/se.leap.bitmask-helper.plist \ + && echo `date` ":: Bitmask pre-install: unloaded bitmask-helper." >> $LOG +echo `date` ":: Bitmask pre-install: ok." >> $LOG +exit 0 diff --git a/pkg/osx/scripts-riseupvpn/se.leap.bitmask-helper.plist b/pkg/osx/scripts-riseupvpn/se.leap.bitmask-helper.plist new file mode 100644 index 00000000..8ebfb947 --- /dev/null +++ b/pkg/osx/scripts-riseupvpn/se.leap.bitmask-helper.plist @@ -0,0 +1,26 @@ + + + + + WorkingDirectory + /Applications/RiseupVPN.app/Contents/Resources/bitmask-helper/ + StandardOutPath + bitmask-helper.log + StandardErrorPath + bitmask-helper-err.log + GroupName + daemon + RunAtLoad + + SessionCreate + + KeepAlive + + ThrottleInterval + 5 + Label + se.leap.BitmaskHelper + Program + /Applications/RiseupVPN.app/Contents/Resources/bitmask-helper/bitmask-helper + + diff --git a/src/leap/bitmask/vpn/launchers/darwin.py b/src/leap/bitmask/vpn/launchers/darwin.py index 03393da2..d959b159 100644 --- a/src/leap/bitmask/vpn/launchers/darwin.py +++ b/src/leap/bitmask/vpn/launchers/darwin.py @@ -73,29 +73,23 @@ class DarwinVPNLauncher(VPNLauncher): # Hardcode the installation path for OSX for security, openvpn is # run as root - INSTALL_PATH = "/Applications/Bitmask.app/" - OPENVPN_BIN = 'openvpn.leap' - OPENVPN_PATH = "%s/Contents/Resources/openvpn" % (INSTALL_PATH,) - try: - INSTALL_PATH_ESCAPED = os.path.realpath(os.getcwd() + "/../../") - except OSError as exc: - # this might happen if os.getcwd() was deleted under our feet. We do - # not want to raise the Exception at import time. - logger.error('Error while setting openvpn paths: %r' % exc) - INSTALL_PATH_ESCAPED = "/Applications/Bitmask.app/" - OPENVPN_PATH_ESCAPED = "%s/Contents/Resources/openvpn" % ( - INSTALL_PATH_ESCAPED,) + if os.path.isdir('/Applications/RiseupVPN.app'): + INSTALL_PATH = '/Applications/RiseupVPN.app' + else: + INSTALL_PATH = '/Applications/Bitmask.app' - OTHER_FILES = [] + OPENVPN_BIN = 'openvpn.leap' + OPENVPN_PATH = "%s/Contents/Resources/" % (INSTALL_PATH,) - _openvpn_bin_path = "%s/Contents/Resources/%s" % ( - INSTALL_PATH, OPENVPN_BIN) + _openvpn_bin_path = os.path.join(OPENVPN_PATH, OPENVPN_BIN) if os.path.isfile(_openvpn_bin_path): OPENVPN_BIN_PATH = _openvpn_bin_path else: # let's try with the homebrew path OPENVPN_BIN_PATH = '/usr/local/sbin/openvpn' + OTHER_FILES = [] + def kill_previous_openvpn(): pass -- cgit v1.2.3