mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
Merge pull request #4636 from lifubang/fix-exec-timens
libct: don't send config to nsexec when joining an existing timens
This commit is contained in:
@@ -1146,8 +1146,9 @@ func (c *Container) bootstrapData(cloneFlags uintptr, nsMaps map[configs.Namespa
|
||||
Value: c.config.RootlessEUID,
|
||||
})
|
||||
|
||||
// write boottime and monotonic time ns offsets.
|
||||
if c.config.TimeOffsets != nil {
|
||||
// write boottime and monotonic time ns offsets only when we are not joining an existing time ns
|
||||
_, joinExistingTime := nsMaps[configs.NEWTIME]
|
||||
if !joinExistingTime && c.config.TimeOffsets != nil {
|
||||
var offsetSpec bytes.Buffer
|
||||
for clock, offset := range c.config.TimeOffsets {
|
||||
fmt.Fprintf(&offsetSpec, "%s %d %d\n", clock, offset.Secs, offset.Nanosecs)
|
||||
|
||||
@@ -54,6 +54,26 @@ function teardown() {
|
||||
grep -E '^boottime\s+1337\s+3141519$' <<<"$output"
|
||||
}
|
||||
|
||||
# https://github.com/opencontainers/runc/issues/4635
|
||||
@test "runc exec [simple timens]" {
|
||||
requires timens
|
||||
|
||||
update_config '.process.args = ["sleep", "inf"]'
|
||||
update_config '.linux.namespaces += [{"type": "time"}]
|
||||
| .linux.timeOffsets = {
|
||||
"monotonic": { "secs": 7881, "nanosecs": 2718281 },
|
||||
"boottime": { "secs": 1337, "nanosecs": 3141519 }
|
||||
}'
|
||||
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
runc exec test_busybox cat /proc/self/timens_offsets
|
||||
[ "$status" -eq 0 ]
|
||||
grep -E '^monotonic\s+7881\s+2718281$' <<<"$output"
|
||||
grep -E '^boottime\s+1337\s+3141519$' <<<"$output"
|
||||
}
|
||||
|
||||
@test "runc run [simple timens + userns]" {
|
||||
requires root
|
||||
requires timens
|
||||
|
||||
Reference in New Issue
Block a user