Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions lib/autoupdate/agent/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,28 @@ func (s SystemdService) IsPresent(ctx context.Context) (bool, error) {

// checkSystem returns an error if the system is not compatible with this process manager.
func (s SystemdService) checkSystem(ctx context.Context) error {
_, err := os.Stat("/run/systemd/system")
if errors.Is(err, os.ErrNotExist) {
present, err := hasSystemD()
if err != nil {
return trace.Wrap(err)
}
if !present {
s.Log.ErrorContext(ctx, "This system does not support systemd, which is required by the updater.")
return trace.Wrap(ErrNotSupported)
}
return trace.Wrap(err)
return nil

}

// hasSystemD returns true if the system uses the SystemD process manager.
func hasSystemD() (bool, error) {
_, err := os.Stat("/run/systemd/system")
if errors.Is(err, os.ErrNotExist) {
return false, nil
}
if err != nil {
return false, trace.Wrap(err)
}
return true, nil
}

// systemctl returns a systemctl subcommand, converting the output to logs.
Expand Down
14 changes: 14 additions & 0 deletions lib/autoupdate/agent/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ import (
// The binary is considered managed if it lives under /opt/teleport, but not within the package
// path at /opt/teleport/system.
func IsManagedByUpdater() (bool, error) {
systemd, err := hasSystemD()
if err != nil {
return false, trace.Wrap(err)
}
if !systemd {
return false, nil
}
teleportPath, err := os.Readlink("/proc/self/exe")
if err != nil {
return false, trace.Wrap(err, "cannot find Teleport binary")
Expand All @@ -52,6 +59,13 @@ func IsManagedByUpdater() (bool, error) {
// and the default installation (with teleport.service as the unit file name).
// The binary is considered managed and default if it lives within /opt/teleport/default.
func IsManagedAndDefault() (bool, error) {
systemd, err := hasSystemD()
if err != nil {
return false, trace.Wrap(err)
}
if !systemd {
return false, nil
}
teleportPath, err := os.Readlink("/proc/self/exe")
if err != nil {
return false, trace.Wrap(err, "cannot find Teleport binary")
Expand Down