~ubuntu-branches/ubuntu/saucy/chkrootkit/saucy-security

« back to all changes in this revision

Viewing changes to debian/patches/chkutmp.diff

  • Committer: Bazaar Package Importer
  • Author(s): Giuseppe Iuculano
  • Date: 2009-08-28 10:29:14 UTC
  • Revision ID: james.westby@ubuntu.com-20090828102914-0f0p04tjj6t5q90h
Tags: 0.49-3
* [543dafe] Fixed chkutmp parser and added a regexp to ignore PIDs in
  chkutmp output, thanks to Aaron M. Ucko. (Closes: #542327)
* [d016db0] chkutmp: sort ps output by tty,ruser,args. Thanks to Aaron
  M. Ucko
* [c1fb66c] Updated to standards version 3.8.3 (No changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Fixed chkutmp parser, thanks to Aaron M. Ucko
 
2
--- a/chkutmp.c
 
3
+++ b/chkutmp.c
 
4
@@ -58,9 +58,9 @@ int main () { return 0; }
 
5
 #endif
 
6
 
 
7
 struct ps_line {
 
8
-    char ps_tty[UT_LINESIZE];
 
9
-    char ps_user[UT_NAMESIZE];
 
10
-    char ps_args[MAXLENGTH];
 
11
+    char ps_tty[UT_LINESIZE+2];
 
12
+    char ps_user[UT_NAMESIZE+2];
 
13
+    char ps_args[MAXLENGTH+2];
 
14
     int ps_pid;
 
15
 };
 
16
 struct utmp_line {
 
17
@@ -70,7 +70,7 @@ struct utmp_line {
 
18
 };
 
19
 static char *cmd[] = {
 
20
     "ps -ef -o \"tty,pid,ruser,args\"",        /* solaris */
 
21
-    "ps ax -o \"tty,pid,ruser,args\""  /* linux */
 
22
+    "ps axk \"tty,ruser,args\" -o \"tty,pid,ruser,args\""      /* linux */
 
23
 };
 
24
 int fetchps(struct ps_line *);
 
25
 int fetchutmp(struct utmp_line *);
 
26
@@ -113,6 +113,8 @@ int fetchps(struct ps_line *psl_p)
 
27
                    s++;
 
28
                for (x = 0; (*d++ = *s++) && x <= MAXLENGTH; x++)       /* cmd + args */
 
29
                    ;
 
30
+               if (d[-2] == '\n')
 
31
+                       d[-2] = '\0';
 
32
                i++;
 
33
                curp++;
 
34
            }
 
35
@@ -202,7 +204,7 @@ int main(int argc, char *argv[])
 
36
                       "CMD");
 
37
                hdr_prntd = 1;
 
38
            }
 
39
-           printf("! %-9s %7d %-6s %s", ps_l[h].ps_user,
 
40
+           printf("! %-9s %7d %-6s %s\n", ps_l[h].ps_user,
 
41
                   ps_l[h].ps_pid, ps_l[h].ps_tty, ps_l[h].ps_args);
 
42
        }
 
43
     }