Skip to content

Commit 30a122d

Browse files
author
Mrunal Patel
authored
Merge pull request #1112 from rhatdan/romount
Add support for r/o mount labels
2 parents 4dcc046 + 6932807 commit 30a122d

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

libcontainer/label/label.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ func InitLabels(options []string) (string, string, error) {
99
return "", "", nil
1010
}
1111

12+
func GetROMountLabel() string {
13+
return ""
14+
}
15+
1216
func GenLabels(options string) (string, string, error) {
1317
return "", "", nil
1418
}

libcontainer/label/label_selinux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func InitLabels(options []string) (string, string, error) {
5959
return processLabel, mountLabel, nil
6060
}
6161

62+
func GetROMountLabel() string {
63+
return selinux.GetROFileLabel()
64+
}
65+
6266
// DEPRECATED: The GenLabels function is only to be used during the transition to the official API.
6367
func GenLabels(options string) (string, string, error) {
6468
return InitLabels(strings.Fields(options))

libcontainer/label/label_selinux_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func TestInit(t *testing.T) {
1919
t.Fatal(err)
2020
}
2121
testDisabled := []string{"label=disable"}
22+
roMountLabel := GetROMountLabel()
23+
if roMountLabel == "" {
24+
t.Errorf("GetROMountLabel Failed")
25+
}
2226
plabel, mlabel, err = InitLabels(testDisabled)
2327
if err != nil {
2428
t.Log("InitLabels Disabled Failed")

libcontainer/selinux/selinux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ func FreeLxcContexts(scon string) {
355355
}
356356
}
357357

358+
var roFileLabel string
359+
360+
func GetROFileLabel() (fileLabel string) {
361+
return roFileLabel
362+
}
363+
358364
func GetLxcContexts() (processLabel string, fileLabel string) {
359365
var (
360366
val, key string
@@ -399,13 +405,19 @@ func GetLxcContexts() (processLabel string, fileLabel string) {
399405
if key == "file" {
400406
fileLabel = strings.Trim(val, "\"")
401407
}
408+
if key == "ro_file" {
409+
roFileLabel = strings.Trim(val, "\"")
410+
}
402411
}
403412
}
404413

405414
if processLabel == "" || fileLabel == "" {
406415
return "", ""
407416
}
408417

418+
if roFileLabel == "" {
419+
roFileLabel = fileLabel
420+
}
409421
exit:
410422
// mcs := IntToMcs(os.Getpid(), 1024)
411423
mcs := uniqMcs(1024)

0 commit comments

Comments
 (0)