misc/66445: Add options ti last to ignore ftp logins (usefull for busy ftp servers) [PATCH]

Flemming Jacobsen fj at batmule.dk
Mon May 10 03:10:23 PDT 2004


>Number:         66445
>Category:       misc
>Synopsis:       Add options ti last to ignore ftp logins (usefull for busy ftp servers) [PATCH]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 10 03:10:22 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Flemming Jacobsen
>Release:        5.2.1-RELEASE-p3
>Organization:
DKUUG
>Environment:
FreeBSD ra.dkuug.dk 5.2.1-RELEASE-p3 FreeBSD 5.2.1-RELEASE-p3 #1: Fri Mar 19 05:46:43 CET 2004     fj at nyra.dkuug.dk:/usr/obj/usr/src/sys/RA  i386

>Description:
On a busy ftp server last is almost useless wothout using some kind of grep -v, if wou want to know about your co-admins.
>How-To-Repeat:
do 'last -10' on a busy ftp server. Observe that no "shell-logins" are seen.
>Fix:
A patch to fix this is located at: http://www.batmule.dk/FreeBSD/last.ignoreftp.diff

It's pasted below for competeness:

--- last.1.orig Mon May 10 11:10:40 2004
+++ last.1      Mon May 10 11:35:54 2004
@@ -145,6 +145,12 @@
 .It Fl h Ar host
 .Ar Host
 names may be names or internet numbers.
+.It Fl i
+Ignore all anonymous ftp logins while displaying. 
+This is usefull on a busy ftp server.
+.It Fl I
+Ignore all ftp logins while displaying. 
+This is usefull on a busy ftp server.
 .It Fl n Ar maxrec
 Limit the report to
 .Ar maxrec

--- last.c.orig Mon May 10 11:10:34 2004
+++ last.c      Mon May 10 11:52:34 2004
@@ -98,6 +98,11 @@
                                                 * report users logged in
                                                 * at this snapshot time
                                                 */
+static int     ignoreftp=0;                    /* if == 1, ignore annonymous
+                                                * ftp logins
+                                                * if ==2, ignore all ftp 
+                                                * logins
+                                                */
 
 void    addarg(int, char *);
 time_t  dateconv(char *);
@@ -114,7 +119,7 @@
 usage(void)
 {
        (void)fprintf(stderr,
-"usage: last [-swy] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
+"usage: last [-iIswy] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
 "            [-n maxrec] [-t tty] [user ...]\n");
        exit(1);
 }
@@ -130,7 +135,7 @@
 
        maxrec = -1;
        snaptime = 0;
-       while ((ch = getopt(argc, argv, "0123456789d:f:h:n:st:wy")) != -1)
+       while ((ch = getopt(argc, argv, "0123456789d:f:h:iIn:st:wy")) != -1)
                switch (ch) {
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
@@ -157,6 +162,12 @@
                        hostconv(optarg);
                        addarg(HOST_TYPE, optarg);
                        break;
+               case 'i':
+                       ignoreftp=1;
+                       break;
+               case 'I':
+                       ignoreftp=2;
+                       break;
                case 'n':
                        errno = 0;
                        maxrec = strtol(optarg, &p, 10);
@@ -336,6 +347,10 @@
        time_t  delta;                          /* time difference */
        time_t  t;
 
+       if( !strcmp("ftp",bp->ut_name) && ignoreftp)            /* anon ftp */
+         return;
+       if( !strcmp("ftp",bp->ut_line) && ignoreftp == 2)       /* ftp */
+         return;
        if (maxrec != -1 && !maxrec--)
                exit(0);
        t = _int_to_time(bp->ut_time);

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list