Skip to content

Commit 1d5f580

Browse files
jeromegnxibz
authored andcommitted
Fixes stdin default during jailing
Prior to this fix the SDK would use os.Stdin if no stdin was provided in the jailer config. This would cause shell sessions to break and should only include stdin if it was provided in the jailer config. Signed-off-by: xibz <[email protected]>
1 parent 69c9b07 commit 1d5f580

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

jailer.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,7 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
309309
stderr = os.Stderr
310310
}
311311

312-
stdin := cfg.JailerCfg.Stdin
313-
if stdin == nil {
314-
stdin = os.Stdin
315-
}
316-
317-
m.cmd = NewJailerCommandBuilder().
312+
builder := NewJailerCommandBuilder().
318313
WithID(cfg.JailerCfg.ID).
319314
WithUID(*cfg.JailerCfg.UID).
320315
WithGID(*cfg.JailerCfg.GID).
@@ -324,9 +319,13 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
324319
WithDaemonize(cfg.JailerCfg.Daemonize).
325320
WithSeccompLevel(cfg.JailerCfg.SeccompLevel).
326321
WithStdout(stdout).
327-
WithStderr(stderr).
328-
WithStdin(stdin).
329-
Build(ctx)
322+
WithStderr(stderr)
323+
324+
if stdin := cfg.JailerCfg.Stdin; stdin != nil {
325+
builder.WithStdin(stdin)
326+
}
327+
328+
m.cmd = builder.Build(ctx)
330329

331330
if err := cfg.JailerCfg.ChrootStrategy.AdaptHandlers(&m.Handlers); err != nil {
332331
return err

0 commit comments

Comments
 (0)