Debian Codegraph @

src/functions/debug.sh

raw
1 #!/usr/bin/env bash
2 # shellcheck disable=SC2154
3 # these top lines are moved during build
4
5 debug_report() {
6 echo "***** Checksec debug *****"
7 failed=false
8 id
9 uname -a
10
11 echo "checksec version: ${SCRIPT_MAJOR}.${SCRIPT_MINOR}.${SCRIPT_REVISION} -- ${SCRIPT_VERSION}"
12
13 if [[ -f /etc/os-release ]]; then
14 # freedesktop.org and systemd
15 # shellcheck disable=SC1091
16 source /etc/os-release
17 # shellcheck disable=SC2153
18 OS=${NAME}
19 VER=${VERSION_ID}
20 elif type lsb_release > /dev/null 2>&1; then
21 # linuxbase.org
22 OS=$(lsb_release -si)
23 VER=$(lsb_release -sr)
24 elif [[ -f /etc/lsb-release ]]; then
25 # For some versions of Debian/Ubuntu without lsb_release command
26 # shellcheck disable=SC1091
27 source /etc/lsb-release
28 OS=${DISTRIB_ID}
29 VER=${DISTRIB_RELEASE}
30 elif [[ -f /etc/debian_version ]]; then
31 # Older Debian/Ubuntu/etc.
32 OS=Debian
33 VER=$(cat /etc/debian_version)
34 elif [[ -f /etc/SuSe-release ]]; then
35 # Older SuSE/etc.
36 OS=$(cat /etc/SuSe-release)
37 VER=$(uname -r)
38 elif [[ -f /etc/redhat-release ]]; then
39 # Older Red Hat, CentOS, etc.
40 OS=$(cat /etc/redhat-release)
41 VER=$(uname -r)
42 else
43 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
44 OS=$(uname -s)
45 VER=$(uname -r)
46 fi
47
48 echo "OS=${OS}"
49 echo "VER=${VER}"
50
51 for command in cat awk sysctl uname mktemp openssl grep stat file find head ps readlink basename id which wget curl readelf eu-readelf; do
52 path="$(command -v ${command})"
53 if [[ -e "${path}" ]]; then
54 ls -l "${path}"
55 if [[ -L "${path}" ]]; then
56 absolutepath=$(readlink -f "${path}")
57 ls -l "${absolutepath}"
58 file "${absolutepath}"
59 else
60 file "${path}"
61 fi
62 else
63 echo "*** can not find command ${command}"
64 failed=true
65 fi
66 done
67
68 if [[ ${failed} ]]; then
69 exit 1
70 fi
71 }