|
@@ -33,19 +33,15 @@ func InitLabels(options []string) (string, string, error) {
|
|
pcon := selinux.NewContext(processLabel)
|
|
pcon := selinux.NewContext(processLabel)
|
|
mcon := selinux.NewContext(mountLabel)
|
|
mcon := selinux.NewContext(mountLabel)
|
|
for _, opt := range options {
|
|
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
|
|
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]
|
|
pcon[con[0]] = con[1]
|