mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #3559 from kolyshkin/fix-dev-pts
Fix failed exec after systemctl daemon-reload
This commit is contained in:
@@ -128,14 +128,16 @@ func systemdProperties(r *configs.Resources) ([]systemdDbus.Property, error) {
|
|||||||
case devices.CharDevice:
|
case devices.CharDevice:
|
||||||
entry.Path = fmt.Sprintf("/dev/char/%d:%d", rule.Major, rule.Minor)
|
entry.Path = fmt.Sprintf("/dev/char/%d:%d", rule.Major, rule.Minor)
|
||||||
}
|
}
|
||||||
|
// 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 {
|
||||||
|
logrus.Debugf("skipping device %s for systemd: %s", entry.Path, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// systemd will issue a warning if the path we give here doesn't exist.
|
deviceAllowList = append(deviceAllowList, entry)
|
||||||
// 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))
|
properties = append(properties, newProp("DeviceAllow", deviceAllowList))
|
||||||
|
|||||||
@@ -128,3 +128,19 @@ function teardown() {
|
|||||||
runc exec test_allow_block sh -c 'fdisk -l '"$device"''
|
runc exec test_allow_block sh -c 'fdisk -l '"$device"''
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# https://github.com/opencontainers/runc/issues/3551
|
||||||
|
@test "runc exec vs systemctl daemon-reload" {
|
||||||
|
requires systemd root
|
||||||
|
|
||||||
|
runc run -d --console-socket "$CONSOLE_SOCKET" test_exec
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
runc exec -t test_exec sh -c "ls -l /proc/self/fd/0; echo 123"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
runc exec -t test_exec sh -c "ls -l /proc/self/fd/0; echo 123"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user