fix: Fix the issue of abnormal sshd service auto-start status (#11022)

Refs #11017
This commit is contained in:
ssongliu
2025-11-21 16:13:06 +08:00
committed by GitHub
parent bddcf76fc3
commit fb929687d8

View File

@@ -26,10 +26,10 @@ func (s *Systemd) IsActive(serviceName string) (bool, error) {
func (s *Systemd) IsEnable(serviceName string) (bool, error) {
out, err := run(s.toolCmd, "is-enabled", serviceName)
if out == "alias\n" && serviceName == "sshd.service" {
return s.IsEnable("ssh")
}
if err != nil && out != "disabled\n" {
if serviceName == "sshd" && out == "alias\n" {
return s.IsEnable("ssh")
}
if NewSnap().IsEnable(serviceName) {
return true, nil
}