From d35d9afa3ebdefd917fa59716d4980e9f22bbb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=B6hmke?= Date: Sun, 15 Dec 2019 16:24:44 +0100 Subject: [PATCH] fixed SystemSSHEnabled --- system.go | 2 +- system_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system.go b/system.go index 7634a7a..817f9bc 100644 --- a/system.go +++ b/system.go @@ -40,7 +40,7 @@ func SystemSSHEnabled() (bool, error) { return false, fmt.Errorf("failed to read ssh config: %w", err) } - return strings.Contains(string(data), "127.0.0.1:22"), nil + return !strings.Contains(string(data), "127.0.0.1:22"), nil } // SystemEnableSSH server diff --git a/system_test.go b/system_test.go index bdf39c8..0c5adf2 100644 --- a/system_test.go +++ b/system_test.go @@ -43,12 +43,12 @@ func TestSystemSSHEnabled(t *testing.T) { ass.NoError(ioutil.WriteFile(systemDropbearConfig, []byte("test"), os.ModePerm)) value, err := SystemSSHEnabled() ass.NoError(err) - ass.False(value) + ass.True(value) ass.NoError(ioutil.WriteFile(systemDropbearConfig, []byte("DROPBEAR_OPTS=\"-p 127.0.0.1:22\""), os.ModePerm)) value, err = SystemSSHEnabled() ass.NoError(err) - ass.True(value) + ass.False(value) _ = os.Remove(systemDropbearConfig) }