summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-04-24 18:57:01 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-04-30 22:10:31 +0200
commita14b4ac6507b65d9b2d5e22ff89cf89c689cd936 (patch)
tree7eaecf9f82d703e3da30e9efe3a63a4d56b39368
parent3a9f65fb9ccb32e6ef0e3f3c471cc50f1c3ee505 (diff)
[bug] do not use cross-compiling for the helper in win
- add -H windowsgui to avoid console popping up
-rw-r--r--Makefile9
-rwxr-xr-xbranding/templates/makefile/Makefile3
-rwxr-xr-xbranding/templates/windows/payload/install2
-rwxr-xr-xbranding/templates/windows/payload/uninstall15
-rwxr-xr-xbranding/templates/windows/template.nsi23
-rw-r--r--docker/Makefile4
-rwxr-xr-xdocker/builder.sh12
-rw-r--r--pkg/helper/windows.go2
8 files changed, 47 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 950c6fd..ec642b2 100644
--- a/Makefile
+++ b/Makefile
@@ -57,7 +57,7 @@ dependsCygwin:
@choco install -y golang python nssm nsis wget 7zip
build:
- $(MAKE) _buildparts
+ echo "XBUILD>", ${XBUILD}
ifeq (${XBUILD}, yes)
$(MAKE) build_cross_win
$(MAKE) build_cross_osx
@@ -68,11 +68,14 @@ else ifeq (${XBUILD}, win)
else ifeq (${XBUILD}, osx)
$(MAKE) build_cross_osx
$(MAKE) _build_done
+else
+ $(MAKE) _buildparts
endif
_buildparts: $(foreach path,$(wildcard cmd/*),build_$(patsubst cmd/%,%,$(path)))
build_%:
+ @echo "PLATFORM: ${PLATFORM}"
@mkdir -p build/bin/${PLATFORM}
go build -tags $(TAGS) -ldflags "-s -w -X main.version=`git describe --tags` ${EXTRA_LDFLAGS}" -o build/bin/${PLATFORM}/$* ./cmd/$*
-@rm -rf build/${PROVIDER}/staging/${PLATFORM} && mkdir -p build/${PROVIDER}/staging/${PLATFORM}
@@ -91,7 +94,11 @@ CROSS_WIN_FLAGS = CGO_ENABLED=1 GOARCH=386 GOOS=windows CC="/usr/bin/i686-w64-mi
PLATFORM_WIN = PLATFORM=windows
EXTRA_LDFLAGS_WIN = EXTRA_LDFLAGS="-H windowsgui"
build_cross_win:
+ @echo "[+] Cross-building for windows..."
$(CROSS_WIN_FLAGS) $(PLATFORM_WIN) $(EXTRA_LDFLAGS_WIN) $(MAKE) _buildparts
+ # workaround for helper: we use the go compiler
+ @echo "[+] Compiling helper with the Go compiler to work around missing stdout bug..."
+ cd cmd/bitmask-helper && GOOS=windows GOARCH=386 go build -ldflags "-X main.version=`git describe --tags` -H windowsgui" -o ../../build/bin/windows/bitmask-helper-go
CROSS_OSX_FLAGS = MACOSX_DEPLOYMENT_TARGET=10.10 CGO_ENABLED=1 GOOS=darwin CC="o64-clang"
PLATFORM_OSX = PLATFORM=darwin
diff --git a/branding/templates/makefile/Makefile b/branding/templates/makefile/Makefile
index 859118f..5994e19 100755
--- a/branding/templates/makefile/Makefile
+++ b/branding/templates/makefile/Makefile
@@ -37,7 +37,8 @@ else
pkg_win: staging/openvpn/openvpn.exe
echo "[+] building windows"
cp ../bin/windows/bitmask-vpn staging/bitmask-vpn.exe
- cp ../bin/windows/bitmask-helper staging/bitmask_helper.exe
+ #cp ../bin/windows/bitmask-helper staging/bitmask_helper.exe
+ cp ../bin/windows/bitmask-helper-go staging/helper.exe
makensis windows/$(APPNAME)-installer.nsi
mv dist/$(APPNAME)-$(VERSION).exe ../../deploy/
endif
diff --git a/branding/templates/windows/payload/install b/branding/templates/windows/payload/install
index da9a195..280703a 100755
--- a/branding/templates/windows/payload/install
+++ b/branding/templates/windows/payload/install
@@ -1,4 +1,4 @@
-..\staging\bitmask_helper.exe
+..\staging\helper.exe
..\staging\bitmask-vpn.exe
..\staging\libcrypto-1_1-x64.dll
..\staging\liblzo2-2.dll
diff --git a/branding/templates/windows/payload/uninstall b/branding/templates/windows/payload/uninstall
index f0a1687..bb6cf39 100755
--- a/branding/templates/windows/payload/uninstall
+++ b/branding/templates/windows/payload/uninstall
@@ -1,13 +1,14 @@
icon.ico
-openssl.exe
-openvpn.exe
-ssleay32.dll
-libeay32.dll
-liblzo2-2.dll
-libpkcs11-helper-1.dll
+openssl.exe
+openvpn.exe
+ssleay32.dll
+libeay32.dll
+liblzo2-2.dll
+libpkcs11-helper-1.dll
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
padlock.dll
-bitmask-helper.exe
+bitmask_helper.exe
bitmask-vpn.exe
tap-windows.exe
+helper.exe
diff --git a/branding/templates/windows/template.nsi b/branding/templates/windows/template.nsi
index f6a908d..9c319d0 100755
--- a/branding/templates/windows/template.nsi
+++ b/branding/templates/windows/template.nsi
@@ -61,6 +61,11 @@ Section "InstallFiles"
Delete 'C:\Program Files\$applicationName\bitmask_helper.exe'
IfErrors 0 noErrorHelper
+ DetailPrint "Trying to uninstall new helper..."
+ ClearErrors
+ Delete 'C:\Program Files\$applicationName\helper.exe'
+ IfErrors 0 noErrorHelper
+
; uninstalling old nssm helper - could fail if it isn't there, or if nssm is not there...
ClearErrors
DetailPrint "Trying to uninstall an old style helper..."
@@ -77,6 +82,12 @@ Section "InstallFiles"
IfErrors 0 noErrorHelper
DetailPrint "Failed to stop new-style helper, maybe it was not there"
+ ClearErrors
+ DetailPrint "Trying to uninstall a new style helper..."
+ ExecWait '"$INSTDIR\helper.exe" stop'
+ IfErrors 0 noErrorHelper
+ DetailPrint "Failed to stop new-style helper, maybe it was not there"
+
noErrorHelper:
; now we try to delete the systray, locked by the app - just to know if another instance of FoobarVPN is running.
@@ -120,14 +131,14 @@ SectionEnd
Section "InstallService"
DetailPrint "Trying to uninstall previous versions of the (new) helper..."
ClearErrors
- ExecWait '"$INSTDIR\bitmask_helper.exe" stop'
- ExecWait '"$INSTDIR\bitmask_helper.exe" remove'
+ ExecWait '"$INSTDIR\helper.exe" stop'
+ ExecWait '"$INSTDIR\helper.exe" remove'
IfErrors 0 noError
DetailPrint "Could not uninstall a previous version of the (new) helper!"
noError:
- ExecWait '"$INSTDIR\bitmask_helper.exe" install'
- ExecWait '"$INSTDIR\bitmask_helper.exe" start'
+ ExecWait '"$INSTDIR\helper.exe" install'
+ ExecWait '"$INSTDIR\helper.exe" start'
SectionEnd
Section /o "TAP Virtual Ethernet Adapter" SecTAP
@@ -147,9 +158,11 @@ Section "Uninstall"
ExecWait '"$INSTDIR\bitmask_helper.exe" stop'
ExecWait '"$INSTDIR\bitmask_helper.exe" remove'
+ ExecWait '"$INSTDIR\helper.exe" stop'
+ ExecWait '"$INSTDIR\helper.exe" remove'
+
; now we (try to) remove everything else. kill it with fire!
Delete $INSTDIR\nssm.exe ; probably does not exist anymore, but just in case
- Delete $INSTDIR\bitmask_helper.exe
Delete $INSTDIR\readme.txt
Delete $INSTDIR\helper.log
Delete $INSTDIR\openvpn.log
diff --git a/docker/Makefile b/docker/Makefile
index bdcc2b8..80ca9dd 100644
--- a/docker/Makefile
+++ b/docker/Makefile
@@ -14,10 +14,10 @@ package_win:
docker run \
-e XBUILD=win \
-e PROVIDER=riseup \
- -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.orig \
+ -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.host \
--cpus="4" \
-it --rm \
$(REGISTRY)/$(IMAGE):latest \
/builder.sh
shell:
- docker run -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.orig -it --rm $(REGISTRY)/$(IMAGE):latest /bin/bash
+ docker run -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.host -it --rm $(REGISTRY)/$(IMAGE):latest /bin/bash
diff --git a/docker/builder.sh b/docker/builder.sh
index dad7800..2767d61 100755
--- a/docker/builder.sh
+++ b/docker/builder.sh
@@ -1,9 +1,11 @@
#!/bin/bash
set -e
-export DESTDIR=/bitmask-vpn.orig/deploy/
-rm -rf /bitmask-vpn
-cp -r /bitmask-vpn.orig /bitmask-vpn
-cd /bitmask-vpn
+export HOSTDIR=/bitmask-vpn.host
+export GUESTDIR=/bitmask-vpn
+export DESTDIR="${HOSTDIR}"/deploy/
+rm -rf "${GUESTDIR}"
+cp -r "${HOSTDIR}" "${GUESTDIR}"
+cd "${GUESTDIR}"
make prepare
make build
case $XBUILD in
@@ -17,4 +19,4 @@ case $XBUILD in
make packages
;;
esac
-cp /bitmask-vpn/deploy/* $DESTDIR
+cp "${GUESTDIR}"/deploy/* $DESTDIR
diff --git a/pkg/helper/windows.go b/pkg/helper/windows.go
index 08b01aa..2872702 100644
--- a/pkg/helper/windows.go
+++ b/pkg/helper/windows.go
@@ -30,7 +30,7 @@ import (
)
const (
- svcName = config.BinaryName + `-helper`
+ svcName = config.BinaryName + `-helper-v2`
appPath = `C:\Program Files\` + config.ApplicationName + `\`
LogFolder = appPath
openvpnPath = appPath + `openvpn.exe`