summaryrefslogtreecommitdiff
path: root/pkg/vpn/launcher_linux.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-17 21:14:35 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-06-26 12:13:44 +0200
commit20266b063c1be8818d4582bff7b59486551ee447 (patch)
tree2f7bd97624104e7defecd6d29fff8dad2446c0ce /pkg/vpn/launcher_linux.go
parent9b8009cfaf6707d23a20494cd5467aed9c98513b (diff)
[feat] pass initialization errors to gui
Diffstat (limited to 'pkg/vpn/launcher_linux.go')
-rw-r--r--pkg/vpn/launcher_linux.go53
1 files changed, 35 insertions, 18 deletions
diff --git a/pkg/vpn/launcher_linux.go b/pkg/vpn/launcher_linux.go
index 71a74ea..f92cf6f 100644
--- a/pkg/vpn/launcher_linux.go
+++ b/pkg/vpn/launcher_linux.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
@@ -53,32 +53,49 @@ func (l *launcher) close() error {
return nil
}
-func (l *launcher) check() (helpers bool, priviledge bool, err error) {
+func (l *launcher) check() (helpers bool, privilege bool, err error) {
+ hasHelpers, err := hasHelpers()
+ if err != nil {
+ return
+ }
+ if !hasHelpers {
+ return false, true, nil
+ }
- /*
- isRunning, err := isPolkitRunning()
+ isRunning, err := isPolkitRunning()
+ if err != nil {
+ return
+ }
+
+ if !isRunning {
+ polkitPath := getPolkitPath()
+ if polkitPath == "" {
+ return true, false, nil
+ }
+ cmd := exec.Command("setsid", polkitPath)
+ err = cmd.Start()
if err != nil {
return
}
- if !isRunning {
- polkitPath := getPolkitPath()
- if polkitPath == "" {
- return true, false, nil
- }
- cmd := exec.Command("setsid", polkitPath)
- err = cmd.Start()
- if err != nil {
- return
- }
- isRunning, err = isPolkitRunning()
- return true, isRunning, err
- }
- */
+ isRunning, err = isPolkitRunning()
+ return true, isRunning, err
+ }
return true, true, nil
}
+func hasHelpers() (bool, error) {
+ /* TODO add polkit file too */
+ for _, f := range bitmaskRootPaths {
+ if _, err := os.Stat(f); err == nil {
+ return true, nil
+ }
+ }
+ return false, nil
+}
+
func isPolkitRunning() (bool, error) {
+ // TODO shouldn't we also check for polkitd running?
var polkitProcNames = [...]string{
"polkit-gnome-authentication-agent-1",
"polkit-kde-authentication-agent-1",