File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -330,12 +330,28 @@ func (s SystemdService) IsPresent(ctx context.Context) (bool, error) {
330
330
331
331
// checkSystem returns an error if the system is not compatible with this process manager.
332
332
func (s SystemdService ) checkSystem (ctx context.Context ) error {
333
- _ , err := os .Stat ("/run/systemd/system" )
334
- if errors .Is (err , os .ErrNotExist ) {
333
+ present , err := hasSystemD ()
334
+ if err != nil {
335
+ return trace .Wrap (err )
336
+ }
337
+ if ! present {
335
338
s .Log .ErrorContext (ctx , "This system does not support systemd, which is required by the updater." )
336
339
return trace .Wrap (ErrNotSupported )
337
340
}
338
- return trace .Wrap (err )
341
+ return nil
342
+
343
+ }
344
+
345
+ // hasSystemD returns true if the system uses the SystemD process manager.
346
+ func hasSystemD () (bool , error ) {
347
+ _ , err := os .Stat ("/run/systemd/system" )
348
+ if errors .Is (err , os .ErrNotExist ) {
349
+ return false , nil
350
+ }
351
+ if err != nil {
352
+ return false , trace .Wrap (err )
353
+ }
354
+ return true , nil
339
355
}
340
356
341
357
// systemctl returns a systemctl subcommand, converting the output to logs.
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ import (
31
31
// The binary is considered managed if it lives under /opt/teleport, but not within the package
32
32
// path at /opt/teleport/system.
33
33
func IsManagedByUpdater () (bool , error ) {
34
+ systemd , err := hasSystemD ()
35
+ if err != nil {
36
+ return false , trace .Wrap (err )
37
+ }
38
+ if ! systemd {
39
+ return false , nil
40
+ }
34
41
teleportPath , err := os .Readlink ("/proc/self/exe" )
35
42
if err != nil {
36
43
return false , trace .Wrap (err , "cannot find Teleport binary" )
@@ -52,6 +59,13 @@ func IsManagedByUpdater() (bool, error) {
52
59
// and the default installation (with teleport.service as the unit file name).
53
60
// The binary is considered managed and default if it lives within /opt/teleport/default.
54
61
func IsManagedAndDefault () (bool , error ) {
62
+ systemd , err := hasSystemD ()
63
+ if err != nil {
64
+ return false , trace .Wrap (err )
65
+ }
66
+ if ! systemd {
67
+ return false , nil
68
+ }
55
69
teleportPath , err := os .Readlink ("/proc/self/exe" )
56
70
if err != nil {
57
71
return false , trace .Wrap (err , "cannot find Teleport binary" )
You can’t perform that action at this time.
0 commit comments