summaryrefslogtreecommitdiff
path: root/pkg/vpn
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/vpn')
-rw-r--r--pkg/vpn/launcher_linux.go53
-rw-r--r--pkg/vpn/main.go11
-rw-r--r--pkg/vpn/openvpn.go5
3 files changed, 44 insertions, 25 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",
diff --git a/pkg/vpn/main.go b/pkg/vpn/main.go
index ce599c9..9d59131 100644
--- a/pkg/vpn/main.go
+++ b/pkg/vpn/main.go
@@ -51,10 +51,13 @@ func Init() (*Bitmask, error) {
}
b := Bitmask{tempdir, statusCh, nil, bonafide, launch, "", nil}
- err = b.StopVPN()
- if err != nil {
- return nil, err
- }
+ /*
+ err = b.StopVPN()
+ if err != nil {
+ return nil, err
+ }
+ */
+
err = ioutil.WriteFile(b.getCaCertPath(), config.CaCert, 0600)
go b.openvpnManagement()
diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go
index a75b830..984aa09 100644
--- a/pkg/vpn/openvpn.go
+++ b/pkg/vpn/openvpn.go
@@ -207,14 +207,13 @@ func (b *Bitmask) GetStatus() (string, error) {
return status, nil
}
-// InstallHelpers into the system
func (b *Bitmask) InstallHelpers() error {
- // TODO
+ // TODO use pickle module from here
return nil
}
// VPNCheck returns if the helpers are installed and up to date and if polkit is running
-func (b *Bitmask) VPNCheck() (helpers bool, priviledge bool, err error) {
+func (b *Bitmask) VPNCheck() (helpers bool, privilege bool, err error) {
return b.launch.check()
}