summaryrefslogtreecommitdiff
path: root/installer/packages/riseupvpn
diff options
context:
space:
mode:
Diffstat (limited to 'installer/packages/riseupvpn')
-rw-r--r--installer/packages/riseupvpn/data/.gitignore3
-rwxr-xr-xinstaller/packages/riseupvpn/data/post-install.py54
-rw-r--r--installer/packages/riseupvpn/data/se.leap.bitmask-helper.plist26
3 files changed, 64 insertions, 19 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>WorkingDirectory</key>
+ <string>/tmp</string>
+ <key>StandardOutPath</key>
+ <string>bitmask-helper.log</string>
+ <key>StandardErrorPath</key>
+ <string>bitmask-helper-err.log</string>
+ <key>GroupName</key>
+ <string>daemon</string>
+ <key>RunAtLoad</key>
+ <true/>
+ <key>SessionCreate</key>
+ <true/>
+ <key>KeepAlive</key>
+ <true/>
+ <key>ThrottleInterval</key>
+ <integer>5</integer>
+ <key>Label</key>
+ <string>se.leap.BitmaskHelper</string>
+ <key>Program</key>
+ <string>PATH/bitmask-helper</string>
+</dict>
+</plist>