Skip to content

Commit

Permalink
Merge pull request opencontainers#3504 from cyphar/1.1-systemd-device…
Browse files Browse the repository at this point in the history
…s-nonexistent-files

[1.1] cgroups: systemd: skip adding device paths that don't exist
  • Loading branch information
thaJeztah authored Jun 8, 2022
2 parents da9b9d9 + 7219387 commit 5d74e0f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libcontainer/cgroups/systemd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ func generateDeviceProperties(r *configs.Resources) ([]systemdDbus.Property, err
entry.Path = fmt.Sprintf("/dev/char/%d:%d", rule.Major, rule.Minor)
}
}
deviceAllowList = append(deviceAllowList, entry)
// systemd will issue a warning if the path we give here doesn't exist.
// Since all of this logic is best-effort anyway (we manually set these
// rules separately to systemd) we can safely skip entries that don't
// have a corresponding path.
if _, err := os.Stat(entry.Path); err == nil {
deviceAllowList = append(deviceAllowList, entry)
}
}

properties = append(properties, newProp("DeviceAllow", deviceAllowList))
Expand Down

0 comments on commit 5d74e0f

Please sign in to comment.