From 7c4a4f5ae0c02f57eb9073fa8f412a38b8f79363 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Tue, 4 Aug 2020 19:28:43 +0200 Subject: Quit if there was an initializaton error Let's close properly without segfaults :) --- pkg/backend/api.go | 9 ++++++--- pkg/backend/init.go | 2 +- pkg/vpn/launcher_linux.go | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'pkg') diff --git a/pkg/backend/api.go b/pkg/backend/api.go index 99e156f..ff8c1bb 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -4,7 +4,6 @@ package backend import ( "C" - "fmt" "log" "strconv" "unsafe" @@ -31,7 +30,9 @@ func Quit() { } else { ctx.cfg.SetUserStoppedVPN(true) } - ctx.bm.Close() + if ctx.bm != nil { + ctx.bm.Close() + } } func DonateAccepted() { @@ -55,7 +56,9 @@ func InitializeBitmaskContext(opts *InitOpts) { initOnce.Do(func() { initializeContext(opts) }) runDonationReminder() - go ctx.updateStatus() + if ctx.bm != nil { + go ctx.updateStatus() + } } func RefreshContext() *C.char { diff --git a/pkg/backend/init.go b/pkg/backend/init.go index 79efdc7..bae9b9b 100644 --- a/pkg/backend/init.go +++ b/pkg/backend/init.go @@ -45,6 +45,7 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { os.Exit(1) } bitmask.InitializeLogger() + ctx.cfg = config.ParseConfig() b, err := bitmask.InitializeBitmask(opts.SkipLaunch) if err != nil { @@ -70,5 +71,4 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { } ctx.bm = b - ctx.cfg = config.ParseConfig() } diff --git a/pkg/vpn/launcher_linux.go b/pkg/vpn/launcher_linux.go index f92cf6f..1280eae 100644 --- a/pkg/vpn/launcher_linux.go +++ b/pkg/vpn/launcher_linux.go @@ -230,7 +230,8 @@ func bitmaskRootPath() (string, error) { return path, nil } } - return "", errors.New("No bitmask-root found") + log.Println("Can't find bitmask-root") + return "", errors.New("nohelpers") } func getOpenvpnPath() string { -- cgit v1.2.3