From bf1a69200547ab24ce31861ab4aed211a558d171 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 30 Oct 2020 15:51:22 -0400 Subject: [PATCH 01/44] key manager should throw on failures --- llarp/config/key_manager.cpp | 21 ++++++--------------- llarp/config/key_manager.hpp | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index 9525593721..25020675ae 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -175,32 +175,23 @@ namespace llarp bool KeyManager::loadOrCreateKey( - const fs::path& filepath, + fs::path path, llarp::SecretKey& key, std::function keygen) { - fs::path path(filepath); - std::error_code ec; - if (!fs::exists(path, ec)) + if (not fs::exists(path)) { - if (ec) - { - LogError("Error checking key", filepath, ec.message()); - return false; - } - - LogInfo("Generating new key", filepath); + LogInfo("Generating new key", path); keygen(key); - if (!key.SaveToFile(filepath)) + if (!key.SaveToFile(path)) { LogError("Failed to save new key"); return false; } } - - LogDebug("Loading key from file ", filepath); - return key.LoadFromFile(filepath); + LogDebug("Loading key from file ", path); + return key.LoadFromFile(path); } } // namespace llarp diff --git a/llarp/config/key_manager.hpp b/llarp/config/key_manager.hpp index ca089b1e96..a967ffba3f 100644 --- a/llarp/config/key_manager.hpp +++ b/llarp/config/key_manager.hpp @@ -82,7 +82,7 @@ namespace llarp /// @param keygen is a function that will generate the key if needed static bool loadOrCreateKey( - const fs::path& filepath, + fs::path filepath, llarp::SecretKey& key, std::function keygen); }; From 5233b26552e51688d40849cd30f39147ab050b62 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 30 Oct 2020 15:53:05 -0400 Subject: [PATCH 02/44] format --- llarp/config/key_manager.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index 25020675ae..7827e39166 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -175,9 +175,7 @@ namespace llarp bool KeyManager::loadOrCreateKey( - fs::path path, - llarp::SecretKey& key, - std::function keygen) + fs::path path, llarp::SecretKey& key, std::function keygen) { if (not fs::exists(path)) { From aa4c4e7453066d23690b312a05c3b394162c3db2 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Tue, 10 Nov 2020 20:10:09 -0400 Subject: [PATCH 03/44] Install less stuff on windows CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mingw-w64 is a metapackage that pulls in 4 different compilers {i686,x86_64}×{-posix,-win32} but we only need x86_64-posix, so just install that package. --- .drone.jsonnet | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 80217a54c0..0bfa9df7d4 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -90,7 +90,7 @@ local windows_cross_pipeline(name, image, 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections', apt_get_quiet + ' update', apt_get_quiet + ' install -y eatmydata', - 'eatmydata ' + apt_get_quiet + ' install -y build-essential cmake git ninja-build pkg-config ccache mingw-w64 nsis zip', + 'eatmydata ' + apt_get_quiet + ' install -y build-essential cmake git ninja-build pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip', 'update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix', 'update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix', 'git clone https://github.com/despair86/libuv.git win32-setup/libuv', @@ -215,8 +215,8 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra debian_pipeline("Debian sid (ARM64)", "debian:sid", arch="arm64"), debian_pipeline("Debian buster (armhf)", "arm32v7/debian:buster", arch="arm64", cmake_extra='-DDOWNLOAD_SODIUM=ON'), - // Windows builds (WOW64 and native) - windows_cross_pipeline("win32 (amd64)", "debian:testing", + // Windows builds (x64) + windows_cross_pipeline("Windows (amd64)", "debian:testing", toolchain='64', extra_cmds=[ '../contrib/ci/drone-static-upload.sh' ]), From b5bbe1747966547f808e6d4ea3dce63a76f63740 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 11 Nov 2020 10:10:12 -0400 Subject: [PATCH 04/44] Update gui win32 package url (#1466) (#1468) Co-authored-by: Jeff --- cmake/win32_installer_deps.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/win32_installer_deps.cmake b/cmake/win32_installer_deps.cmake index 03cfd6d7eb..fa0a0453b4 100644 --- a/cmake/win32_installer_deps.cmake +++ b/cmake/win32_installer_deps.cmake @@ -1,5 +1,5 @@ -set(GUI_ZIP_URL "https://builds.lokinet.dev/loki-project/loki-network-control-panel/master/lokinet-gui-windows-32bit-20201106T142720Z-b92e5fd10.zip") -set(GUI_ZIP_HASH SHA256=52868f7bf6d1f4fc7ca587cc79449fefd8000a485bb7917acbc29fdefdd55839) +set(GUI_ZIP_URL "https://builds.lokinet.dev/loki-project/loki-network-control-panel/master/lokinet-gui-windows-32bit-v0.3.2.zip") +set(GUI_ZIP_HASH SHA256=136595c287f0664e02a7c62a88fd69299510545b0f25c028dba0142f62b8e189) set(TUNTAP_URL "https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe") set(TUNTAP_EXE "${CMAKE_BINARY_DIR}/tuntap-install.exe") set(BOOTSTRAP_URL "https://seed.lokinet.org/lokinet.signed") From f18f18372a28fbf7bc4740c2994cdf6c42c3b1d3 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 11 Nov 2020 09:55:00 -0500 Subject: [PATCH 05/44] stop lokinet before uninstalling service (#1469) * stop lokinet before uninstalling service * kill gui in uninstaller * add helper script for building windows installers because i forgot how to most of the time. --- cmake/win32_installer_deps.cmake | 2 +- contrib/windows.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 contrib/windows.sh diff --git a/cmake/win32_installer_deps.cmake b/cmake/win32_installer_deps.cmake index fa0a0453b4..ae366bffd4 100644 --- a/cmake/win32_installer_deps.cmake +++ b/cmake/win32_installer_deps.cmake @@ -29,7 +29,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Lokinet") set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/win32-setup/lokinet.ico") set(CPACK_NSIS_DEFINES "RequestExecutionLevel admin") set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '$INSTDIR\\\\bin\\\\tuntap-install.exe /S'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --install'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe -g C:\\\\ProgramData\\\\lokinet\\\\lokinet.ini'\\nCopyFiles '$INSTDIR\\\\share\\\\bootstrap.signed' C:\\\\ProgramData\\\\lokinet\\\\bootstrap.signed") -set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "ExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --remove'\\nRMDir /r /REBOOTOK C:\\\\ProgramData\\\\lokinet") +set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "ExecWait 'net stop lokinet'\\nExecWait 'taskkill /f /t /im lokinet-gui.exe'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --remove'\\nRMDir /r /REBOOTOK C:\\\\ProgramData\\\\lokinet") set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Lokinet.lnk' '$INSTDIR\\\\share\\\\gui\\\\lokinet-gui.exe'" ) diff --git a/contrib/windows.sh b/contrib/windows.sh new file mode 100755 index 0000000000..5215e44200 --- /dev/null +++ b/contrib/windows.sh @@ -0,0 +1,5 @@ +#!/bin/bash +mkdir -p build-windows +cd build-windows +cmake -G Ninja -DCMAKE_CROSSCOMPILE=ON -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DLIBUV_ROOT=$PWD/../external/libuv -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw64.cmake -DBUILD_STATIC_DEPS=ON -DBUILD_PACKAGE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DWITH_TESTS=OFF -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON -DWITH_SYSTEMD=OFF -DFORCE_LOKIMQ_SUBMODULE=ON -DSUBMODULE_CHECK=OFF -DWITH_LTO=OFF .. +ninja package From bcdb521974266fa69350cf996c66f1284b0c8a45 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 11 Nov 2020 19:39:31 -0400 Subject: [PATCH 06/44] Update win32 gui download with smaller svg icon --- cmake/win32_installer_deps.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/win32_installer_deps.cmake b/cmake/win32_installer_deps.cmake index ae366bffd4..17c7376555 100644 --- a/cmake/win32_installer_deps.cmake +++ b/cmake/win32_installer_deps.cmake @@ -1,5 +1,5 @@ -set(GUI_ZIP_URL "https://builds.lokinet.dev/loki-project/loki-network-control-panel/master/lokinet-gui-windows-32bit-v0.3.2.zip") -set(GUI_ZIP_HASH SHA256=136595c287f0664e02a7c62a88fd69299510545b0f25c028dba0142f62b8e189) +set(GUI_ZIP_URL "https://builds.lokinet.dev/loki-project/loki-network-control-panel/master/lokinet-gui-windows-32bit-v0.3.3.zip") +set(GUI_ZIP_HASH SHA256=4a7be3e8d93b891959c896e050ff9e3beba2e82003419cb199fdacd53937a5cb) set(TUNTAP_URL "https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe") set(TUNTAP_EXE "${CMAKE_BINARY_DIR}/tuntap-install.exe") set(BOOTSTRAP_URL "https://seed.lokinet.org/lokinet.signed") From 8e550091abc111478755618747a5350a5a4d945c Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Fri, 13 Nov 2020 10:00:04 -0400 Subject: [PATCH 07/44] Disable LTO on sid for now (#1472) --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 0bfa9df7d4..5c3dadf741 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -203,7 +203,7 @@ local mac_builder(name, build_type='Release', werror=true, cmake_extra='', extra // Various debian builds debian_pipeline("Debian sid (amd64)", "debian:sid"), - debian_pipeline("Debian sid/Debug (amd64)", "debian:sid", build_type='Debug', lto=true), + debian_pipeline("Debian sid/Debug (amd64)", "debian:sid", build_type='Debug'), debian_pipeline("Debian sid/clang-11 (amd64)", "debian:sid", deps='clang-11 '+default_deps_nocxx, cmake_extra='-DCMAKE_C_COMPILER=clang-11 -DCMAKE_CXX_COMPILER=clang++-11 '), debian_pipeline("Debian buster (i386)", "i386/debian:buster", cmake_extra='-DDOWNLOAD_SODIUM=ON'), From dad66c50cb2b81825f14466f6712595903d9a8f6 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 16 Nov 2020 12:16:38 -0500 Subject: [PATCH 08/44] poke route hole for loopback on windows because that OS is made by brain damaged non programmers. (#1473) this fixes the gui bug where it hangs on adding an exit becuase loopback gets routed over the exit. before it was causing the lmq connection to hang becuase of that route change. --- llarp/net/route.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llarp/net/route.cpp b/llarp/net/route.cpp index cb681ad388..56366e7968 100644 --- a/llarp/net/route.cpp +++ b/llarp/net/route.cpp @@ -369,6 +369,8 @@ namespace llarp::net do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, default_gw, if_idx); #endif #elif _WIN32 + // poke hole for loopback bacause god is dead on windows + Execute(RouteCommand() + " ADD 127.0.0.0 MASK 255.0.0.0 0.0.0.0"); ifname.back()++; Execute(RouteCommand() + " ADD 0.0.0.0 MASK 128.0.0.0 " + ifname); Execute(RouteCommand() + " ADD 128.0.0.0 MASK 128.0.0.0 " + ifname); @@ -404,6 +406,7 @@ namespace llarp::net ifname.back()++; Execute(RouteCommand() + " DELETE 0.0.0.0 MASK 128.0.0.0 " + ifname); Execute(RouteCommand() + " DELETE 128.0.0.0 MASK 128.0.0.0 " + ifname); + Execute(RouteCommand() + " DELETE 127.0.0.0 MASK 255.0.0.0 0.0.0.0"); #elif __APPLE__ Execute("/sbin/route -n delete -cloning -net 0.0.0.0 -netmask 128.0.0.0 -interface " + ifname); Execute( From db7abe8f0928df8982650f2d865ff88b29a02989 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 16 Nov 2020 13:33:45 -0500 Subject: [PATCH 09/44] do /1 route poker split on linux (#1480) * do /1 route poker split on linux i hate netlink so god damn much * use an enum class for the gateway mode --- llarp/net/route.cpp | 56 +++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/llarp/net/route.cpp b/llarp/net/route.cpp index 56366e7968..ba7b301b1c 100644 --- a/llarp/net/route.cpp +++ b/llarp/net/route.cpp @@ -82,6 +82,14 @@ namespace llarp::net #ifdef __linux__ #ifndef ANDROID + + enum class GatewayMode + { + eFirstHop, + eLowerDefault, + eUpperDefault + }; + struct NLSocket { NLSocket() : fd(socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) @@ -139,7 +147,14 @@ namespace llarp::net } int - do_route(int sock, int cmd, int flags, _inet_addr* dst, _inet_addr* gw, int def_gw, int if_idx) + do_route( + int sock, + int cmd, + int flags, + const _inet_addr* dst, + const _inet_addr* gw, + GatewayMode mode, + int if_idx) { struct { @@ -187,27 +202,27 @@ namespace llarp::net if (gw->bitlen != 0) { rtattr_add(&nl_request.n, sizeof(nl_request), RTA_GATEWAY, &gw->data, gw->bitlen / 8); - nl_request.r.rtm_scope = 0; - nl_request.r.rtm_family = gw->family; } - - /* Don't set destination and interface in case of default gateways */ - if (!def_gw) + nl_request.r.rtm_scope = 0; + nl_request.r.rtm_family = gw->family; + if (mode == GatewayMode::eFirstHop) { - /* Set destination network */ rtattr_add( &nl_request.n, sizeof(nl_request), /*RTA_NEWDST*/ RTA_DST, &dst->data, dst->bitlen / 8); - /* Set interface */ rtattr_add(&nl_request.n, sizeof(nl_request), RTA_OIF, &if_idx, sizeof(int)); } - + if (mode == GatewayMode::eUpperDefault) + { + rtattr_add( + &nl_request.n, sizeof(nl_request), /*RTA_NEWDST*/ RTA_DST, &dst->data, sizeof(uint32_t)); + } /* Send message to the netlink */ return send(sock, &nl_request, sizeof(nl_request), 0); } int - read_addr(const char* addr, _inet_addr* res) + read_addr(const char* addr, _inet_addr* res, int bitlen = 32) { if (strchr(addr, ':')) { @@ -217,7 +232,7 @@ namespace llarp::net else { res->family = AF_INET; - res->bitlen = 32; + res->bitlen = bitlen; } return inet_pton(res->family, addr, res->data); } @@ -295,7 +310,6 @@ namespace llarp::net #ifdef __linux__ #ifndef ANDROID NLSocket sock; - int default_gw = 0; int if_idx = 0; _inet_addr to_addr{}; _inet_addr gw_addr{}; @@ -303,7 +317,7 @@ namespace llarp::net int nl_flags = NLM_F_CREATE | NLM_F_EXCL; read_addr(gateway.c_str(), &gw_addr); read_addr(ip.c_str(), &to_addr); - do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, default_gw, if_idx); + do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, GatewayMode::eFirstHop, if_idx); #endif #else std::stringstream ss; @@ -325,7 +339,6 @@ namespace llarp::net #ifdef __linux__ #ifndef ANDROID NLSocket sock; - int default_gw = 0; int if_idx = 0; _inet_addr to_addr{}; _inet_addr gw_addr{}; @@ -333,7 +346,7 @@ namespace llarp::net int nl_flags = 0; read_addr(gateway.c_str(), &gw_addr); read_addr(ip.c_str(), &to_addr); - do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, default_gw, if_idx); + do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, GatewayMode::eFirstHop, if_idx); #endif #else std::stringstream ss; @@ -355,18 +368,19 @@ namespace llarp::net #ifdef __linux__ #ifndef ANDROID NLSocket sock; - int default_gw = 1; int if_idx = if_nametoindex(ifname.c_str()); _inet_addr to_addr{}; _inet_addr gw_addr{}; - const auto maybe = GetIFAddr(ifname); if (not maybe.has_value()) throw std::runtime_error("we dont have our own net interface?"); int nl_cmd = RTM_NEWROUTE; int nl_flags = NLM_F_CREATE | NLM_F_EXCL; read_addr(maybe->toHost().c_str(), &gw_addr); - do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, default_gw, if_idx); + read_addr("0.0.0.0", &to_addr, 1); + do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, GatewayMode::eLowerDefault, if_idx); + read_addr("128.0.0.0", &to_addr, 1); + do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, GatewayMode::eUpperDefault, if_idx); #endif #elif _WIN32 // poke hole for loopback bacause god is dead on windows @@ -389,7 +403,6 @@ namespace llarp::net #ifdef __linux__ #ifndef ANDROID NLSocket sock; - int default_gw = 1; int if_idx = if_nametoindex(ifname.c_str()); _inet_addr to_addr{}; _inet_addr gw_addr{}; @@ -400,7 +413,10 @@ namespace llarp::net int nl_cmd = RTM_DELROUTE; int nl_flags = 0; read_addr(maybe->toHost().c_str(), &gw_addr); - do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, default_gw, if_idx); + read_addr("0.0.0.0", &to_addr, 1); + do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, GatewayMode::eLowerDefault, if_idx); + read_addr("128.0.0.0", &to_addr, 1); + do_route(sock.fd, nl_cmd, nl_flags, &to_addr, &gw_addr, GatewayMode::eUpperDefault, if_idx); #endif #elif _WIN32 ifname.back()++; From 27c276ae4dafd897886534f527160bac92931308 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 17 Nov 2020 05:04:27 -0500 Subject: [PATCH 10/44] fix install path for liblokinet-cryptography.so --- crypto/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 0500aa9edb..bbadc09f04 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -59,7 +59,7 @@ enable_lto(lokinet-cryptography) add_log_tag(lokinet-cryptography) if(BUILD_SHARED_LIBS) - install(TARGETS lokinet-cryptography LIBRARY DESTINATION lib) + install(TARGETS lokinet-cryptography LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if (WARNINGS_AS_ERRORS) From 0afe9f0138f49ee0f4a4e025280790a8638dab97 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 13 Nov 2020 10:18:51 -0500 Subject: [PATCH 11/44] update packaging for macos add preinstall script that nukes any existing lokinet make uninstaller revert dns to "empty" make cpack use preinstall script in pkg file --- cmake/macos_installer_deps.cmake | 1 + contrib/macos/lokinet_uninstall.sh | 44 ++++++++++++++++++++++++---- contrib/macos/preinstall | 46 ++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 contrib/macos/preinstall diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index 217433d5d8..8b343f0a4d 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -58,6 +58,7 @@ set(CPACK_COMPONENT_GUI_DESCRIPTION "Small GUI which provides stats and limited set(CPACK_GENERATOR "productbuild") set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/lokinet") +set(CPACK_PREFLIGHT_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/preinstall) set(CPACK_POSTFLIGHT_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/postinstall) set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index 68029fa201..b7399390d4 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -1,10 +1,44 @@ #!/bin/sh -touch /var/lib/lokinet/suspend-launchd-service # Prevent restarting on exit -killall lokinet -sleep 5 # Give it some time to shut down before we bring launchd into this -launchctl stop network.loki.lokinet.daemon -launchctl unload /Library/LaunchDaemons/network.loki.lokinet.daemon.plist +# this is for dns tomfoolery +scutil_query() +{ + key=$1 + + scutil< Date: Fri, 13 Nov 2020 11:26:59 -0500 Subject: [PATCH 12/44] preflight -> preinstall --- cmake/macos_installer_deps.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index 8b343f0a4d..7dd6de2843 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -58,7 +58,7 @@ set(CPACK_COMPONENT_GUI_DESCRIPTION "Small GUI which provides stats and limited set(CPACK_GENERATOR "productbuild") set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/lokinet") -set(CPACK_PREFLIGHT_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/preinstall) +set(CPACK_PREINSTALL_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/preinstall) set(CPACK_POSTFLIGHT_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/postinstall) set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") From 3b3374fa4ca1b8f6e247b3776642f44b56029ae4 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 13 Nov 2020 13:08:25 -0500 Subject: [PATCH 13/44] try watching trash for lokinet-gui.app and delete ourself if we see it --- .../macos/network.loki.lokinet.daemon.plist | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/contrib/macos/network.loki.lokinet.daemon.plist b/contrib/macos/network.loki.lokinet.daemon.plist index 81aa721f40..8178c19a3e 100644 --- a/contrib/macos/network.loki.lokinet.daemon.plist +++ b/contrib/macos/network.loki.lokinet.daemon.plist @@ -20,11 +20,20 @@ - StandardOutPath - /var/lib/lokinet/stdout + + WatchPaths + + ~/.Trash/LokinetGUI.app + + ProgramArguments + + /opt/lokinet/bin/lokinet_uninstall.sh + - StandardErrorPath - /var/lib/lokinet/stderr - + StandardOutPath + /var/lib/lokinet/stdout + + StandardErrorPath + /var/lib/lokinet/stderr From 580f005f506321da8cef2d2d4062c51a88f16545 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 13 Nov 2020 13:17:27 -0500 Subject: [PATCH 14/44] revert --- contrib/macos/network.loki.lokinet.daemon.plist | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/contrib/macos/network.loki.lokinet.daemon.plist b/contrib/macos/network.loki.lokinet.daemon.plist index 8178c19a3e..974cad1702 100644 --- a/contrib/macos/network.loki.lokinet.daemon.plist +++ b/contrib/macos/network.loki.lokinet.daemon.plist @@ -20,16 +20,6 @@ - - WatchPaths - - ~/.Trash/LokinetGUI.app - - ProgramArguments - - /opt/lokinet/bin/lokinet_uninstall.sh - - StandardOutPath /var/lib/lokinet/stdout From ca5df6436a530fb59351cb8144e9cb69d8a2bb75 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 07:57:03 -0500 Subject: [PATCH 15/44] add initial uninstaller code that is horrible --- cmake/macos_installer_deps.cmake | 25 ++++++-- contrib/macos/uninstaller/CMakeLists.txt | 78 ++++++++++++++++++++++++ contrib/macos/uninstaller/icon.svg | 1 + contrib/macos/uninstaller/main.cpp | 43 +++++++++++++ contrib/macos/uninstaller/mk-icns.sh | 20 ++++++ 5 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 contrib/macos/uninstaller/CMakeLists.txt create mode 100644 contrib/macos/uninstaller/icon.svg create mode 100644 contrib/macos/uninstaller/main.cpp create mode 100644 contrib/macos/uninstaller/mk-icns.sh diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index 7dd6de2843..b0aca10ee4 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -20,6 +20,14 @@ set(MACOS_NOTARIZE_ASC "" include(ExternalProject) +message(STATUS "Building UninstallLokinet.app") + +ExternalProject_Add(lokinet-uninstaller + SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/macos/uninstaller + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} +) + message(STATUS "Building LokinetGUI.app from ${LOKINET_GUI_REPO} @ ${LOKINET_GUI_CHECKOUT}") ExternalProject_Add(lokinet-gui @@ -27,9 +35,7 @@ ExternalProject_Add(lokinet-gui GIT_TAG "${LOKINET_GUI_CHECKOUT}" CMAKE_ARGS -DMACOS_APP=ON -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF - ) - - + ) install(PROGRAMS ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_uninstall.sh DESTINATION "bin/" @@ -42,11 +48,18 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app PATTERN "*" ) +install(DIRECTORY ${PROJECT_BINARY_DIR}/UninstallLokinet.app + DESTINATION "../../Applications" + USE_SOURCE_PERMISSIONS + COMPONENT lokinet + PATTERN "*" + ) + # copy files that will be later moved by the postinstall script to proper locations install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh - ${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist - DESTINATION "extra/" - COMPONENT lokinet) + ${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist + DESTINATION "extra/" + COMPONENT lokinet) set(CPACK_COMPONENTS_ALL lokinet gui) diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt new file mode 100644 index 0000000000..d0b3639f61 --- /dev/null +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -0,0 +1,78 @@ +cmake_minimum_required(VERSION 3.10) # bionic's cmake version + +# Has to be set before `project()`, and ignored on non-macos: +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)") + +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + foreach(lang C CXX) + if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/ccache") + message(STATUS "Enabling ccache for ${lang}") + set(CMAKE_${lang}_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "") + endif() + endforeach() +endif() + +set(PROJECT_NAME lokinet-uninstaller) +project(${PROJECT_NAME} + VERSION 0.0.1 + DESCRIPTION "lokinet uninstaller for macos" + LANGUAGES CXX) + +add_executable(${PROJECT_NAME} + main.cpp) + +find_package(Qt5 COMPONENTS Widgets REQUIRED) + +target_link_libraries(${PROJECT_NAME} PRIVATE + "-framework Security" + Qt5::Core Qt5::Widgets) + +set_target_properties(${PROJECT_NAME} + PROPERTIES + CXX_STANDARD 17 + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON + ) + + +set(MACOS_SIGN "" + CACHE STRING "enable codesigning -- use a 'Apple Distribution' key (or key description) from `security find-identity -v`") + +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lokinet-uninstall.icns + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mk-icns.sh ${CMAKE_CURRENT_SOURCE_DIR}/icon.svg ${CMAKE_CURRENT_BINARY_DIR}/lokinet-uninstall.icns + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/icon.svg ${CMAKE_CURRENT_SOURCE_DIR}/mk-icns.sh) + +target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/lokinet-uninstall.icns) + +set_target_properties(${PROJECT_NAME} + PROPERTIES + MACOSX_BUNDLE TRUE + OUTPUT_NAME UninstallLokinet + RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/lokinet-gui.icns") + +set(MACOSX_BUNDLE_BUNDLE_NAME UninstallLokinet) +set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lokinet.lokinet-uninstaller) +set(MACOSX_BUNDLE_INFO_STRING "Lokinet uninstaller") +set(MACOSX_BUNDLE_ICON_FILE lokinet-uninstall.icns) +set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}) +set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) +set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) +set(MACOSX_BUNDLE_COPYRIGHT "© 2020, The Loki Project") + +if(MACOS_SIGN) + add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND echo "Running qt magic macos deploy script" + COMMAND "${qt_dir}/macdeployqt" UninstallLokinet.app -always-overwrite + COMMAND echo "Signing app bundle and everything inside it" + COMMAND codesign -s "${MACOS_SIGN}" --deep --strict --options runtime + --entitlements ${PROJECT_SOURCE_DIR}/lokinet-uninstaller-entitlements.plist --force -vvv UninstallLokinet.app + ) +else() + add_custom_command(TARGET lokinet-gui + POST_BUILD + COMMAND echo "Running qt magic macos deploy script" + COMMAND "${qt_dir}/macdeployqt" UninstallLokinet.app -always-overwrite + ) +endif() diff --git a/contrib/macos/uninstaller/icon.svg b/contrib/macos/uninstaller/icon.svg new file mode 100644 index 0000000000..a7a571aa68 --- /dev/null +++ b/contrib/macos/uninstaller/icon.svg @@ -0,0 +1 @@ +image/svg+xml diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp new file mode 100644 index 0000000000..b1a8d86ed6 --- /dev/null +++ b/contrib/macos/uninstaller/main.cpp @@ -0,0 +1,43 @@ + +#include +#include +#include + +int uninstall(); + +int main(int argc, char * argv[]) +{ + QApplication app{argc, argv}; + if(QMessageBox::question(nullptr, "Lokinet Uninstaller", "Do You want to uninstall Lokinet?", + QMessageBox::Yes|QMessageBox::No) + == QMessageBox::Yes) + { + QMessageBox msgBox; + const auto retcode = uninstall(); + if(retcode == 0) + { + msgBox.setText("Lokinet has been successfully uninstalled, you may now remove the uninstaller if you wish."); + } + else + { + msgBox.setText("Failed to uninstall lokinet: error code ("+std::to_string(retcode)+")"); + } + msgBox.exec(); + } + return 0; +} + +int uninstall() +{ + AuthorizationRef authorizationRef; + OSStatus status; + + status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef); + + char* tool = "/bin/bash"; + char* args[] = { "-c" , "/opt/lokinet/bin/lokinet_uninstall.sh", nullptr}; + FILE* pipe = NULL; + + return AuthorizationExecuteWithPrivileges(authorizationRef, tool, AuthorizationFlagDefaults, args, &pipe); +} + diff --git a/contrib/macos/uninstaller/mk-icns.sh b/contrib/macos/uninstaller/mk-icns.sh new file mode 100644 index 0000000000..8ba62be492 --- /dev/null +++ b/contrib/macos/uninstaller/mk-icns.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Invoked from cmake as mk-icns.sh /path/to/icon.svg /path/to/output.icns +svg="$1" +out="$2" +outdir="${out/%.icns/.iconset}" + +set -e + +mkdir -p "${outdir}" +for size in 16 32 64 128 256 512 1024; do + convert -background none -resize "${size}x${size}" "$svg" -strip "png32:${outdir}/icon_${size}x${size}.png" +done +mv "${outdir}/icon_1024x1024.png" "${outdir}/icon_512x512@2x.png" +for size in 16 32 128 256; do + double=$((size * 2)) + cp "${outdir}/icon_${double}x${double}.png" "${outdir}/icon_${size}x${size}@2x.png" +done + +iconutil -c icns "${outdir}" From e183bf9673996038ea46e6d91078c2496b89782f Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 07:58:44 -0500 Subject: [PATCH 16/44] fix typo --- contrib/macos/uninstaller/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index d0b3639f61..93a8423933 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -70,7 +70,7 @@ if(MACOS_SIGN) --entitlements ${PROJECT_SOURCE_DIR}/lokinet-uninstaller-entitlements.plist --force -vvv UninstallLokinet.app ) else() - add_custom_command(TARGET lokinet-gui + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND echo "Running qt magic macos deploy script" COMMAND "${qt_dir}/macdeployqt" UninstallLokinet.app -always-overwrite From e835ad63472ea19ede56ede965e0ad3979ff9cb4 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 07:59:21 -0500 Subject: [PATCH 17/44] chmod +x --- contrib/macos/uninstaller/mk-icns.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 contrib/macos/uninstaller/mk-icns.sh diff --git a/contrib/macos/uninstaller/mk-icns.sh b/contrib/macos/uninstaller/mk-icns.sh old mode 100644 new mode 100755 From 6e6bff5e1de6eb4a796b1af70767939f35d176ee Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 08:00:08 -0500 Subject: [PATCH 18/44] fix header --- contrib/macos/uninstaller/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp index b1a8d86ed6..b86d82f8db 100644 --- a/contrib/macos/uninstaller/main.cpp +++ b/contrib/macos/uninstaller/main.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include int uninstall(); From ee3489744e08d0bb9e3a1ff1b5ddd49d33468379 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 08:07:25 -0500 Subject: [PATCH 19/44] more fixes for macos --- contrib/macos/uninstaller/CMakeLists.txt | 3 +++ contrib/macos/uninstaller/main.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index 93a8423933..f2935b41a0 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -60,6 +60,9 @@ set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) set(MACOSX_BUNDLE_COPYRIGHT "© 2020, The Loki Project") +get_target_property(uic_location Qt5::uic IMPORTED_LOCATION) +get_filename_component(qt_dir ${uic_location} DIRECTORY) + if(MACOS_SIGN) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp index b86d82f8db..fe1829c381 100644 --- a/contrib/macos/uninstaller/main.cpp +++ b/contrib/macos/uninstaller/main.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include int uninstall(); @@ -20,7 +20,7 @@ int main(int argc, char * argv[]) } else { - msgBox.setText("Failed to uninstall lokinet: error code ("+std::to_string(retcode)+")"); + msgBox.setText("Failed to uninstall lokinet"); } msgBox.exec(); } @@ -38,6 +38,6 @@ int uninstall() char* args[] = { "-c" , "/opt/lokinet/bin/lokinet_uninstall.sh", nullptr}; FILE* pipe = NULL; - return AuthorizationExecuteWithPrivileges(authorizationRef, tool, AuthorizationFlagDefaults, args, &pipe); + return AuthorizationExecuteWithPrivileges(authorizationRef, tool, kAuthorizationFlagDefaults, args, &pipe); } From d268ef12466b221c28dbc1286e6ae8f93baefac1 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 08:08:08 -0500 Subject: [PATCH 20/44] security.h --- contrib/macos/uninstaller/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp index fe1829c381..b1a5fa9b6a 100644 --- a/contrib/macos/uninstaller/main.cpp +++ b/contrib/macos/uninstaller/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include int uninstall(); From bb1f9c4dc0f1a7659c3d0f98a9454225728cfccc Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 08:08:33 -0500 Subject: [PATCH 21/44] ugh --- contrib/macos/uninstaller/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp index b1a5fa9b6a..0096f23a80 100644 --- a/contrib/macos/uninstaller/main.cpp +++ b/contrib/macos/uninstaller/main.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include int uninstall(); From d2a68f832325c1ee75b7324780e83774957062b1 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 08:10:40 -0500 Subject: [PATCH 22/44] add install target --- contrib/macos/uninstaller/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index f2935b41a0..bc0cccdf71 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -79,3 +79,8 @@ else() COMMAND "${qt_dir}/macdeployqt" UninstallLokinet.app -always-overwrite ) endif() + +install(TARGETS lokinet-uninstaller + RUNTIME DESTINATION bin + BUNDLE DESTINATION . + RESOURCE DESTINATION .) From 36fa3f347a6b98c4994f4c419f2b02b0b0aae3bb Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 08:11:45 -0500 Subject: [PATCH 23/44] fix icon path --- contrib/macos/uninstaller/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index bc0cccdf71..58b0009101 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -49,7 +49,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE OUTPUT_NAME UninstallLokinet - RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/lokinet-gui.icns") + RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/lokinet-uninstall.icns") set(MACOSX_BUNDLE_BUNDLE_NAME UninstallLokinet) set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lokinet.lokinet-uninstaller) From 4d089db3cd6d3fa18eb1ed1f2ca1cfb7fc004d94 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 09:19:17 -0500 Subject: [PATCH 24/44] change tool name --- contrib/macos/uninstaller/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp index 0096f23a80..a069a7f05f 100644 --- a/contrib/macos/uninstaller/main.cpp +++ b/contrib/macos/uninstaller/main.cpp @@ -35,8 +35,8 @@ int uninstall() status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef); - char* tool = "/bin/bash"; - char* args[] = { "-c" , "/opt/lokinet/bin/lokinet_uninstall.sh", nullptr}; + char* tool = "/opt/lokinet/bin/lokinet_uninstall.sh"; + char* args[] = {nullptr}; FILE* pipe = NULL; return AuthorizationExecuteWithPrivileges(authorizationRef, tool, kAuthorizationFlagDefaults, args, &pipe); From 3a950aa9507ad48213172fed4a6e043ee5468dae Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 09:28:36 -0500 Subject: [PATCH 25/44] change icon --- contrib/macos/uninstaller/icon.svg | 214 ++++++++++++++++++++++++++++- 1 file changed, 213 insertions(+), 1 deletion(-) diff --git a/contrib/macos/uninstaller/icon.svg b/contrib/macos/uninstaller/icon.svg index a7a571aa68..df16c62822 100644 --- a/contrib/macos/uninstaller/icon.svg +++ b/contrib/macos/uninstaller/icon.svg @@ -1 +1,213 @@ -image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Stop Process + December 2006 + + + Jakub Steiner + + + + + Andreas Nilsson + + + + + + stop + halt + + + + + + + + + + + + + + + + + + + + + + + From f3989c0f9a2d21e77c5dae426ff73e433dfc9090 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 12:12:47 -0500 Subject: [PATCH 26/44] add entitlements --- .gitignore | 1 - .../uninstaller/lokinet-uninstaller-entitlements.plist | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist diff --git a/.gitignore b/.gitignore index afba6f0330..b688b6ad38 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ *.a *.o -*.plist *.so build/ diff --git a/contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist b/contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist new file mode 100644 index 0000000000..c318596233 --- /dev/null +++ b/contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist @@ -0,0 +1,10 @@ + + + + + + com.apple.security.cs.disable-library-validation + + + From c4e983da3fbeb015a7a8a1106dd9ec144e293910 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 13:17:36 -0500 Subject: [PATCH 27/44] update icon --- contrib/macos/uninstaller/icon.svg | 237 +++-------------------------- 1 file changed, 25 insertions(+), 212 deletions(-) diff --git a/contrib/macos/uninstaller/icon.svg b/contrib/macos/uninstaller/icon.svg index df16c62822..096d925a47 100644 --- a/contrib/macos/uninstaller/icon.svg +++ b/contrib/macos/uninstaller/icon.svg @@ -1,213 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Stop Process - December 2006 - - - Jakub Steiner - - - - - Andreas Nilsson - - - - - - stop - halt - - - - - - - - - - - - - - - - - - - - - - + + + + + + image/svg+xml + + lokinet icon + + + + + + + lokinet icon + + + + + + + + + + From 42b979b26637df1408ee51749f26d1d20a0bceef Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 13:18:45 -0500 Subject: [PATCH 28/44] remove line from uninstaller --- contrib/macos/lokinet_uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index b7399390d4..36f30b90b6 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -41,7 +41,7 @@ killall -9 lokinet || true ) rm -rf /Library/LaunchDaemons/network.loki.lokinet.daemon.plist -rm -rf /Applications/LokinetGUI.app +rm -rf /Applications/Lokinet/LokinetGUI.app rm -rf /var/lib/lokinet rm -rf /usr/local/lokinet/ rm -rf /opt/lokinet From bacb95962f83e5952549ca002c99bba15c169460 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 15:34:03 -0500 Subject: [PATCH 29/44] try installing to lokinet subdirectory --- cmake/macos_installer_deps.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index b0aca10ee4..6aba28a6e0 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -42,16 +42,16 @@ install(PROGRAMS ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_uninstall.sh COMPONENT lokinet) install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app - DESTINATION "../../Applications" + DESTINATION "../../Applications/Lokinet" USE_SOURCE_PERMISSIONS COMPONENT gui PATTERN "*" ) install(DIRECTORY ${PROJECT_BINARY_DIR}/UninstallLokinet.app - DESTINATION "../../Applications" + DESTINATION "../../Applications/Lokinet" USE_SOURCE_PERMISSIONS - COMPONENT lokinet + COMPONENT gui PATTERN "*" ) From b8a1c69a3eb559b695c7e2e849e3ccd9af8e84c2 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 15:38:07 -0500 Subject: [PATCH 30/44] remove old path too --- contrib/macos/lokinet_uninstall.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index 36f30b90b6..801ecb67da 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -42,6 +42,7 @@ killall -9 lokinet || true rm -rf /Library/LaunchDaemons/network.loki.lokinet.daemon.plist rm -rf /Applications/Lokinet/LokinetGUI.app +rm -rf /Applications/LokinetGUI.app rm -rf /var/lib/lokinet rm -rf /usr/local/lokinet/ rm -rf /opt/lokinet From 452cf13841933d6f84479b7e8f7eb494ee91e3df Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 16:07:58 -0500 Subject: [PATCH 31/44] delete lokinet applications directory --- contrib/macos/lokinet_uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index 801ecb67da..f3e8d765d0 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -41,7 +41,7 @@ killall -9 lokinet || true ) rm -rf /Library/LaunchDaemons/network.loki.lokinet.daemon.plist -rm -rf /Applications/Lokinet/LokinetGUI.app +rm -rf /Applications/Lokinet/ rm -rf /Applications/LokinetGUI.app rm -rf /var/lib/lokinet rm -rf /usr/local/lokinet/ From 300ce892782e4956b7859409243327f088bd53c5 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 16:13:39 -0500 Subject: [PATCH 32/44] kill the gui --- contrib/macos/lokinet_uninstall.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index f3e8d765d0..0916776d3f 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -26,6 +26,9 @@ SERVICE_NAME=`scutil_query Setup:/Network/Service/$SERVICE_GUID \ # tell dns to be "empty" so that it's reset networksetup -setdnsservers "$SERVICE_NAME" empty +# kill the gui +killall LokinetGUI + # Prevent restarting on exit [ -e /var/lib/lokinet ] && touch /var/lib/lokinet/suspend-launchd-service # kill it From 876f292efb758a093319c75acda05df88c7fe238 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 16 Nov 2020 16:23:25 -0500 Subject: [PATCH 33/44] use /var/log/ for log files --- contrib/macos/network.loki.lokinet.daemon.plist | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contrib/macos/network.loki.lokinet.daemon.plist b/contrib/macos/network.loki.lokinet.daemon.plist index 974cad1702..cfdaa48aeb 100644 --- a/contrib/macos/network.loki.lokinet.daemon.plist +++ b/contrib/macos/network.loki.lokinet.daemon.plist @@ -21,9 +21,6 @@ StandardOutPath - /var/lib/lokinet/stdout - - StandardErrorPath - /var/lib/lokinet/stderr + /var/log/lokinet.log From 8c01201a2f1015c116d9cf4193415b1a87c4211b Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 16 Nov 2020 20:39:27 -0400 Subject: [PATCH 34/44] Upgrade libunbound to latest stable --- cmake/StaticBuild.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index c7f3ff1974..52c3491324 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -19,10 +19,10 @@ set(EXPAT_SOURCE expat-${EXPAT_VERSION}.tar.xz) set(EXPAT_HASH SHA512=e082874efcc4b00709e2c0192c88fb15dfc4f33fc3a2b09e619b010ea93baaf7e7572683f738463db0ce2350cab3de48a0c38af6b74d1c4f5a9e311f499edab0 CACHE STRING "expat source hash") -set(UNBOUND_VERSION 1.11.0 CACHE STRING "unbound version") +set(UNBOUND_VERSION 1.12.0 CACHE STRING "unbound version") set(UNBOUND_MIRROR ${LOCAL_MIRROR} https://nlnetlabs.nl/downloads/unbound CACHE STRING "unbound download mirror(s)") set(UNBOUND_SOURCE unbound-${UNBOUND_VERSION}.tar.gz) -set(UNBOUND_HASH SHA256=9f2f0798f76eb8f30feaeda7e442ceed479bc54db0e3ac19c052d68685e51ef7 +set(UNBOUND_HASH SHA256=5b9253a97812f24419bf2e6b3ad28c69287261cf8c8fa79e3e9f6d3bf7ef5835 CACHE STRING "unbound source hash") set(SQLITE3_VERSION 3330000 CACHE STRING "sqlite3 version") From f9144a7bb3805999efc6388e27208d52801c5ea9 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 16 Nov 2020 20:40:25 -0400 Subject: [PATCH 35/44] Patch to avoid IP_DONTFRAG bug in latest xcode with broken Big Sur SDK --- cmake/StaticBuild.cmake | 1 + contrib/patches/unbound-no-apple-dontfrag.patch | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 contrib/patches/unbound-no-apple-dontfrag.patch diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 52c3491324..b493111b0d 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -232,6 +232,7 @@ add_static_target(expat expat_external libexpat.a) build_external(unbound DEPENDS openssl_external expat_external + PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/contrib/patches/unbound-no-apple-dontfrag.patch CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared --enable-static --with-libunbound-only --with-pic --$,enable,disable>-flto --with-ssl=${DEPS_DESTDIR} diff --git a/contrib/patches/unbound-no-apple-dontfrag.patch b/contrib/patches/unbound-no-apple-dontfrag.patch new file mode 100644 index 0000000000..e6dfa67102 --- /dev/null +++ b/contrib/patches/unbound-no-apple-dontfrag.patch @@ -0,0 +1,11 @@ +--- a/services/listen_dnsport.c 2020-11-16 20:07:44.494582149 -0400 ++++ b/services/listen_dnsport.c 2020-11-16 20:07:31.074585943 -0400 +@@ -533,7 +533,7 @@ + return -1; + } + } +-# elif defined(IP_DONTFRAG) ++# elif defined(IP_DONTFRAG) && !defined(__APPLE__) + int off = 0; + if (setsockopt(s, IPPROTO_IP, IP_DONTFRAG, + &off, (socklen_t)sizeof(off)) < 0) { From 1c0e4dc4e7797f0c22294b35df3128f256917ddd Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 16 Nov 2020 20:42:34 -0400 Subject: [PATCH 36/44] Move all patches into contrib/patches --- cmake/StaticBuild.cmake | 2 +- contrib/{cross => }/patches/libzmq-mingw-closesocket.patch | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename contrib/{cross => }/patches/libzmq-mingw-closesocket.patch (100%) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index b493111b0d..e90859f939 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -258,7 +258,7 @@ add_static_target(sqlite3 sqlite3_external libsqlite3.a) if(ZMQ_VERSION VERSION_LESS 4.3.4 AND CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw) set(zmq_patch - PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/contrib/cross/patches/libzmq-mingw-closesocket.patch) + PATCH_COMMAND patch -p1 -i ${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-closesocket.patch) endif() build_external(zmq diff --git a/contrib/cross/patches/libzmq-mingw-closesocket.patch b/contrib/patches/libzmq-mingw-closesocket.patch similarity index 100% rename from contrib/cross/patches/libzmq-mingw-closesocket.patch rename to contrib/patches/libzmq-mingw-closesocket.patch From 8dd5bd6899b23819dd0b06eccede1a66b8921219 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Tue, 17 Nov 2020 14:39:27 -0400 Subject: [PATCH 37/44] Update to lokimq 1.2.2 for segfault-at-shutdown fix --- CMakeLists.txt | 2 +- external/loki-mq | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dac39e848a..9f77fdd13f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,7 @@ endif() option(FORCE_LOKIMQ_SUBMODULE "force using lokimq submodule" OFF) if(NOT FORCE_LOKIMQ_SUBMODULE) - pkg_check_modules(LOKIMQ liblokimq>=1.2) + pkg_check_modules(LOKIMQ liblokimq>=1.2.2) endif() if(LOKIMQ_FOUND) add_library(lokimq INTERFACE) diff --git a/external/loki-mq b/external/loki-mq index ea484729c7..e7487fd0c8 160000 --- a/external/loki-mq +++ b/external/loki-mq @@ -1 +1 @@ -Subproject commit ea484729c7bb7b430259a422df373e86bdd95b55 +Subproject commit e7487fd0c8ee843b3a3df16563ee42dad2fde050 From deae30257173968855e0da1968036f3a15ddd728 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Tue, 17 Nov 2020 15:22:33 -0400 Subject: [PATCH 38/44] macos: pass our pre-built static libs into the gui sub-build Avoids the mac build needing to build lokimq & libzmq twice (once in lokinet, then again in the gui) --- cmake/macos_installer_deps.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index 6aba28a6e0..ce4d33ee39 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -30,11 +30,20 @@ ExternalProject_Add(lokinet-uninstaller message(STATUS "Building LokinetGUI.app from ${LOKINET_GUI_REPO} @ ${LOKINET_GUI_CHECKOUT}") +if(NOT BUILD_STATIC_DEPS) + message(FATAL_ERROR "Building an installer on macos requires -DBUILD_STATIC_DEPS=ON") +endif() + + + ExternalProject_Add(lokinet-gui + DEPENDS lokimq::lokimq GIT_REPOSITORY "${LOKINET_GUI_REPO}" GIT_TAG "${LOKINET_GUI_CHECKOUT}" CMAKE_ARGS -DMACOS_APP=ON -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP} - -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DBUILD_SHARED_LIBS=OFF + "-DLOKIMQ_LIBRARIES=$$$$$" + "-DLOKIMQ_INCLUDE_DIRS=$" ) install(PROGRAMS ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_uninstall.sh From a753e96d8d9df62bca1087dc4da9b0bcee6ab129 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 18 Nov 2020 07:08:56 -0400 Subject: [PATCH 39/44] Version bump (#1483) * Bump version to 0.8.2 * Let cmake set PROJECT_NAME `project(x ...)` already sets PROJECT_NAME (and CMAKE_PROKECT_NAME if this is the top-level build) to `x`; the logic here seemed sort of backwards. * Get rid of uninstaller entitlement We don't seem to need it anymore with Qt 5.15.1. * Bump windows lokinet-gui build --- CMakeLists.txt | 5 ++--- cmake/win32_installer_deps.cmake | 4 ++-- contrib/macos/uninstaller/CMakeLists.txt | 3 +-- .../uninstaller/lokinet-uninstaller-entitlements.plist | 10 ---------- 4 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f77fdd13f..cec1825bf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,8 @@ if(CCACHE_PROGRAM) endforeach() endif() -set(PROJECT_NAME lokinet) -project(${PROJECT_NAME} - VERSION 0.8.1 +project(lokinet + VERSION 0.8.2 DESCRIPTION "lokinet - IP packet onion router" LANGUAGES C CXX) diff --git a/cmake/win32_installer_deps.cmake b/cmake/win32_installer_deps.cmake index 17c7376555..1ca1fe72a5 100644 --- a/cmake/win32_installer_deps.cmake +++ b/cmake/win32_installer_deps.cmake @@ -1,5 +1,5 @@ -set(GUI_ZIP_URL "https://builds.lokinet.dev/loki-project/loki-network-control-panel/master/lokinet-gui-windows-32bit-v0.3.3.zip") -set(GUI_ZIP_HASH SHA256=4a7be3e8d93b891959c896e050ff9e3beba2e82003419cb199fdacd53937a5cb) +set(GUI_ZIP_URL "https://builds.lokinet.dev/loki-project/loki-network-control-panel/master/lokinet-gui-windows-32bit-v0.3.4.zip") +set(GUI_ZIP_HASH SHA256=a91467dc37e9f55eea81141253099579ca68749b0ca89637db619d8ab466ccfa) set(TUNTAP_URL "https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe") set(TUNTAP_EXE "${CMAKE_BINARY_DIR}/tuntap-install.exe") set(BOOTSTRAP_URL "https://seed.lokinet.org/lokinet.signed") diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index 58b0009101..eddfdfaa0d 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -69,8 +69,7 @@ if(MACOS_SIGN) COMMAND echo "Running qt magic macos deploy script" COMMAND "${qt_dir}/macdeployqt" UninstallLokinet.app -always-overwrite COMMAND echo "Signing app bundle and everything inside it" - COMMAND codesign -s "${MACOS_SIGN}" --deep --strict --options runtime - --entitlements ${PROJECT_SOURCE_DIR}/lokinet-uninstaller-entitlements.plist --force -vvv UninstallLokinet.app + COMMAND codesign -s "${MACOS_SIGN}" --deep --strict --options runtime --force -vvv UninstallLokinet.app ) else() add_custom_command(TARGET ${PROJECT_NAME} diff --git a/contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist b/contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist deleted file mode 100644 index c318596233..0000000000 --- a/contrib/macos/uninstaller/lokinet-uninstaller-entitlements.plist +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - com.apple.security.cs.disable-library-validation - - - From e62f04c6014aec86534785557d087e4fbbd0258a Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 18 Nov 2020 13:49:16 -0400 Subject: [PATCH 40/44] Build mac uninstaller as subproject instead of externalproject (#1485) This makes it easier to build/rebuild via a target, and is a bit cleaner. --- cmake/macos_installer_deps.cmake | 15 +-------------- contrib/macos/uninstaller/CMakeLists.txt | 13 ++++++------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index ce4d33ee39..66b7cc68d8 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -20,13 +20,7 @@ set(MACOS_NOTARIZE_ASC "" include(ExternalProject) -message(STATUS "Building UninstallLokinet.app") - -ExternalProject_Add(lokinet-uninstaller - SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/macos/uninstaller - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP} - -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -) +add_subdirectory(${PROJECT_SOURCE_DIR}/contrib/macos/uninstaller) message(STATUS "Building LokinetGUI.app from ${LOKINET_GUI_REPO} @ ${LOKINET_GUI_CHECKOUT}") @@ -57,13 +51,6 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app PATTERN "*" ) -install(DIRECTORY ${PROJECT_BINARY_DIR}/UninstallLokinet.app - DESTINATION "../../Applications/Lokinet" - USE_SOURCE_PERMISSIONS - COMPONENT gui - PATTERN "*" - ) - # copy files that will be later moved by the postinstall script to proper locations install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh ${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index eddfdfaa0d..7aea0162ab 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -13,8 +13,7 @@ if(CCACHE_PROGRAM) endforeach() endif() -set(PROJECT_NAME lokinet-uninstaller) -project(${PROJECT_NAME} +project(lokinet-uninstaller VERSION 0.0.1 DESCRIPTION "lokinet uninstaller for macos" LANGUAGES CXX) @@ -54,7 +53,7 @@ set_target_properties(${PROJECT_NAME} set(MACOSX_BUNDLE_BUNDLE_NAME UninstallLokinet) set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lokinet.lokinet-uninstaller) set(MACOSX_BUNDLE_INFO_STRING "Lokinet uninstaller") -set(MACOSX_BUNDLE_ICON_FILE lokinet-uninstall.icns) +set(MACOSX_BUNDLE_ICON_FILE ${CMAKE_CURRENT_BINARY_DIR}/lokinet-uninstall.icns) set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) @@ -79,7 +78,7 @@ else() ) endif() -install(TARGETS lokinet-uninstaller - RUNTIME DESTINATION bin - BUNDLE DESTINATION . - RESOURCE DESTINATION .) +install(TARGETS ${PROJECT_NAME} + DESTINATION "../../Applications/Lokinet" + COMPONENT gui + ) From bc62e9dd2dbefd1c384ead28bcef7c1ad595db74 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 18 Nov 2020 17:54:29 -0400 Subject: [PATCH 41/44] Revert "Build mac uninstaller as subproject instead of externalproject (#1485)" This reverts commit e62f04c6014aec86534785557d087e4fbbd0258a. --- cmake/macos_installer_deps.cmake | 15 ++++++++++++++- contrib/macos/uninstaller/CMakeLists.txt | 13 +++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index 66b7cc68d8..ce4d33ee39 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -20,7 +20,13 @@ set(MACOS_NOTARIZE_ASC "" include(ExternalProject) -add_subdirectory(${PROJECT_SOURCE_DIR}/contrib/macos/uninstaller) +message(STATUS "Building UninstallLokinet.app") + +ExternalProject_Add(lokinet-uninstaller + SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/macos/uninstaller + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} +) message(STATUS "Building LokinetGUI.app from ${LOKINET_GUI_REPO} @ ${LOKINET_GUI_CHECKOUT}") @@ -51,6 +57,13 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app PATTERN "*" ) +install(DIRECTORY ${PROJECT_BINARY_DIR}/UninstallLokinet.app + DESTINATION "../../Applications/Lokinet" + USE_SOURCE_PERMISSIONS + COMPONENT gui + PATTERN "*" + ) + # copy files that will be later moved by the postinstall script to proper locations install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh ${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist diff --git a/contrib/macos/uninstaller/CMakeLists.txt b/contrib/macos/uninstaller/CMakeLists.txt index 7aea0162ab..eddfdfaa0d 100644 --- a/contrib/macos/uninstaller/CMakeLists.txt +++ b/contrib/macos/uninstaller/CMakeLists.txt @@ -13,7 +13,8 @@ if(CCACHE_PROGRAM) endforeach() endif() -project(lokinet-uninstaller +set(PROJECT_NAME lokinet-uninstaller) +project(${PROJECT_NAME} VERSION 0.0.1 DESCRIPTION "lokinet uninstaller for macos" LANGUAGES CXX) @@ -53,7 +54,7 @@ set_target_properties(${PROJECT_NAME} set(MACOSX_BUNDLE_BUNDLE_NAME UninstallLokinet) set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lokinet.lokinet-uninstaller) set(MACOSX_BUNDLE_INFO_STRING "Lokinet uninstaller") -set(MACOSX_BUNDLE_ICON_FILE ${CMAKE_CURRENT_BINARY_DIR}/lokinet-uninstall.icns) +set(MACOSX_BUNDLE_ICON_FILE lokinet-uninstall.icns) set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) @@ -78,7 +79,7 @@ else() ) endif() -install(TARGETS ${PROJECT_NAME} - DESTINATION "../../Applications/Lokinet" - COMPONENT gui - ) +install(TARGETS lokinet-uninstaller + RUNTIME DESTINATION bin + BUNDLE DESTINATION . + RESOURCE DESTINATION .) From b18546086ae91db485ed5fa33d46232a4d6e92d0 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 18 Nov 2020 17:06:48 -0500 Subject: [PATCH 42/44] make macos uninstaller actually kill and uninstall lokinet (#1484) * macos fluff * make uninstaller work, the uninstall script needs to be called with /usr/bin/sudo to work because god know why it needs that even though it's already root. * add logrotation * make the uninstall script kill all the things * revert * use correct regular expression * remove logrotate configs rename logrotate config file name to be more descriptive --- cmake/macos_installer_deps.cmake | 1 + contrib/macos/lokinet-newsyslog.conf | 1 + contrib/macos/lokinet_uninstall.sh | 30 ++++++++++++++-------------- contrib/macos/postinstall | 4 ++++ contrib/macos/uninstaller/main.cpp | 11 +++++----- 5 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 contrib/macos/lokinet-newsyslog.conf diff --git a/cmake/macos_installer_deps.cmake b/cmake/macos_installer_deps.cmake index 66b7cc68d8..5b02f8f8c4 100644 --- a/cmake/macos_installer_deps.cmake +++ b/cmake/macos_installer_deps.cmake @@ -54,6 +54,7 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app # copy files that will be later moved by the postinstall script to proper locations install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh ${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist + ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet-newsyslog.conf DESTINATION "extra/" COMPONENT lokinet) diff --git a/contrib/macos/lokinet-newsyslog.conf b/contrib/macos/lokinet-newsyslog.conf new file mode 100644 index 0000000000..69c30ffd34 --- /dev/null +++ b/contrib/macos/lokinet-newsyslog.conf @@ -0,0 +1 @@ +/var/log/lokinet.log 644 5 5M $D0 J \ No newline at end of file diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index 0916776d3f..e094f58848 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/bin/bash +set -x +test `whoami` == root || exit 1 # this is for dns tomfoolery scutil_query() @@ -26,22 +28,20 @@ SERVICE_NAME=`scutil_query Setup:/Network/Service/$SERVICE_GUID \ # tell dns to be "empty" so that it's reset networksetup -setdnsservers "$SERVICE_NAME" empty -# kill the gui -killall LokinetGUI +# shut off exit if it's up +pgrep lokinet$ && /opt/lokinet/bin/lokinet-vpn --down # Prevent restarting on exit -[ -e /var/lib/lokinet ] && touch /var/lib/lokinet/suspend-launchd-service -# kill it -killall lokinet || true -# Give it some time to shut down before we bring launchd into this -sleep 2 -# make sure it's dead -killall -9 lokinet || true +touch /var/lib/lokinet/suspend-launchd-service +# kill the gui and such +killall LokinetGUI +killall lokinet # if the launch daemon is there kill it -[ -e /Library/LaunchDaemons/network.loki.lokinet.daemon.plist ] && ( - launchctl stop network.loki.lokinet.daemon ; - launchctl unload /Library/LaunchDaemons/network.loki.lokinet.daemon.plist -) +/bin/launchctl stop network.loki.lokinet.daemon +/bin/launchctl unload /Library/LaunchDaemons/network.loki.lokinet.daemon.plist + +# kill it and make sure it's dead +killall -9 lokinet rm -rf /Library/LaunchDaemons/network.loki.lokinet.daemon.plist rm -rf /Applications/Lokinet/ @@ -49,4 +49,4 @@ rm -rf /Applications/LokinetGUI.app rm -rf /var/lib/lokinet rm -rf /usr/local/lokinet/ rm -rf /opt/lokinet - +rm -f /etc/newsyslog.d/lokinet.conf diff --git a/contrib/macos/postinstall b/contrib/macos/postinstall index 6e8f1638af..ac2674f7ff 100644 --- a/contrib/macos/postinstall +++ b/contrib/macos/postinstall @@ -18,6 +18,10 @@ mv /opt/lokinet/extra/network.loki.lokinet.daemon.plist /Library/LaunchDaemons/ chown $CHOWN /Library/LaunchDaemons/network.loki.lokinet.daemon.plist chmod 640 /Library/LaunchDaemons/network.loki.lokinet.daemon.plist +mv /opt/lokinet/extra/lokinet-newsyslog.conf /etc/newsyslog.d/lokinet.conf +chown $CHOWN /etc/newsyslog.d/lokinet.conf +chmod 640 /etc/newsyslog.d/lokinet.conf + # clean up by removing 'extra/' (so long as it's empty) rmdir /opt/lokinet/extra/ diff --git a/contrib/macos/uninstaller/main.cpp b/contrib/macos/uninstaller/main.cpp index a069a7f05f..a58b116c8f 100644 --- a/contrib/macos/uninstaller/main.cpp +++ b/contrib/macos/uninstaller/main.cpp @@ -33,11 +33,12 @@ int uninstall() AuthorizationRef authorizationRef; OSStatus status; - status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef); - - char* tool = "/opt/lokinet/bin/lokinet_uninstall.sh"; - char* args[] = {nullptr}; - FILE* pipe = NULL; + status = AuthorizationCreate(nullptr, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef); + if(status != 0) + return status; + char* tool = "/bin/sh"; + char* args[] = {"/opt/lokinet/bin/lokinet_uninstall.sh", nullptr}; + FILE* pipe = stdout; return AuthorizationExecuteWithPrivileges(authorizationRef, tool, kAuthorizationFlagDefaults, args, &pipe); } From 6407733c8edf30e87014e421eb8008b57f6e294b Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 20 Nov 2020 12:37:30 -0500 Subject: [PATCH 43/44] * make llarp.halt rpc call actually return a reply (#1488) * add --kill flag to lokinet-vpn that calls llarp.halt * make macos uninstaller kill lokinet via lokinet-vpn --kill --- contrib/macos/lokinet_uninstall.sh | 9 +++++---- daemon/lokinet-vpn.cpp | 16 +++++++++++++++- llarp/rpc/rpc_server.cpp | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/contrib/macos/lokinet_uninstall.sh b/contrib/macos/lokinet_uninstall.sh index e094f58848..63885b9724 100755 --- a/contrib/macos/lokinet_uninstall.sh +++ b/contrib/macos/lokinet_uninstall.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -x test `whoami` == root || exit 1 @@ -28,11 +28,12 @@ SERVICE_NAME=`scutil_query Setup:/Network/Service/$SERVICE_GUID \ # tell dns to be "empty" so that it's reset networksetup -setdnsservers "$SERVICE_NAME" empty -# shut off exit if it's up -pgrep lokinet$ && /opt/lokinet/bin/lokinet-vpn --down - # Prevent restarting on exit touch /var/lib/lokinet/suspend-launchd-service + +# shut off lokinet gracefully +pgrep lokinet$ && /opt/lokinet/bin/lokinet-vpn --kill + # kill the gui and such killall LokinetGUI killall lokinet diff --git a/daemon/lokinet-vpn.cpp b/daemon/lokinet-vpn.cpp index 51ac591bc7..5e43f67221 100644 --- a/daemon/lokinet-vpn.cpp +++ b/daemon/lokinet-vpn.cpp @@ -59,6 +59,7 @@ main(int argc, char* argv[]) opts.add_options() ("v,verbose", "Verbose", cxxopts::value()) ("h,help", "help", cxxopts::value()) + ("kill", "kill the daemon", cxxopts::value()) ("up", "put vpn up", cxxopts::value()) ("down", "put vpn down", cxxopts::value()) ("exit", "specify exit node address", cxxopts::value()) @@ -77,6 +78,7 @@ main(int argc, char* argv[]) bool goUp = false; bool goDown = false; bool printStatus = false; + bool killDaemon = false; try { const auto result = opts.parse(argc, argv); @@ -102,6 +104,7 @@ main(int argc, char* argv[]) goUp = result.count("up") > 0; goDown = result.count("down") > 0; printStatus = result.count("status") > 0; + killDaemon = result.count("kill") > 0; if (result.count("endpoint") > 0) { @@ -127,7 +130,7 @@ main(int argc, char* argv[]) std::cout << ex.what() << std::endl; return 1; } - if ((not goUp) and (not goDown) and (not printStatus)) + if ((not goUp) and (not goDown) and (not printStatus) and (not killDaemon)) { std::cout << opts.help() << std::endl; return 1; @@ -161,6 +164,17 @@ main(int argc, char* argv[]) return 1; } + if (killDaemon) + { + const auto maybe = LMQ_Request(lmq, connID, "llarp.halt"); + if (not maybe.has_value()) + { + std::cout << "call to llarp.admin.die failed" << std::endl; + return 1; + } + return 0; + } + if (printStatus) { const auto maybe_status = LMQ_Request(lmq, connID, "llarp.status"); diff --git a/llarp/rpc/rpc_server.cpp b/llarp/rpc/rpc_server.cpp index 1dd861cc3f..a0d138f546 100644 --- a/llarp/rpc/rpc_server.cpp +++ b/llarp/rpc/rpc_server.cpp @@ -93,8 +93,8 @@ namespace llarp::rpc msg.send_reply(CreateJSONError("router is not running")); return; } - m_Router->Stop(); msg.send_reply(CreateJSONResponse("OK")); + m_Router->Stop(); }) .add_request_command( "version", From 1eb5c6deedbbe80e99d7db2229d7cdd90f39f2a0 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 23 Nov 2020 14:45:30 -0500 Subject: [PATCH 44/44] resolve merge conflicts for 0.8.2 (#1493) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update gui win32 package url (#1466) * Dev to stable (#1471) * Install less stuff on windows CI mingw-w64 is a metapackage that pulls in 4 different compilers {i686,x86_64}×{-posix,-win32} but we only need x86_64-posix, so just install that package. * Update gui win32 package url (#1466) (#1468) Co-authored-by: Jeff * stop lokinet before uninstalling service (#1469) * stop lokinet before uninstalling service * kill gui in uninstaller * add helper script for building windows installers because i forgot how to most of the time. * Update win32 gui download with smaller svg icon Co-authored-by: Jeff Co-authored-by: Jason Rhinelander