From 1190bdaeebac0a9b678b8e2b5032062f1869eca3 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Tue, 13 Oct 2020 15:21:54 +0200 Subject: [bug] get the correct snap paths config.BinaryName is not set when the global variables are defined, we need to generate the string when we need it instead. --- pkg/vpn/launcher_linux.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/vpn/launcher_linux.go b/pkg/vpn/launcher_linux.go index ba505b8..b91bb3e 100644 --- a/pkg/vpn/launcher_linux.go +++ b/pkg/vpn/launcher_linux.go @@ -32,15 +32,9 @@ const ( systemOpenvpnPath = "/usr/sbin/openvpn" ) -var ( - snapOpenvpnPath = "/snap/bin/" + config.BinaryName + ".openvpn" - snapBitmaskRootPath = "/snap/bin/" + config.BinaryName + ".bitmask-root" -) - var bitmaskRootPaths = []string{ "/usr/sbin/bitmask-root", "/usr/local/sbin/bitmask-root", - snapBitmaskRootPath, } type launcher struct { @@ -96,10 +90,8 @@ func (l *launcher) check() (helpers bool, privilege bool, err error) { func hasHelpers() (bool, error) { /* TODO add polkit file too */ - for _, f := range bitmaskRootPaths { - if _, err := os.Stat(f); err == nil { - return true, nil - } + if _, err := bitmaskRootPath(); err == nil { + return true, nil } return false, nil } @@ -230,7 +222,7 @@ func runBitmaskRoot(arg ...string) error { func bitmaskRootPath() (string, error) { if os.Getenv("SNAP") != "" { - path := snapBitmaskRootPath + path := "/snap/bin/" + config.BinaryName + ".bitmask-root" if _, err := os.Stat(path); !os.IsNotExist(err) { return path, nil } @@ -246,7 +238,7 @@ func bitmaskRootPath() (string, error) { func getOpenvpnPath() string { if os.Getenv("SNAP") != "" { - return snapOpenvpnPath + return "/snap/bin/" + config.BinaryName + ".openvpn" } return systemOpenvpnPath } -- cgit v1.2.3