@@ -26,7 +26,7 @@ import (
26
26
const (
27
27
// defaultJailerPath is the default chroot base directory that the jailer
28
28
// will use if no other base directory was provided.
29
- defaultJailerPath = "/srv/jailer/firecracker "
29
+ defaultJailerPath = "/srv/jailer"
30
30
defaultJailerBin = "jailer"
31
31
32
32
rootfsFolderName = "root"
38
38
ErrMissingJailerConfig = fmt .Errorf ("jailer config was not set for use" )
39
39
)
40
40
41
- // SeccompLevelValue represents a secure computing level type.
42
- type SeccompLevelValue int
43
-
44
- // secure computing levels
45
- const (
46
- // SeccompLevelDisable is the default value.
47
- SeccompLevelDisable SeccompLevelValue = iota
48
- // SeccompLevelBasic prohibits syscalls not whitelisted by Firecracker.
49
- SeccompLevelBasic
50
- // SeccompLevelAdvanced adds further checks on some of the parameters of the
51
- // allowed syscalls.
52
- SeccompLevelAdvanced
53
- )
54
-
55
41
// JailerConfig is jailer specific configuration needed to execute the jailer.
56
42
type JailerConfig struct {
57
43
// GID the jailer switches to as it execs the target binary.
@@ -90,15 +76,6 @@ type JailerConfig struct {
90
76
// STDERR to /dev/null
91
77
Daemonize bool
92
78
93
- // SeccompLevel specifies whether seccomp filters should be installed and how
94
- // restrictive they should be. Possible values are:
95
- //
96
- // 0 : (default): disabled.
97
- // 1 : basic filtering. This prohibits syscalls not whitelisted by Firecracker.
98
- // 2 : advanced filtering. This adds further checks on some of the
99
- // parameters of the allowed syscalls.
100
- SeccompLevel SeccompLevelValue
101
-
102
79
// ChrootStrategy will dictate how files are transfered to the root drive.
103
80
ChrootStrategy HandlersAdapter
104
81
@@ -121,10 +98,10 @@ type JailerCommandBuilder struct {
121
98
node int
122
99
123
100
// optional params
124
- chrootBaseDir string
125
- netNS string
126
- daemonize bool
127
- seccompLevel SeccompLevelValue
101
+ chrootBaseDir string
102
+ netNS string
103
+ daemonize bool
104
+ firecrackerArgs [] string
128
105
129
106
stdin io.Reader
130
107
stdout io.Writer
@@ -155,12 +132,15 @@ func (b JailerCommandBuilder) Args() []string {
155
132
args = append (args , "--netns" , b .netNS )
156
133
}
157
134
158
- args = append (args , "--seccomp-level" , strconv .Itoa (int (b .seccompLevel )))
159
-
160
135
if b .daemonize {
161
136
args = append (args , "--daemonize" )
162
137
}
163
138
139
+ if len (b .firecrackerArgs ) > 0 {
140
+ args = append (args , "--" )
141
+ args = append (args , b .firecrackerArgs ... )
142
+ }
143
+
164
144
return args
165
145
}
166
146
@@ -229,14 +209,6 @@ func (b JailerCommandBuilder) WithDaemonize(daemonize bool) JailerCommandBuilder
229
209
return b
230
210
}
231
211
232
- // WithSeccompLevel will set the provided level to the builder. This represents
233
- // the seccomp filters that should be installed and how restrictive they should
234
- // be.
235
- func (b JailerCommandBuilder ) WithSeccompLevel (level SeccompLevelValue ) JailerCommandBuilder {
236
- b .seccompLevel = level
237
- return b
238
- }
239
-
240
212
// Stdout will return the stdout that will be used when creating the
241
213
// firecracker exec.Command
242
214
func (b JailerCommandBuilder ) Stdout () io.Writer {
@@ -276,6 +248,13 @@ func (b JailerCommandBuilder) WithStdin(stdin io.Reader) JailerCommandBuilder {
276
248
return b
277
249
}
278
250
251
+ // WithFirecrackerArgs will adds these arguments to the end of the argument
252
+ // chain which the jailer will intepret to belonging to Firecracke
253
+ func (b JailerCommandBuilder ) WithFirecrackerArgs (args ... string ) JailerCommandBuilder {
254
+ b .firecrackerArgs = args
255
+ return b
256
+ }
257
+
279
258
// Build will build a jailer command.
280
259
func (b JailerCommandBuilder ) Build (ctx context.Context ) * exec.Cmd {
281
260
cmd := exec .CommandContext (
@@ -304,12 +283,12 @@ func (b JailerCommandBuilder) Build(ctx context.Context) *exec.Cmd {
304
283
func jail (ctx context.Context , m * Machine , cfg * Config ) error {
305
284
jailerWorkspaceDir := ""
306
285
if len (cfg .JailerCfg .ChrootBaseDir ) > 0 {
307
- jailerWorkspaceDir = filepath .Join (cfg .JailerCfg .ChrootBaseDir , "firecracker" , cfg .JailerCfg .ID , rootfsFolderName )
286
+ jailerWorkspaceDir = filepath .Join (cfg .JailerCfg .ChrootBaseDir , filepath . Base ( cfg . JailerCfg . ExecFile ) , cfg .JailerCfg .ID , rootfsFolderName )
308
287
} else {
309
- jailerWorkspaceDir = filepath .Join (defaultJailerPath , cfg .JailerCfg .ID , rootfsFolderName )
288
+ jailerWorkspaceDir = filepath .Join (defaultJailerPath , filepath . Base ( cfg . JailerCfg . ExecFile ), cfg .JailerCfg .ID , rootfsFolderName )
310
289
}
311
290
312
- cfg .SocketPath = filepath .Join (jailerWorkspaceDir , "api .socket" )
291
+ cfg .SocketPath = filepath .Join (jailerWorkspaceDir , "run" , "firecracker .socket" )
313
292
314
293
stdout := cfg .JailerCfg .Stdout
315
294
if stdout == nil {
@@ -329,7 +308,9 @@ func jail(ctx context.Context, m *Machine, cfg *Config) error {
329
308
WithExecFile (cfg .JailerCfg .ExecFile ).
330
309
WithChrootBaseDir (cfg .JailerCfg .ChrootBaseDir ).
331
310
WithDaemonize (cfg .JailerCfg .Daemonize ).
332
- WithSeccompLevel (cfg .JailerCfg .SeccompLevel ).
311
+ WithFirecrackerArgs (
312
+ "--seccomp-level" , cfg .SeccompLevel .String (),
313
+ ).
333
314
WithStdout (stdout ).
334
315
WithStderr (stderr )
335
316
0 commit comments