summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2018-02-14 02:38:47 +0100
committerKali Kaneko <kali@leap.se>2018-02-15 16:36:58 +0100
commit5abd127f3780ca2078962ace489bd4c32b5d545d (patch)
tree4e3f81c695fe848906c89b4fd34c20a4e9c39e02
parent76878da40906af750aed62d63bd1e928bfa45163 (diff)
[pkg] packaging fixes for anonvpn bundle
-rw-r--r--Makefile12
-rw-r--r--pkg/bundles/build.mk4
-rw-r--r--pkg/docker_build_apt7
-rw-r--r--pkg/docker_build_riseupvpn45
-rw-r--r--pkg/docker_bundleapt/Dockerfile8
-rw-r--r--pkg/docker_bundleapt/Makefile6
-rw-r--r--pkg/docker_bundleapt/systray.sh10
-rw-r--r--pkg/launcher/Makefile2
-rw-r--r--pkg/launcher/bitmask-launcher.c33
-rw-r--r--pkg/pyinst/anonvpn.spec1
-rw-r--r--src/leap/bitmask/gui/app2.py1
11 files changed, 104 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index ef0d9c10..769e63cf 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,12 @@
DIST=dist/bitmask
-HEADLESS_DIST=dist/bitmask-nox
-ANONVPN_DIST=dist/riseupvpn
NEXT_VERSION = $(shell cat pkg/next-version)
-DIST_VERSION = dist/bitmask-$(NEXT_VERSION)/
-HEADLESS_DIST_VERSION = dist/bitmask-nox-$(NEXT_VERSION)/
-ANONVPN_DIST_VERSION = dist/riseupvpn-$(NEXT_VERSION)/
+DIST_VERSION = $(DIST)-$(NEXT_VERSION)/
+
+HEADLESS_DIST=dist/bitmask-nox
+HEADLESS_DIST_VERSION = $(HEADLESS_DIST)-$(NEXT_VERSION)/
+
+ANONVPN_DIST=dist/anonvpn
+ANONVPN_DIST_VERSION = $(ANONVPN_DIST)-$(NEXT_VERSION)/
BITMASK_ROOT = src/leap/bitmask/vpn/helpers/linux/bitmask-root
POLKIT_POLICY = src/leap/bitmask/vpn/helpers/linux/se.leap.bitmask.policy
diff --git a/pkg/bundles/build.mk b/pkg/bundles/build.mk
index 837b3389..3458354c 100644
--- a/pkg/bundles/build.mk
+++ b/pkg/bundles/build.mk
@@ -140,14 +140,14 @@ bundle_anonvpn:
pyinstaller -y pkg/pyinst/anonvpn.spec
cp src/leap/bitmask/core/bitmaskd.tac $(ANONVPN_DIST)
cp $(VIRTUAL_ENV)/lib/python2.7/site-packages/leap/common/cacert.pem $(ANONVPN_DIST)/
- cho `git describe` > $(ANONVPN_DIST)/version
+ echo `git describe` > $(ANONVPN_DIST)/version
mv $(ANONVPN_DIST) _bundlelib && mkdir $(ANONVPN_DIST_VERSION) && mv _bundlelib $(ANONVPN_DIST_VERSION)lib/
mkdir -p $(ANONVPN_DIST_VERSION)/apps/providers
cp -r src/leap/bitmask/bonafide/providers/* $(ANONVPN_DIST_VERSION)/apps/providers/
-
# openvpn
mkdir -p $(ANONVPN_DIST_VERSION)/apps/vpn
wget https://downloads.leap.se/thirdparty/linux/openvpn/openvpn-x64 -O $(ANONVPN_DIST_VERSION)/apps/vpn/openvpn.leap
+ chmod +x $(ANONVPN_DIST_VERSION)/apps/vpn/openvpn.leap
# helpers
mkdir -p $(ANONVPN_DIST_VERSION)/apps/helpers
cp src/leap/bitmask/vpn/helpers/linux/bitmask-root $(ANONVPN_DIST_VERSION)/apps/helpers/
diff --git a/pkg/docker_build_apt b/pkg/docker_build_apt
index 605bc1be..1d87b4e1 100644
--- a/pkg/docker_build_apt
+++ b/pkg/docker_build_apt
@@ -12,6 +12,13 @@ git clone $REPO bitmaskbuild
cd bitmaskbuild
git checkout $BRANCH
git fetch --tags
+
+pip uninstall --yes leap.bitmask
+pip install -e .
+
mkdir -p dist/
+
VIRTUAL_ENV=/usr/local make bundle_linux
cp -r dist/* /dist
+
+echo "[+] DONE"
diff --git a/pkg/docker_build_riseupvpn b/pkg/docker_build_riseupvpn
index 3463b7b7..9da829cc 100644
--- a/pkg/docker_build_riseupvpn
+++ b/pkg/docker_build_riseupvpn
@@ -8,27 +8,54 @@
# (dependencies should already be in the base image)
export GOPATH=/srv/go
+export CGO_CPPFLAGS="-I/usr/include"
+export CGO_LDFLAGS="-L/usr/lib -L/usr/lib/z86_64-linux-gnu -lzmq -lpthread -lsodium -lrt -lstdc++ -lm -lc -lgcc"
+
+# echo "[+] building systray deps"
+# go get -a 0xacab.org/leap/bitmask-systray
cd /src/leap && git clone --depth 1 --single-branch --branch master https://0xacab.org/leap/bitmask-systray
+echo "[+] building systray"
cd bitmask-systray && go build .
-cd /src/leap/bitmask-dev
cd $HOME
echo "[+] CLONING REPO from $REPO [$BRANCH]"
-git clone $REPO bitmaskbuild
+rm -rf bitmaskbuild
+git clone --depth 1 --single-branch --branch $BRANCH $REPO bitmaskbuild
cd bitmaskbuild
RELEASE=anonvpn-`cat pkg/next-version`
echo "[+] RELEASE: $RELEASE"
-git checkout $BRANCH
git fetch --tags
+# uninstall bitmask-dev from base image and install bitmask-vpn
+pip uninstall --yes leap.bitmask
+pip install -e '.[vpn]'
mkdir -p dist/
-# nuke mail
+# nuke bitmask mail
rm -rf src/leap/bitmask/mail
-# get anonvpn bundle
+# build anonvpn bundle
VIRTUAL_ENV=/usr/local make bundle_anonvpn_linux
-# copy systray binary
-cp /src/leap/bitmask-systray/bitmask-systray dist/anonvpn-${RELEASE}/lib/
-# rename entrypoing
-mv dist/anonvpn-${RELEASE}/bitmask dist/anonvpn-${RELEASE}/riseupvpn
+
+# copy systray binary and libs
+echo "[+] Copy systray binary"
+cp /src/leap/bitmask-systray/bitmask-systray dist/${RELEASE}/lib/
+cp /usr/lib/x86_64-linux-gnu/libsodium.so.18 dist/${RELEASE}/lib/
+cp /usr/lib/x86_64-linux-gnu/libzmq.so.5.1.1 dist/${RELEASE}/lib/libzmq.so.5
+cp /usr/lib/x86_64-linux-gnu/libappindicator3.so.1 dist/${RELEASE}/lib/
+cp /usr/lib/x86_64-linux-gnu/libpng16.so.16 dist/${RELEASE}/lib/libpng.so.16
+cp /usr/lib/x86_64-linux-gnu/libz.so dist/${RELEASE}/lib/libz.so
+
+# trim some bytes
+rm dist/${RELEASE}/lib/pysqlcipher._sqlite.so
+rm dist/${RELEASE}/lib/libzmq-0576c57a.so.5.0.2
+rm dist/${RELEASE}/lib/libsqlite3.so.0
+
+# rename entrypoint
+echo "[+] Build and copy wrapper binary"
+cd $HOME/bitmaskbuild/pkg/launcher && make
+cd $HOME/bitmaskbuild
+cp pkg/launcher/bitmask dist/${RELEASE}/riseupVPN
+mv dist/${RELEASE}/lib/anonvpn dist/${RELEASE}/lib/bitmask
+
cp -r dist/* /dist
+echo "[+] DONE"
diff --git a/pkg/docker_bundleapt/Dockerfile b/pkg/docker_bundleapt/Dockerfile
index 0e79cf3c..810cae81 100644
--- a/pkg/docker_bundleapt/Dockerfile
+++ b/pkg/docker_bundleapt/Dockerfile
@@ -18,7 +18,8 @@ RUN apt install -y --no-install-recommends \
qttranslations5-l10n libgl1-mesa-glx \
libusb-0.1-4 patchelf wget \
gnupg1 git libgl1-mesa-glx \
- libappindicator3-dev libgtk-3-dev golang
+ libappindicator3-dev libgtk-3-dev golang \
+ libsodium-dev
# Pyinstaller custom versions
#ARG PYINSTALLER_TAG=v3.2
@@ -73,4 +74,7 @@ RUN ln -s /usr/lib/python2.7/dist-packages/sipconfig_nd.py /usr/local/lib/python
RUN ln -s /usr/lib/python2.7/dist-packages/sip.pyi /usr/local/lib/python2.7/site-packages/
# get dependencies for bitmask-systray so that builds are quick
-RUN export GOPATH=/srv/go && go get 0xacab.org/leap/bitmask-systray
+RUN export GOPATH=/srv/go && \
+ export CGO_CPPFLAGS="-I/usr/include" && \
+ export CGO_LDFLAGS="-L/usr/lib -L/usr/lib/z86_64-linux-gnu -lzmq -lpthread -lsodium -lrt -lstdc++ -lm -lc -lgcc" && \
+ go get 0xacab.org/leap/bitmask-systray
diff --git a/pkg/docker_bundleapt/Makefile b/pkg/docker_bundleapt/Makefile
index e68a9cf5..f36d2ef1 100644
--- a/pkg/docker_bundleapt/Makefile
+++ b/pkg/docker_bundleapt/Makefile
@@ -10,11 +10,13 @@ login:
docker login 0xacab.org:4567
# for local tests
-
+prune:
+ docker system prune
bundler:
docker build -t $(IMAGE) .
shell:
docker run -i -t $(IMAGE) bash
bundle:
echo "cd /src/leap/bitmask-dev && VIRTUAL_ENV=/usr/local make bundle && cp -r dist/* /dist" | docker run -i -v /srv/bitmask-builds:/dist -w /dist $(IMAGE) bash
-
+systray:
+ cat systray.sh | docker run -i -v /srv/bitmask-builds:/dist -w /dist $(IMAGE) bash
diff --git a/pkg/docker_bundleapt/systray.sh b/pkg/docker_bundleapt/systray.sh
new file mode 100644
index 00000000..4bb19067
--- /dev/null
+++ b/pkg/docker_bundleapt/systray.sh
@@ -0,0 +1,10 @@
+export GOPATH=/srv/go
+export CGO_CPPFLAGS="-I/usr/include"
+export CGO_LDFLAGS="-L/usr/lib -L/usr/lib/z86_64-linux-gnu -lzmq -lpthread -lsodium -lrt -lstdc++ -lm -lc -lgcc"
+
+echo "[+] building systray deps"
+go get -a 0xacab.org/leap/bitmask-systray
+cd /src/leap && git clone --depth 1 --single-branch --branch master https://0xacab.org/leap/bitmask-systray
+echo "[+] building systray"
+cd bitmask-systray && go build .
+cp -r /src/leap/bitmask-systray/bitmask-systray /dist
diff --git a/pkg/launcher/Makefile b/pkg/launcher/Makefile
index 8dd1013d..8948e6b4 100644
--- a/pkg/launcher/Makefile
+++ b/pkg/launcher/Makefile
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS = -g -Wall
+CFLAGS = -g -Wall -fPIE
STRIP = strip
default: bitmask
diff --git a/pkg/launcher/bitmask-launcher.c b/pkg/launcher/bitmask-launcher.c
index cf5c2a18..b9bda1c2 100644
--- a/pkg/launcher/bitmask-launcher.c
+++ b/pkg/launcher/bitmask-launcher.c
@@ -4,20 +4,45 @@
* part of the bitmask bundle.
* execute main entrypoint in a child folder inside the bundle.
*
- * (c) LEAP Encryption Access Project, 2016.
+ * (c) LEAP Encryption Access Project, 2016-2018.
* License: GPL.
*
*/
#include <unistd.h>
#include <stdlib.h>
+#include <libgen.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
-char* const bitmask_path = "lib";
-char* const entrypoint = "bitmask";
+#define MAXBUFFSIZE 1024
+
+char* const lib = "/lib";
+char* const entrypoint = "app";
+char* const linkname = "/proc/self/exe";
int main(int argc, char *argv[])
{
+ char buf[MAXBUFFSIZE];
+ char pth[MAXBUFFSIZE];
+ char *dirc, *dname;
+ const size_t bufsize = MAXBUFFSIZE + 1;
+
argv[0] = entrypoint;
- chdir(bitmask_path);
+ buf[0] = 0;
+ pth[0] = 0;
+
+ readlink(linkname, buf, bufsize - 1);
+
+ dirc = strdup(buf);
+ dname = dirname(dirc);
+ strncat(pth, dname, strlen(dname));
+ strncat(pth, lib, strlen(lib));
+
+ if (chdir(pth) < 0)
+ {
+ fprintf(stderr, "error: %s\n", strerror(errno));
+ }
execv(entrypoint, argv);
}
diff --git a/pkg/pyinst/anonvpn.spec b/pkg/pyinst/anonvpn.spec
index 0748fc09..98624dd4 100644
--- a/pkg/pyinst/anonvpn.spec
+++ b/pkg/pyinst/anonvpn.spec
@@ -19,6 +19,7 @@ hiddenimports = [
'service_identity',
'leap.common', 'leap.bitmask',
'leap.bitmask.core.logs',
+ 'leap.bitmask.gui.housekeeping',
'packaging', 'packaging.version', 'packaging.specifiers',
'packaging.requirements']
diff --git a/src/leap/bitmask/gui/app2.py b/src/leap/bitmask/gui/app2.py
index 151dead5..6a83e1f6 100644
--- a/src/leap/bitmask/gui/app2.py
+++ b/src/leap/bitmask/gui/app2.py
@@ -46,6 +46,7 @@ from leap.bitmask.gui.systray import WithTrayIcon
from leap.bitmask.gui.housekeeping import cleanup, terminate, reset_authtoken
from leap.bitmask.gui.housekeeping import get_authenticated_url
from leap.bitmask.gui.housekeeping import NoAuthTokenError
+from leap.bitmask.gui.housekeeping import check_stale_pidfile
DEBUG = os.environ.get("DEBUG", False)