From 2cf32806dcce2d41920be28bd0e7d12e5d049357 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 27 Jul 2020 18:18:38 +0200 Subject: [pkg] update build script for openvpn --- installer/bitmask-installer.pro | 5 ++ installer/config/config.xml | 2 + installer/packages/riseupvpn/data/.gitignore | 3 ++ installer/packages/riseupvpn/data/post-install.py | 54 ++++++++++++++-------- .../riseupvpn/data/se.leap.bitmask-helper.plist | 26 +++++++++++ 5 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 installer/packages/riseupvpn/data/.gitignore create mode 100644 installer/packages/riseupvpn/data/se.leap.bitmask-helper.plist (limited to 'installer') diff --git a/installer/bitmask-installer.pro b/installer/bitmask-installer.pro index 1435e4c..49179c4 100644 --- a/installer/bitmask-installer.pro +++ b/installer/bitmask-installer.pro @@ -22,6 +22,11 @@ macx { OTHER_FILES += "packages/riseupvpn/data/riseup-vpn.app" OTHER_FILES += "packages/riseupvpn/data/bitmask-helper" OTHER_FILES += "packages/riseupvpn/data/installer.py" + OTHER_FILES += "packages/riseupvpn/data/se.leap.bitmask-helper.plist" + OTHER_FILES += "packages/riseupvpn/data/openvpn.leap" + OTHER_FILES += "packages/riseupvpn/data/helper/bitmask.pf.conf" + OTHER_FILES += "packages/riseupvpn/data/client.up.sh" + OTHER_FILES += "packages/riseupvpn/data/client.down.sh" } linux { OTHER_FILES += "packages/riseupvpn/data/riseup-vpn" diff --git a/installer/config/config.xml b/installer/config/config.xml index ef0e5e8..492e76f 100644 --- a/installer/config/config.xml +++ b/installer/config/config.xml @@ -1,6 +1,7 @@ RiseupVPN Installer 1.0 + LEAP Encryption Access Project RiseupVPN Installer 1.0.0 @ApplicationsDir@/RiseupVPN @@ -9,4 +10,5 @@ http://localhost/repository/ + mac diff --git a/installer/packages/riseupvpn/data/.gitignore b/installer/packages/riseupvpn/data/.gitignore new file mode 100644 index 0000000..63c86a1 --- /dev/null +++ b/installer/packages/riseupvpn/data/.gitignore @@ -0,0 +1,3 @@ +openvpn.leap +bitmask-helper +riseup-vpn.app diff --git a/installer/packages/riseupvpn/data/post-install.py b/installer/packages/riseupvpn/data/post-install.py index 1e1addd..02da859 100755 --- a/installer/packages/riseupvpn/data/post-install.py +++ b/installer/packages/riseupvpn/data/post-install.py @@ -1,49 +1,49 @@ #!/usr/bin/env python import os +import shutil import sys import subprocess HELPER = "bitmask-helper" HELPER_PLIST = "/Library/LaunchDaemons/se.leap.bitmask-helper.plist" +_dir = os.path.dirname(os.path.realpath(__file__)) def main(): - _dir = os.path.dirname(os.path.realpath(__file__)) log = open(os.path.join(_dir, 'post-install.log'), 'w') - log.write('Checking for admin privileges...') + log.write('Checking for admin privileges...\n') _id = os.getuid() if _id != 0: err = "error: need to run as root. UID: %s\n" % str(_id) - logErr(log, msg) + logErr(log, err) # failure: sys.exit(1) if isHelperRunning(): - log.write("Trying to stop bitmask-helper...") + log.write("Trying to stop bitmask-helper...\n") # if this fail, we can check if the HELPER_PLIST is there ok = unloadHelper() log.write("success: %s \n" % str(ok)) - ok = makeHelperExecutable() - log.write("chmod +x helper: %s \n" % str(ok)) + ok = fixHelperOwner(log) + log.write("chown helper: %s \n" % str(ok)) - # 3. cp se.leap.bitmask-helper.plist /Library/LaunchDaemons/ + log.write("Copy launch daemon...\n") copyLaunchDaemon() - # 4. launchctl load /Library/LaunchDaemons/se.leap.bitmask-helper.plist - launchHelper() + out = launchHelper() + log.write("Copy plist: %s \n" % str(ok)) - # 5. chown admin:wheel /Applications/$applicationName.app/Contents/helper # is this the folder? grantPermissionsOnLogFolder() - # all good - log.write('post-install script: done') + # all done + log.write('post-install script: done\n') sys.exit(0) def logErr(log, msg): - log.write(err) + log.write(msg) sys.exit(1) def isHelperRunning(): @@ -54,18 +54,34 @@ def unloadHelper(): out = subprocess.call(["launchctl", "unload", HELPER_PLIST]) return out == 0 -def makeHelperExecutable(): - out = subprocess.call(["chmod", "+x", HELPER]) - return out == 0 +def fixHelperOwner(log): + path = os.path.join(_dir, HELPER) + try: + os.chown(path, 0, 0) + except OSError as exc: + log.write(str(exc)) + return False + return True def copyLaunchDaemon(): - pass + plist = "se.leap.bitmask-helper.plist" + path = os.path.join(_dir, plist) + dest = os.path.join('/Library/LaunchDaemons', plist) + _p = _dir.replace("/", "\/") + subprocess.call(["sed", "-i.back", "s/PATH/%s/" % _p, path]) + shutil.copy(path, dest) def launchHelper(): - pass + out = subprocess.call(["launchctl", "load", "/Library/LaunchDaemons/se.leap.bitmask-helper.plist"]) + return out == 0 def grantPermissionsOnLogFolder(): - pass + helperDir = os.path.join(_dir, 'helper') + try: + os.makedirs(helperDir) + except Exception: + pass + os.chown(helperDir, 0, 0) def _getProcessList(): _out = [] diff --git a/installer/packages/riseupvpn/data/se.leap.bitmask-helper.plist b/installer/packages/riseupvpn/data/se.leap.bitmask-helper.plist new file mode 100644 index 0000000..c9d9687 --- /dev/null +++ b/installer/packages/riseupvpn/data/se.leap.bitmask-helper.plist @@ -0,0 +1,26 @@ + + + + + WorkingDirectory + /tmp + StandardOutPath + bitmask-helper.log + StandardErrorPath + bitmask-helper-err.log + GroupName + daemon + RunAtLoad + + SessionCreate + + KeepAlive + + ThrottleInterval + 5 + Label + se.leap.BitmaskHelper + Program + PATH/bitmask-helper + + -- cgit v1.2.3