Skip to content

Commit 5f5d954

Browse files
committed
add selinux category range to config
This allows an admin to set the upper bounds on the category range for selinux labels. This can be useful when handling allocation of PVs or other volume types that need to be shared with selinux enabled on the hosts and volumes. Signed-off-by: Michael Crosby <[email protected]>
1 parent 9b06da4 commit 5f5d954

5 files changed

Lines changed: 18 additions & 7 deletions

File tree

docs/config.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ version = 2
3535
# enable_selinux indicates to enable the selinux support.
3636
enable_selinux = false
3737

38+
# selinux_category_range allows the upper bound on the category range to be set.
39+
# if not specified or set to 0, defaults to 1024 from the selinux package.
40+
selinux_category_range = 1024
41+
3842
# sandbox_image is the image used by sandbox container.
3943
sandbox_image = "k8s.gcr.io/pause:3.2"
4044

pkg/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ type PluginConfig struct {
198198
StreamIdleTimeout string `toml:"stream_idle_timeout" json:"streamIdleTimeout"`
199199
// EnableSelinux indicates to enable the selinux support.
200200
EnableSelinux bool `toml:"enable_selinux" json:"enableSelinux"`
201+
// SelinuxCategoryRange allows the upper bound on the category range to be set.
202+
// If not specified or set to 0, defaults to 1024 from the selinux package.
203+
SelinuxCategoryRange int `toml:"selinux_category_range" json:"selinuxCategoryRange"`
201204
// SandboxImage is the image used by sandbox container.
202205
SandboxImage string `toml:"sandbox_image" json:"sandboxImage"`
203206
// StatsCollectPeriod is the period (in seconds) of snapshots stats collection.

pkg/config/config_unix.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ func DefaultConfig() PluginConfig {
4444
},
4545
},
4646
},
47-
DisableTCPService: true,
48-
StreamServerAddress: "127.0.0.1",
49-
StreamServerPort: "0",
50-
StreamIdleTimeout: streaming.DefaultConfig.StreamIdleTimeout.String(), // 4 hour
51-
EnableSelinux: false,
52-
EnableTLSStreaming: false,
47+
DisableTCPService: true,
48+
StreamServerAddress: "127.0.0.1",
49+
StreamServerPort: "0",
50+
StreamIdleTimeout: streaming.DefaultConfig.StreamIdleTimeout.String(), // 4 hour
51+
EnableSelinux: false,
52+
SelinuxCategoryRange: 1024,
53+
EnableTLSStreaming: false,
5354
X509KeyPairStreaming: X509KeyPairStreaming{
5455
TLSKeyFile: "",
5556
TLSCertFile: "",

pkg/server/service_unix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func (c *criService) initPlatform() error {
4444
if !selinux.GetEnabled() {
4545
logrus.Warn("Selinux is not supported")
4646
}
47+
if r := c.config.SelinuxCategoryRange; r > 0 {
48+
selinux.CategoryRange = uint32(r)
49+
}
4750
} else {
4851
selinux.SetDisabled()
4952
}

vendor.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# cri dependencies
22
github.com/docker/docker 4634ce647cf2ce2c6031129ccd109e557244986f
33
github.com/opencontainers/selinux v1.6.0
4-
github.com/willf/bitset d5bec3311243426a3c6d1b7a795f24b17c686dbb # 1.1.10+ used by selinux pkg
54
github.com/tchap/go-patricia v2.2.6
5+
github.com/willf/bitset d5bec3311243426a3c6d1b7a795f24b17c686dbb # 1.1.10+ used by selinux pkg
66

77
# containerd dependencies
88
github.com/beorn7/perks v1.0.1

0 commit comments

Comments
 (0)