Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,9 +792,10 @@ func usrmergeLinter(ctx context.Context, _ *config.Configuration, _ string, fsys

// We don't really care if a package is re-adding a symlink and this catches wolfi-baselayout
// without special casing it with the package name.
if path == "sbin" || path == "bin" || path == "usr/sbin" {
symlinked := []string{"sbin", "bin", "usr/sbin", "lib64", "usr/lib64"}
if slices.Contains(symlinked, path) {
if d.IsDir() || d.Type().IsRegular() {
return fmt.Errorf("package contains non-symlink file at /sbin, /bin or /usr/sbin in violation of usrmerge")
return fmt.Errorf("package contains non-symlink file at /sbin, /bin, /usr/sbin, /lib64 or /usr/lib64 in violation of usrmerge")
} else {
return nil
}
Expand All @@ -811,6 +812,12 @@ func usrmergeLinter(ctx context.Context, _ *config.Configuration, _ string, fsys
if strings.HasPrefix(path, "usr/sbin") {
return fmt.Errorf("package writes to /usr/sbin in violation of usrmerge: %s", path)
}
if strings.HasPrefix(path, "lib64") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be refactored to for _, symlink := range symlinked; [...] now

return fmt.Errorf("package writes to /lib64 in violation of usrmerge, use /lib: %s", path)
}
if strings.HasPrefix(path, "usr/lib64") {
return fmt.Errorf("package writes to /usr/lib64 in violation of usrmerge, use /usr/lib: %s", path)
}

return nil
})
Expand Down
8 changes: 8 additions & 0 deletions pkg/linter/linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ func TestLinters(t *testing.T) {
dirFunc: mkfile(t, "usr/sbin"),
linter: "usrmerge",
pass: false,
}, {
dirFunc: mkfile(t, "lib64/ld-linux.so"),
linter: "usrmerge",
pass: false,
}, {
dirFunc: mkfile(t, "usr/lib64/ld.so"),
linter: "usrmerge",
pass: false,
}, {
dirFunc: func() string {
d := t.TempDir()
Expand Down
Loading