ipn/ipnlocal: add health warning for Tailscale SSH + SELinux

Updates #4908

Change-Id: If46be5045b13dd5c3068c334642f89b5917ec861
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/7049/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent c8db70fd73
commit 6e5faff51e

@ -5,6 +5,7 @@
package ipnlocal package ipnlocal
import ( import (
"bytes"
"context" "context"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
@ -17,6 +18,7 @@ import (
"net/netip" "net/netip"
"net/url" "net/url"
"os" "os"
"os/exec"
"os/user" "os/user"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -2495,6 +2497,7 @@ func (b *LocalBackend) checkSSHPrefsLocked(p *ipn.Prefs) error {
if distro.Get() == distro.QNAP && !envknob.UseWIPCode() { if distro.Get() == distro.QNAP && !envknob.UseWIPCode() {
return errors.New("The Tailscale SSH server does not run on QNAP.") return errors.New("The Tailscale SSH server does not run on QNAP.")
} }
checkSELinux()
// otherwise okay // otherwise okay
case "darwin": case "darwin":
// okay only in tailscaled mode for now. // okay only in tailscaled mode for now.
@ -4508,11 +4511,26 @@ func (b *LocalBackend) sshServerOrInit() (_ SSHServer, err error) {
return b.sshServer, nil return b.sshServer, nil
} }
var warnSSHSELinux = health.NewWarnable()
func checkSELinux() {
if runtime.GOOS != "linux" {
return
}
out, _ := exec.Command("getenforce").Output()
if string(bytes.TrimSpace(out)) == "Enforcing" {
warnSSHSELinux.Set(errors.New("SELinux is enabled; Tailscale SSH may not work. See https://tailscale.com/s/ssh-selinux"))
} else {
warnSSHSELinux.Set(nil)
}
}
func (b *LocalBackend) HandleSSHConn(c net.Conn) (err error) { func (b *LocalBackend) HandleSSHConn(c net.Conn) (err error) {
s, err := b.sshServerOrInit() s, err := b.sshServerOrInit()
if err != nil { if err != nil {
return err return err
} }
checkSELinux()
return s.HandleSSHConn(c) return s.HandleSSHConn(c)
} }

Loading…
Cancel
Save