@@ -18,18 +18,6 @@ import (
18
18
19
19
var generateFlags = []cli.Flag {
20
20
cli.StringSliceFlag {Name : "args" , Usage : "command to run in the container" },
21
- << << << < 9e0 e42dbf918070406a2a4a2e1476e7350ba9129
22
- == == == =
23
- cli.StringSliceFlag {Name : "bind" , Usage : "bind mount directories src:dest[:options...]" },
24
- cli.StringSliceFlag {Name : "cap-add" , Usage : "add Linux capabilities" },
25
- cli.StringSliceFlag {Name : "cap-drop" , Usage : "drop Linux capabilities" },
26
- cli.StringFlag {Name : "cgroup" , Usage : "cgroup namespace" },
27
- cli.StringFlag {Name : "cgroups-path" , Usage : "specify the path to the cgroups" },
28
- cli.StringFlag {Name : "cwd" , Value : "/" , Usage : "current working directory for the process" },
29
- cli.StringSliceFlag {Name : "device-access-add" , Usage : "add a device access rule" },
30
- cli.StringSliceFlag {Name : "device-access-remove" , Usage : "remove a device access rule" },
31
- cli.BoolFlag {Name : "disable-oom-kill" , Usage : "disable OOM Killer" },
32
- >> >> >> > generate : add - - device - access - add and - - device - access - remove option
33
21
cli.StringSliceFlag {Name : "env" , Usage : "add environment variable e.g. key=value" },
34
22
cli.StringSliceFlag {Name : "env-file" , Usage : "read in a file of environment variables" },
35
23
cli.StringSliceFlag {Name : "hooks-poststart" , Usage : "set command to run in poststart hooks" },
@@ -75,6 +63,8 @@ var generateFlags = []cli.Flag{
75
63
cli.StringSliceFlag {Name : "linux-readonly-paths" , Usage : "specifies paths readonly inside container" },
76
64
cli.Int64Flag {Name : "linux-realtime-period" , Usage : "CPU period to be used for realtime scheduling (in usecs)" },
77
65
cli.Int64Flag {Name : "linux-realtime-runtime" , Usage : "the time realtime scheduling may use (in usecs)" },
66
+ cli.StringSliceFlag {Name : "linux-resources-device-add" , Usage : "add a device access rule" },
67
+ cli.StringSliceFlag {Name : "linux-resources-device-remove" , Usage : "remove a device access rule" },
78
68
cli.StringFlag {Name : "linux-rootfs-propagation" , Usage : "mount propagation for rootfs" },
79
69
cli.StringFlag {Name : "linux-seccomp-allow" , Usage : "specifies syscalls to respond with allow" },
80
70
cli.StringFlag {Name : "linux-seccomp-arch" , Usage : "specifies additional architectures permitted to be used for system calls" },
@@ -246,12 +236,15 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
246
236
g .SetLinuxCgroupsPath (context .String ("linux-cgroups-path" ))
247
237
}
248
238
249
- << << << < 9e0 e42dbf918070406a2a4a2e1476e7350ba9129
250
239
if context .IsSet ("linux-masked-paths" ) {
251
240
paths := context .StringSlice ("linux-masked-paths" )
252
- == == == =
253
- if context .IsSet ("device-access-add" ) {
254
- devices := context .StringSlice ("device-access-add" )
241
+ for _ , path := range paths {
242
+ g .AddLinuxMaskedPaths (path )
243
+ }
244
+ }
245
+
246
+ if context .IsSet ("linux-resources-device-add" ) {
247
+ devices := context .StringSlice ("linux-resources-device-add" )
255
248
for _ , device := range devices {
256
249
dev , err := parseLinuxResourcesDeviceAccess (device , g )
257
250
if err != nil {
@@ -261,8 +254,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
261
254
}
262
255
}
263
256
264
- if context .IsSet ("device-access -remove" ) {
265
- devices := context .StringSlice ("device-access -remove" )
257
+ if context .IsSet ("linux-resources-device -remove" ) {
258
+ devices := context .StringSlice ("linux-resources-device -remove" )
266
259
for _ , device := range devices {
267
260
dev , err := parseLinuxResourcesDeviceAccess (device , g )
268
261
if err != nil {
@@ -272,14 +265,6 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
272
265
}
273
266
}
274
267
275
- if context .IsSet ("masked-paths" ) {
276
- paths := context .StringSlice ("masked-paths" )
277
- >> >> >> > generate: add -- device - access - add and -- device - access - remove option
278
- for _ , path := range paths {
279
- g .AddLinuxMaskedPaths (path )
280
- }
281
- }
282
-
283
268
if context .IsSet ("linux-readonly-paths" ) {
284
269
paths := context .StringSlice ("linux-readonly-paths" )
285
270
for _ , path := range paths {
@@ -850,7 +835,6 @@ func parseRlimit(rlimit string) (string, uint64, uint64, error) {
850
835
return parts [0 ], uint64 (hard ), uint64 (soft ), nil
851
836
}
852
837
853
- << << << < 9e0 e42dbf918070406a2a4a2e1476e7350ba9129
854
838
func parseNamespace (ns string ) (string , string , error ) {
855
839
parts := strings .SplitN (ns , ":" , 2 )
856
840
if len (parts ) == 0 || parts [0 ] == "" {
@@ -944,7 +928,8 @@ func parseDevice(device string, g *generate.Generator) (rspec.LinuxDevice, error
944
928
}
945
929
946
930
return dev , nil
947
- == == == =
931
+ }
932
+
948
933
var cgroupDeviceType = map [string ]bool {
949
934
"a" : true , // all
950
935
"b" : true , // block device
@@ -957,9 +942,9 @@ var cgroupDeviceAccess = map[string]bool{
957
942
}
958
943
959
944
// parseLinuxResourcesDeviceAccess parses the raw string passed with the --device-access-add flag
960
- func parseLinuxResourcesDeviceAccess (device string , g * generate.Generator ) (rspec.DeviceCgroup , error ) {
945
+ func parseLinuxResourcesDeviceAccess (device string , g * generate.Generator ) (rspec.LinuxDeviceCgroup , error ) {
961
946
var allow bool
962
- var devType , access * string
947
+ var devType , access string
963
948
var major , minor * int64
964
949
965
950
argsParts := strings .Split (device , "," )
@@ -970,7 +955,7 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
970
955
case "deny" :
971
956
allow = false
972
957
default :
973
- return rspec.DeviceCgroup {},
958
+ return rspec.LinuxDeviceCgroup {},
974
959
fmt .Errorf ("Only 'allow' and 'deny' are allowed in the first field of device-access-add: %s" , device )
975
960
}
976
961
@@ -981,45 +966,44 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
981
966
}
982
967
parts := strings .SplitN (s , "=" , 2 )
983
968
if len (parts ) != 2 {
984
- return rspec.DeviceCgroup {}, fmt .Errorf ("Incomplete device-access-add arguments: %s" , s )
969
+ return rspec.LinuxDeviceCgroup {}, fmt .Errorf ("Incomplete device-access-add arguments: %s" , s )
985
970
}
986
971
name , value := parts [0 ], parts [1 ]
987
972
988
973
switch name {
989
974
case "type" :
990
975
if ! cgroupDeviceType [value ] {
991
- return rspec.DeviceCgroup {}, fmt .Errorf ("Invalid device type in device-access-add: %s" , value )
976
+ return rspec.LinuxDeviceCgroup {}, fmt .Errorf ("Invalid device type in device-access-add: %s" , value )
992
977
}
993
- devType = & value
978
+ devType = value
994
979
case "major" :
995
980
i , err := strconv .ParseInt (value , 10 , 64 )
996
981
if err != nil {
997
- return rspec.DeviceCgroup {}, err
982
+ return rspec.LinuxDeviceCgroup {}, err
998
983
}
999
984
major = & i
1000
985
case "minor" :
1001
986
i , err := strconv .ParseInt (value , 10 , 64 )
1002
987
if err != nil {
1003
- return rspec.DeviceCgroup {}, err
988
+ return rspec.LinuxDeviceCgroup {}, err
1004
989
}
1005
990
minor = & i
1006
991
case "access" :
1007
992
for _ , c := range strings .Split (value , "" ) {
1008
993
if ! cgroupDeviceAccess [c ] {
1009
- return rspec.DeviceCgroup {}, fmt .Errorf ("Invalid device access in device-access-add: %s" , c )
994
+ return rspec.LinuxDeviceCgroup {}, fmt .Errorf ("Invalid device access in device-access-add: %s" , c )
1010
995
}
1011
996
}
1012
- access = & value
997
+ access = value
1013
998
}
1014
999
}
1015
- return rspec.DeviceCgroup {
1000
+ return rspec.LinuxDeviceCgroup {
1016
1001
Allow : allow ,
1017
1002
Type : devType ,
1018
1003
Major : major ,
1019
1004
Minor : minor ,
1020
1005
Access : access ,
1021
1006
}, nil
1022
- >> >> >> > generate: add -- device - access - add and -- device - access - remove option
1023
1007
}
1024
1008
1025
1009
func addSeccomp (context * cli.Context , g * generate.Generator ) error {
0 commit comments