diff options
author | Ruben Pollan <meskio@sindominio.net> | 2020-10-13 15:21:54 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2020-10-13 19:09:56 +0200 |
commit | 1190bdaeebac0a9b678b8e2b5032062f1869eca3 (patch) | |
tree | 57fbd5b7b4e5011d797bbe8f9df53def0a822400 /pkg/vpn | |
parent | 481bd7db1d9c3937373c643d6d6aa3164b179839 (diff) |
[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.
Diffstat (limited to 'pkg/vpn')
-rw-r--r-- | pkg/vpn/launcher_linux.go | 16 |
1 files 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 } |