@@ -94,6 +94,8 @@ type JailerConfig struct {
94
94
Stdout io.Writer
95
95
// Stderr specifies the IO writer for STDERR to use when spawning the jailer.
96
96
Stderr io.Writer
97
+ // Stdin specifies the IO reader for STDIN to use when spawning the jailer.
98
+ Stdin io.Reader
97
99
}
98
100
99
101
// JailerCommandBuilder will build a jailer command. This can be used to
@@ -288,14 +290,14 @@ func (b JailerCommandBuilder) Build(ctx context.Context) *exec.Cmd {
288
290
// Jail will set up proper handlers and remove configuration validation due to
289
291
// stating of files
290
292
func jail (ctx context.Context , m * Machine , cfg * Config ) error {
291
- rootfs := ""
293
+ jailerWorkspaceDir := ""
292
294
if len (cfg .JailerCfg .ChrootBaseDir ) > 0 {
293
- rootfs = filepath .Join (cfg .JailerCfg .ChrootBaseDir , "firecracker" , cfg .JailerCfg .ID )
295
+ jailerWorkspaceDir = filepath .Join (cfg .JailerCfg .ChrootBaseDir , "firecracker" , cfg .JailerCfg .ID , rootfsFolderName )
294
296
} else {
295
- rootfs = filepath .Join (defaultJailerPath , cfg .JailerCfg .ID )
297
+ jailerWorkspaceDir = filepath .Join (defaultJailerPath , cfg .JailerCfg .ID , rootfsFolderName )
296
298
}
297
299
298
- cfg .SocketPath = filepath .Join (rootfs , "api.socket" )
300
+ cfg .SocketPath = filepath .Join (jailerWorkspaceDir , "api.socket" )
299
301
300
302
stdout := cfg .JailerCfg .Stdout
301
303
if stdout == nil {
@@ -307,6 +309,11 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
307
309
stderr = os .Stderr
308
310
}
309
311
312
+ stdin := cfg .JailerCfg .Stdin
313
+ if stdin == nil {
314
+ stdin = os .Stdin
315
+ }
316
+
310
317
m .cmd = NewJailerCommandBuilder ().
311
318
WithID (cfg .JailerCfg .ID ).
312
319
WithUID (* cfg .JailerCfg .UID ).
@@ -318,6 +325,7 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
318
325
WithSeccompLevel (cfg .JailerCfg .SeccompLevel ).
319
326
WithStdout (stdout ).
320
327
WithStderr (stderr ).
328
+ WithStdin (stdin ).
321
329
Build (ctx )
322
330
323
331
if err := cfg .JailerCfg .ChrootStrategy .AdaptHandlers (& m .Handlers ); err != nil {
0 commit comments