Skip to content

Commit

Permalink
Path + Return code (niklasb#27)
Browse files Browse the repository at this point in the history
* Change a message with the right path

Indeed, the script is position independant, thus `./db` is not always
the path to the db.

* Add return codes

It allows automatic tests and, if everything is find, to reproduce 22ad329
  • Loading branch information
ajabep authored Sep 1, 2020
1 parent 78e47c3 commit d69f04c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/libc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ index_libc() {
check_id() {
local id=$1
if [[ -e db/${id}.info ]]; then
echo " -> Already have this version, 'rm db/${id}.*' to force"
echo " -> Already have this version, 'rm ${PWD}/db/${id}.*' to force"
return 1
fi
return 0
Expand Down Expand Up @@ -119,6 +119,7 @@ get_all_debian() {
for f in `wget $url/ -O - 2>/dev/null | grep -Eoh 'libc6(-i386|-amd64)?_[^"]*(amd64|i386)\.deb' |grep -v "</a>"`; do
get_debian $url/$f $1
done
return 0
}

requirements_debian() {
Expand Down
3 changes: 3 additions & 0 deletions dump
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
cd "$(dirname "$0")"
. common/libc.sh
if [[ $# < 1 ]]; then
echo >&2 "Usage: $0 id [name1 [name2 ...]]"
exit 2
Expand All @@ -11,7 +12,9 @@ if [[ $# == 0 ]]; then
else
names="$@"
fi
ls -1 "db/${id}."* >/dev/null 2>&1 || die "Invalid ID '$id'"
for name in $names; do
offset=`cat db/${id}.symbols | grep "^$name " | cut -d' ' -f2`
[ -z "$offset" ] && die "Invalid symbol '$name'"
echo "offset_${name} = 0x${offset}"
done
3 changes: 3 additions & 0 deletions find
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ function find() {
fi
}

ret=1
for id in `find "$@"`; do
echo "`cat db/${id}.info` ($id)"
ret=0
done
exit $ret
1 change: 1 addition & 0 deletions identify
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -o pipefail
cd "$(dirname "$0")"
help() {
echo >&2 "Usage: $0 path/to/libc.so"
Expand Down

0 comments on commit d69f04c

Please sign in to comment.