Skip to content

Commit 974efd2

Browse files
authored
Merge pull request #3620 from lab47/b-remove-udev-dep
[1.1] Fixes inability to use /dev/null when inside a container
2 parents 28fa513 + 3b95828 commit 974efd2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

libcontainer/cgroups/systemd/common.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,18 @@ func generateDeviceProperties(r *configs.Resources) ([]systemdDbus.Property, err
293293
// rules separately to systemd) we can safely skip entries that don't
294294
// have a corresponding path.
295295
if _, err := os.Stat(entry.Path); err != nil {
296-
logrus.Debugf("skipping device %s for systemd: %s", entry.Path, err)
297-
continue
296+
// Also check /sys/dev so that we don't depend on /dev/{block,char}
297+
// being populated. (/dev/{block,char} is populated by udev, which
298+
// isn't strictly required for systemd). Ironically, this happens most
299+
// easily when starting containerd within a runc created container
300+
// itself.
301+
302+
// We don't bother with securejoin here because we create entry.Path
303+
// right above here, so we know it's safe.
304+
if _, err := os.Stat("/sys" + entry.Path); err != nil {
305+
logrus.Warnf("skipping device %s for systemd: %s", entry.Path, err)
306+
continue
307+
}
298308
}
299309
}
300310
deviceAllowList = append(deviceAllowList, entry)

0 commit comments

Comments
 (0)