4
0
Fork 0

fixed SystemSSHEnabled

This commit is contained in:
Benjamin Böhmke 2019-12-15 16:24:44 +01:00
parent 129281fc96
commit d35d9afa3e
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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)
}