Skip to content

Commit 00d547f

Browse files
authored
Merge pull request #180 from rhatdan/relabel1
Allow relabeling of files/directories under /usr prefix
2 parents 4a3908c + d3ccb69 commit 00d547f

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

go-selinux/selinux_linux.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,21 +1072,6 @@ func copyLevel(src, dest string) (string, error) {
10721072
return tcon.Get(), nil
10731073
}
10741074

1075-
// Prevent users from relabeling system files
1076-
func badPrefix(fpath string) error {
1077-
if fpath == "" {
1078-
return ErrEmptyPath
1079-
}
1080-
1081-
badPrefixes := []string{"/usr"}
1082-
for _, prefix := range badPrefixes {
1083-
if strings.HasPrefix(fpath, prefix) {
1084-
return fmt.Errorf("relabeling content in %s is not allowed", prefix)
1085-
}
1086-
}
1087-
return nil
1088-
}
1089-
10901075
// chcon changes the fpath file object to the SELinux label label.
10911076
// If fpath is a directory and recurse is true, then chcon walks the
10921077
// directory tree setting the label.
@@ -1097,9 +1082,6 @@ func chcon(fpath string, label string, recurse bool) error {
10971082
if label == "" {
10981083
return nil
10991084
}
1100-
if err := badPrefix(fpath); err != nil {
1101-
return err
1102-
}
11031085

11041086
if !recurse {
11051087
return setFileLabel(fpath, label)

0 commit comments

Comments
 (0)