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
6 changes: 3 additions & 3 deletions private/util/validate_usr_symlinks.awk
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ BEGIN {
{
original_path = $1
path = original_path
# Normalize: strip leading ./ or /
sub(/^\.\//, "", path)
sub(/^\//, "", path)
# Normalize: strip any combination of leading ./ and /
# This ensures ./bin, /bin, bin, and even //bin are treated the same.
sub(/^(\.\/|\/)+/, "", path)

if (path in expected) {
if ($0 !~ /type=link/) {
Expand Down
15 changes: 15 additions & 0 deletions private/util/validate_usr_symlinks_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,20 @@ run "./lib64 type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/lib64
./usr/bin/ls type=file mode=0755 nlink=1 uid=0 gid=0 size=12345" \
|| fail "content under ./usr/ alongside valid symlinks should pass"

run "/home/user/bin type=dir mode=0755 nlink=2 uid=1000 gid=1000" \
|| fail "deep paths containing 'bin' should pass"

# --- failing cases ---

run "./bin type=dir mode=0755 nlink=2 uid=0 gid=0" \
&& fail "./bin as a directory should fail" || true

run "//bin type=dir mode=0755 nlink=2 uid=0 gid=0" \
&& fail "//bin as a directory should fail" || true

run "././bin type=dir mode=0755 nlink=2 uid=0 gid=0" \
&& fail "././bin as a directory should fail" || true

run "./bin type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/sbin" \
&& fail "./bin -> usr/sbin should fail" || true

Expand All @@ -57,6 +66,12 @@ run "bin type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/fin" \
run "/bin type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/fin" \
&& fail "/bin -> usr/fin should fail" || true

run "//bin type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/fin" \
&& fail "//bin -> usr/fin should fail" || true

run "././bin type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/fin" \
&& fail "././bin -> usr/fin should fail" || true

run "./sbin type=link mode=0777 nlink=1 uid=0 gid=0 link=usr/bin" \
&& fail "./sbin -> usr/bin should fail (Debian keeps sbin separate)" || true

Expand Down
Loading