From ef892643df8970aec45dbc3f48eabb95a1ccbf22 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 30 Sep 2020 16:25:27 +0200 Subject: [pkg] osx helper and working qt installer --- pkg/helper/darwin.go | 24 +++++++++++------------- pkg/vpn/launcher.go | 10 ++++++---- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'pkg') diff --git a/pkg/helper/darwin.go b/pkg/helper/darwin.go index ae42646..2210da3 100644 --- a/pkg/helper/darwin.go +++ b/pkg/helper/darwin.go @@ -50,24 +50,23 @@ const ( func _getExecPath() string { ex, err := os.Executable() if err != nil { - log.Print("error while getting executable path!") + log.Print("ERROR: cannot find executable path") } return filepath.Dir(ex) } -func getHelperPath() string { - execPath := _getExecPath() - hp := filepath.Join(execPath, "../../../", "bitmask-helper") - log.Println(">>> DEBUG: helper", hp) - return hp +func getHelperDir() string { + d := _getExecPath() + log.Println(">>> DEBUG: helper dir", d) + return d } func getPlatformOpenvpnFlags() []string { - helperPath := getHelperPath() + helperDir := getHelperDir() return []string{ "--script-security", "2", - "--up", helperPath + "client.up.sh", - "--down", helperPath + "client.down.sh", + "--up", filepath.Join(helperDir, "client.up.sh"), + "--down", filepath.Join(helperDir, "client.down.sh"), } } @@ -83,7 +82,7 @@ func daemonize() { PidFilePerm: 0644, LogFileName: "bitmask-helper.log", LogFilePerm: 0640, - WorkDir: "./", + WorkDir: filepath.Join(getHelperDir(), "helper"), Umask: 027, Args: []string{"[bitmask-helper]"}, } @@ -107,8 +106,7 @@ func runServer(preferredPort int) { } func getOpenvpnPath() string { - execPath := _getExecPath() - openvpnPath := filepath.Join(execPath, "../../../", "openvpn.leap") + openvpnPath := filepath.Join(getHelperDir(), "openvpn.leap") log.Println(">>> DEBUG: openvpn", openvpnPath) return openvpnPath } @@ -203,7 +201,7 @@ func loadBitmaskAnchor() error { } func getRulefilePath() (string, error) { - rulefilePath := filepath.Join(getHelperPath(), "helper", "bitmask.pf.conf") + rulefilePath := filepath.Join(getHelperDir(), "helper", "bitmask.pf.conf") log.Println("DEBUG: rule file path", rulefilePath) if _, err := os.Stat(rulefilePath); !os.IsNotExist(err) { diff --git a/pkg/vpn/launcher.go b/pkg/vpn/launcher.go index e18fdc6..234a89c 100644 --- a/pkg/vpn/launcher.go +++ b/pkg/vpn/launcher.go @@ -1,5 +1,5 @@ // +build !linux -// Copyright (C) 2018 LEAP +// Copyright (C) 2018-2020 LEAP // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -51,12 +51,12 @@ func probeHelperPort(port int) int { break } } + log.Println("WARN: Cannot find working helper") return 0 } func smellsLikeOurHelperSpirit(port int, c *http.Client) bool { uri := "http://localhost:" + strconv.Itoa(port) + "/version" - log.Println("probing for helper at", uri) resp, err := c.Get(uri) if err != nil { return false @@ -68,9 +68,10 @@ func smellsLikeOurHelperSpirit(port int, c *http.Client) bool { return false } if strings.Contains(string(ver), config.ApplicationName) { + log.Println("DEBUG: Successfully probed for matching helper at", uri) return true } else { - log.Println("Another helper replied to our version request:", string(ver)) + log.Println("DEBUG: Another helper seems to be running:", string(ver)) } } return false @@ -157,7 +158,8 @@ func (l *launcher) send(path string, body []byte) error { resErr, err := ioutil.ReadAll(res.Body) if len(resErr) > 0 { - return fmt.Errorf("Helper returned an error: %q", resErr) + /* FIXME why do we trigger a fatal with this error? */ + return fmt.Errorf("FATAL: Helper returned an error: %q", resErr) } return err } -- cgit v1.2.3