]> git.ipfire.org Git - pakfire.git/blob - tools/quality-agent.d/002-bad-symlinks
Cleanup database and add indexes.
[pakfire.git] / tools / quality-agent.d / 002-bad-symlinks
1 #!/bin/bash
2
3 . $(dirname ${0})/qa-include
4
5 # Check for absolute symlinks.
6 # We do not allow them because they may point to any bad location.
7
8 log_debug "Search for absolute symlinks"
9
10 function check() {
11 local failed=0
12 local item
13
14 for link in $(find ${BUILDROOT} -type l); do
15 if fgrep -q "/lib/udev/devices" <<<${link}; then
16 continue
17 fi
18
19 if listmatch "${link:${#BUILDROOT}}" ${QUALITY_AGENT_WHITELIST_SYMLINK}; then
20 log INFO "Symlink ${link} is on the whitelist."
21 continue
22 fi
23
24 destination=$(readlink ${link})
25 if [ "${destination:0:1}" = "/" ]; then
26 log ERROR " Absolute symlink: ${link}"
27 failed=1
28 fi
29 if [ ! -e "${link%/*}/${destination}" ]; then
30 log ERROR " Not existant destination: ${link} -> ${destination}"
31 failed=1
32 fi
33 done
34
35 return ${failed}
36 }
37
38 run
39