Skip to content

Commit d219646

Browse files
authored
Merge pull request #237 from kinvolk/iaguis/fix-runningFromSystemService
util: fix runningFromSystemService
2 parents 24036eb + b703c57 commit d219646

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

util/util_cgo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ func runningFromSystemService() (ret bool, err error) {
122122
errno := C.my_sd_pid_get_owner_uid(sd_pid_get_owner_uid, 0, &uid)
123123
serrno := syscall.Errno(-errno)
124124
// when we're running from a unit file, sd_pid_get_owner_uid returns
125-
// ENOENT (systemd <220) or ENXIO (systemd >=220)
125+
// ENOENT (systemd <220), ENXIO (systemd 220-223), or ENODATA
126+
// (systemd >=234)
126127
switch {
127128
case errno >= 0:
128129
ret = false
129-
case serrno == syscall.ENOENT, serrno == syscall.ENXIO:
130+
case serrno == syscall.ENOENT, serrno == syscall.ENXIO, serrno == syscall.ENODATA:
130131
// Since the implementation of sessions in systemd relies on
131132
// the `pam_systemd` module, using the sd_pid_get_owner_uid
132133
// heuristic alone can result in false positives if that module

0 commit comments

Comments
 (0)