Skip to content

Commit

Permalink
Revert "DupSecOpt needs to match InitLabels"
Browse files Browse the repository at this point in the history
This reverts commit 491cada.
  • Loading branch information
runcom committed Jan 29, 2017
1 parent 6c22e77 commit d4f4ead
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
18 changes: 7 additions & 11 deletions libcontainer/label/label_selinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@ func InitLabels(options []string) (string, string, error) {
pcon := selinux.NewContext(processLabel)
mcon := selinux.NewContext(mountLabel)
for _, opt := range options {
val := strings.SplitN(opt, "=", 2)
if val[0] != "label" {
continue
}
if len(val) < 2 {
return "", "", fmt.Errorf("bad label option %q, valid options 'disable' or \n'user, role, level, type' followed by ':' and a value", opt)
}
if val[1] == "disable" {
if opt == "disable" {
return "", "", nil
}
con := strings.SplitN(val[1], ":", 2)
if len(con) < 2 || !validOptions[con[0]] {
return "", "", fmt.Errorf("bad label option %q, valid options 'disable, user, role, level, type'", con[0])
if i := strings.Index(opt, ":"); i == -1 {
return "", "", fmt.Errorf("Bad label option %q, valid options 'disable' or \n'user, role, level, type' followed by ':' and a value", opt)
}
con := strings.SplitN(opt, ":", 2)
if !validOptions[con[0]] {
return "", "", fmt.Errorf("Bad label option %q, valid options 'disable, user, role, level, type'", con[0])

}
pcon[con[0]] = con[1]
Expand Down
8 changes: 4 additions & 4 deletions libcontainer/label/label_selinux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestInit(t *testing.T) {
t.Log("InitLabels Failed")
t.Fatal(err)
}
testDisabled := []string{"label=disable"}
testDisabled := []string{"disable"}
roMountLabel := GetROMountLabel()
if roMountLabel == "" {
t.Errorf("GetROMountLabel Failed")
Expand All @@ -32,7 +32,7 @@ func TestInit(t *testing.T) {
t.Log("InitLabels Disabled Failed")
t.FailNow()
}
testUser := []string{"label=user:user_u", "label=role:user_r", "label=type:user_t", "label=level:s0:c1,c15"}
testUser := []string{"user:user_u", "role:user_r", "type:user_t", "level:s0:c1,c15"}
plabel, mlabel, err = InitLabels(testUser)
if err != nil {
t.Log("InitLabels User Failed")
Expand All @@ -44,7 +44,7 @@ func TestInit(t *testing.T) {
t.Fatal(err)
}

testBadData := []string{"label=user", "label=role:user_r", "label=type:user_t", "label=level:s0:c1,c15"}
testBadData := []string{"user", "role:user_r", "type:user_t", "level:s0:c1,c15"}
if _, _, err = InitLabels(testBadData); err == nil {
t.Log("InitLabels Bad Failed")
t.Fatal(err)
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestRelabel(t *testing.T) {
t.Fatal(err)
}
defer os.RemoveAll(testdir)
label := "system_u:object_r:svirt_sandbox_file_t:s0:c1,c2"
label := "system_u:system_r:svirt_sandbox_file_t:s0:c1,c2"
if err := Relabel(testdir, "", true); err != nil {
t.Fatalf("Relabel with no label failed: %v", err)
}
Expand Down

0 comments on commit d4f4ead

Please sign in to comment.