This file is indexed.

/usr/bin/draw_lib_dependencies is in kdesdk-scripts 4:17.12.3-0ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash

# Copyright 2013 Dominik Seichter <domseichter@googlemail.com>
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of 
# the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
# This is the maximum depth to which dependencies are resolved
MAXDEPTH=14

TMPFILE=
READELFTMPFILE=
LDDTMPFILE=

cleanup() {
	for _v in TMPFILE READELFTMPFILE LDDTMPFILE; do
		[ -n "${!_v}" ] && rm -f -- "${!_v}"
	done
}

trap cleanup EXIT
 
# analyze a given file on its
# dependecies using ldd and write
# the results to a given temporary file
#
# Usage: analyze [OUTPUTFILE] [INPUTFILE]
analyze()
{
    local OUT="$1"
    local IN="$2"
    local NAME=$(basename "$IN")
 
    for i in $LIST
    do
        if [ X"$i" == X"$NAME" ];
        then
            # This file was already parsed
            return
        fi
    done
    # Put the file in the list of all files
    LIST="$LIST $NAME"
 
    DEPTH=$(($DEPTH + 1))
    if [ $DEPTH -ge $MAXDEPTH ];
        then
        echo "MAXDEPTH of $MAXDEPTH reached at file $IN."
        echo "Continuing with next file..."
        DEPTH=$(($DEPTH - 1))
        return
    fi
 
    echo "Parsing file:              $IN"
 
    $READELF "$IN" > "$READELFTMPFILE" 2>&1
    ELFRET=$?
 
    if [ $ELFRET != 0 ];
        then
        echo "ERROR: ELF reader returned error code $RET"
        echo "ERROR:"
        cat -v -- "$TMPFILE"
        echo "Aborting..."
        exit 1
    fi
 
    DEPENDENCIES=$(cat "$READELFTMPFILE" | grep NEEDED | awk '{if (substr($NF,1,1) == "[") print substr($NF, 2, length($NF) - 2); else print $NF}')
 
    for DEP in $DEPENDENCIES;
    do
        if [ -n "$DEP" ];
        then
 
            # XXX Change ldd to something more secure?
            ldd "$IN" > "$LDDTMPFILE" 2>&1
            LDDRET=$?
 
            if [ $LDDRET != 0 ];
                then
                echo "ERROR: ldd returned error code $RET"
                echo "ERROR:"
                cat -v -- "$TMPFILE"
                echo "Aborting..."
                exit 1
            fi
 
            DEPPATH=$(grep -- "$DEP" "$LDDTMPFILE" | awk '{print $3}')
            if [ -n "$DEPPATH" ];
            then
                echo "  \"$NAME\" -> \"$DEP\";" >> $OUT
                analyze "$OUT" "$DEPPATH"
            fi
        fi
    done
 
    DEPTH=$(($DEPTH - 1))
}
 
########################################
# main                                 #
########################################
 
if [ $# != 2 ];
    then
    echo "Usage:"
    echo "  $0 [filename] [outputimage]"
    echo ""
    echo "This tools analyses a shared library or an executable"
    echo "and generates a dependency graph as an image."
    echo ""
    echo "GraphViz must be installed for this tool to work."
    echo ""
    exit 1
fi
 
DEPTH=0
INPUT="$1"
OUTPUT="$2"
TMPFILE="$(mktemp -t)"
LDDTMPFILE="$(mktemp -t)"
READELFTMPFILE="$(mktemp -t)"
LIST=""
 
if [ ! -e "$INPUT" ];
    then
    echo "ERROR: File not found: $INPUT"
    echo "Aborting..."
    exit 2
fi
 
# Use either readelf or dump
# Linux has readelf, Solaris has dump
READELF=$(type readelf 2> /dev/null)
if [ $? != 0 ]; then
  READELF=$(type dump 2> /dev/null)
  if [ $? != 0 ]; then
    echo Unable to find ELF reader
    exit 1
  fi
  READELF="dump -Lv"
else
  READELF="readelf -d"
fi
 
 
 
echo "Analyzing dependencies of: $INPUT"
echo "Creating output as:        $OUTPUT"
echo ""
 
echo "digraph DependencyTree {" > "$TMPFILE"
echo "  \"$(basename $INPUT)\" [shape=box];" >> "$TMPFILE"
analyze "$TMPFILE" "$INPUT"
echo "}" >> "$TMPFILE"
 
#cat $TMPFILE # output generated dotfile for debugging purposses
dot -Tpng "$TMPFILE" "-o$OUTPUT"
 
exit 0