File: chkrootkit-printn.patch

package info (click to toggle)
chkrootkit 0.58b-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,796 kB
  • sloc: sh: 187,089; ansic: 3,779; makefile: 103
file content (66 lines) | stat: -rw-r--r-- 1,789 bytes parent folder | download | duplicates (2)
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
From: Jari Aalto <jari.aalto@cante.net>
Date: Wed, 14 Dec 2005 09:38:17 +0200
Subject: chkrootkit-printn

    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.

Last-updated: 2021-10-10
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=343284
Forwarded: yes
(Forwarded by email: 21 Dec 2024)
---
 chkrootkit | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/chkrootkit b/chkrootkit
index 772d405..a24416d 100755
--- a/chkrootkit
+++ b/chkrootkit
@@ -2781,11 +2781,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 [ -z "$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
+	    [ -z "$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_BIN
+    case "$1" in
+	    *exec*|*bogus*) printf="" ;;
+    esac
+
+    if [ -n "$PRINTF_BIN" ] && [ -n "$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
 }