File: 57_chutmp-improve-message-if-processes-without-tty-are-found.patch

package info (click to toggle)
chkrootkit 0.58b-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 7,612 kB
  • sloc: sh: 169,788; ansic: 10,726; makefile: 103
file content (60 lines) | stat: -rw-r--r-- 2,023 bytes parent folder | download
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
From: Richard Lewis <richard.lewis.debian@googlemail.com>
Date: Sat, 16 Oct 2021 23:51:50 +0100
Subject: chutmp: improve message if processes without tty are found

Forwarded: yes
 (forwarded by email, 12 mar 2023)

 (The message needs 'was' not 'were' because "The tty" is singular)
 It also fixes indentation around the change and removes trailing whitespace.  .
 Upstreamable
---
 chkutmp.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/chkutmp.c b/chkutmp.c
index 5668d63..60a5dfb 100644
--- a/chkutmp.c
+++ b/chkutmp.c
@@ -118,12 +118,12 @@ int fetchps(struct ps_line *psl_p)
 			d[-2] = '\0';
 		i++;
 		curp++;
-                /* if we didn't read the line, skip the rest */ 
-                line_length = strlen(line); 
-                while (!(line_length == 0 || line[line_length -1] == '\n')) { 
+                /* if we didn't read the line, skip the rest */
+                line_length = strlen(line);
+                while (!(line_length == 0 || line[line_length -1] == '\n')) {
                    (void) !fgets(line, MAXREAD, ps_fp);
-                   line_length = strlen(line); 
-                } 
+                   line_length = strlen(line);
+                }
 	    }
 	}
 	pclose(ps_fp);
@@ -203,16 +203,13 @@ int main(void)
 	    }
 	}
 	if (!mtch_fnd) {
-	    if (!hdr_prntd) {
-		printf
-		    (" The tty of the following user process(es) were not found\n");
-		printf(" in %s !\n", UTMP);
-		printf("! %-9s %7s %-6s %s\n", "RUID", "PID", "TTY",
-		       "CMD");
-		hdr_prntd = 1;
-	    }
-	    printf("! %-9s %7d %-6s %s\n", ps_l[h].ps_user,
-		   ps_l[h].ps_pid, ps_l[h].ps_tty, ps_l[h].ps_args);
+		if (!hdr_prntd) {
+			printf("The tty of the following process(es) was not found in %s:\n", UTMP);
+			printf("! %-9s %7s %-6s %s\n", "RUID", "PID", "TTY", "CMD");
+			hdr_prntd = 1;
+		}
+		printf("! %-9s %7d %-6s %s\n", ps_l[h].ps_user,
+					 ps_l[h].ps_pid, ps_l[h].ps_tty, ps_l[h].ps_args);
 	}
     }
     exit(EXIT_SUCCESS);