mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
cmd/cli: Capitalizing launchd status error message
This commit is contained in:
committed by
Cuong Manh Le
parent
50ef00526e
commit
139dd62ff3
+10
-2
@@ -29,7 +29,7 @@ func newService(i service.Interface, c *service.Config) (service.Service, error)
|
|||||||
case s.Platform() == "linux-systemd":
|
case s.Platform() == "linux-systemd":
|
||||||
return &systemd{s}, nil
|
return &systemd{s}, nil
|
||||||
case s.Platform() == "darwin-launchd":
|
case s.Platform() == "darwin-launchd":
|
||||||
return &launchd{s}, nil
|
return newLaunchd(s), nil
|
||||||
|
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
@@ -130,17 +130,25 @@ func (s *systemd) Status() (service.Status, error) {
|
|||||||
return s.Service.Status()
|
return s.Service.Status()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newLaunchd(s service.Service) *launchd {
|
||||||
|
return &launchd{
|
||||||
|
Service: s,
|
||||||
|
statusErrMsg: "Permission denied",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// launchd wraps a service.Service, and provide status command to
|
// launchd wraps a service.Service, and provide status command to
|
||||||
// report the status correctly when not running as root on Darwin.
|
// report the status correctly when not running as root on Darwin.
|
||||||
//
|
//
|
||||||
// TODO: remove this wrapper once https://github.com/kardianos/service/issues/400 fixed.
|
// TODO: remove this wrapper once https://github.com/kardianos/service/issues/400 fixed.
|
||||||
type launchd struct {
|
type launchd struct {
|
||||||
service.Service
|
service.Service
|
||||||
|
statusErrMsg string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *launchd) Status() (service.Status, error) {
|
func (l *launchd) Status() (service.Status, error) {
|
||||||
if os.Geteuid() != 0 {
|
if os.Geteuid() != 0 {
|
||||||
return service.StatusUnknown, errors.New("permission denied")
|
return service.StatusUnknown, errors.New(l.statusErrMsg)
|
||||||
}
|
}
|
||||||
return l.Service.Status()
|
return l.Service.Status()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user