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
|
From: Jari Aalto <jari.aalto@cante.net>
Date: Wed, 14 Dec 2005 09:38:17 +0200
Subject: Modify chkrootkit's printn to use printf if available.
This improves readability of the output (if no -q given) by right-aligning
the "nothing found" results.
.
A previous comment noted that upstream was not interested in this patch as
printf is not portable. However, this patch should work even if printf is
not present.
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=343284
Last-updated: 2021-10-10
Forwarded: https://lists.debian.org/debian-security-tools/2021/10/msg00006.html
chkrootkit | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/chkrootkit b/chkrootkit
index 4dc3d1c..17869dc 100755
@@ -2831,11 +2831,36 @@ chk_telnetd () {
return ${STATUS}
}
-printn () {
- if `${echo} "a\c" | ${egrep} c >/dev/null 2>&1` ; then
- ${echo} -n "$1"
+printn ()
+{
+ printf="use printf"
+ printf_fmt="%-60s"
+
+ if [ ! "$PRINTF_BIN" ]; then
+ # This is first time call to use. Check environment and
+ # define this global.
+
+ PRINTF_BIN=`which printf 2> /dev/null`
+
+ # Set to dummy, if not found
+ [ ! "$PRINTF_BIN" ] && PRINTF_BIN="not exists"
+
+ # We're done, and won't enter this if-case any more
+ fi
+
+ # Some messages are continued, so don't use printf
+ case "$1" in
+ *exec*|*bogus*) printf="" ;;
+ esac
+
+ if [ "$PRINTF_BIN" ] && [ "$printf" ]; then
+ $PRINTF_BIN "$printf_fmt" "$1"
else
- ${echo} "${1}\c"
+ if `${echo} "a\c" | ${egrep} c >/dev/null 2>&1` ; then
+ ${echo} -n "$1"
+ else
+ ${echo} "${1}\c"
+ fi
fi
}
|