From dbj@home.pelops.com  Sat Jun 28 20:10:18 1997
Received: from home.pelops.com (dbj@pelops.com [204.255.233.232])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id UAA14308
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 28 Jun 1997 20:10:17 -0700 (PDT)
Received: (from dbj@localhost)
	by home.pelops.com (8.8.5/8.8.5) id XAA07417;
	Sat, 28 Jun 1997 23:10:24 -0400 (EDT)
Message-Id: <199706290310.XAA07417@home.pelops.com>
Date: Sat, 28 Jun 1997 23:10:24 -0400 (EDT)
From: dbj@pelops.com
Reply-To: dbj@pelops.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: User-mode ppp doesn't track online time in a structured manner
X-Send-Pr-Version: 3.2

>Number:         3981
>Category:       misc
>Synopsis:       wtmp logging of ppp activity would be nice
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brian
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 28 20:20:01 PDT 1997
>Closed-Date:    Mon Sep 29 16:58:45 PDT 1997
>Last-Modified:  Mon Sep 29 17:07:33 PDT 1997
>Originator:     David E. Brooks Jr
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
Tantalus Incorporated of Kentucky
>Environment:

	

>Description:

For some of us, the need to track time used on a link is useful,
especially if we're charged for time used.  User-mode ppp doesn't
provide a structured method of obtaining this information.

>How-To-Repeat:

Get an ISDN line in the Louisville, Kentucky area :-)

>Fix:
	
The following patch allows ppp (if compiled with -DLOGWTMP) to write
entries into wtmp whenver a link goes up or down.  By placing a 'set
logname' command into /etc/ppp/ppp.conf, the name used in the wtmp
file can be set (If not set, no logging occurs).

-- Dave

--- ppp.orig/Makefile	Sun May 11 08:58:57 1997
+++ ppp/Makefile	Sat Jun 28 22:24:53 1997
@@ -7,7 +7,7 @@
 	vjcomp.c arp.c alias.c alias_db.c alias_ftp.c alias_util.c \
 	passwdauth.c sig.c
 #CFLAGS+= -DHAVE_SHELL_CMD_WITH_ANY_MODE
-CFLAGS += -Wall -DMSEXT -DPASSWDAUTH
+CFLAGS += -Wall -DMSEXT -DPASSWDAUTH -DLOGWTMP
 LDADD += -lmd -lcrypt -lutil
 DPADD += ${LIBMD} ${LIBCRYPT} ${LIBUTIL}
 MAN8=	ppp.8
--- ppp.orig/command.c	Tue May 13 21:21:27 1997
+++ ppp/command.c	Sat Jun 28 22:05:11 1997
@@ -414,6 +414,14 @@
 }
 #endif /* MSEXT */
 
+#ifdef LOGWTMP
+static int ShowLogName()
+{
+  printf(" Wtmp log name: %s\n", VarLogName);
+  return(1);
+}
+#endif
+
 extern int ShowIfilter(), ShowOfilter(), ShowDfilter(), ShowAfilter();
 
 struct cmdtab const ShowCommands[] = {
@@ -461,6 +469,10 @@
   { "msext", 	NULL,	  ShowMSExt,		LOCAL_AUTH,
 	"Show MS PPP extentions", StrNull},
 #endif /* MSEXT */
+#ifdef LOGWTMP
+  { "logname",  NULL,     ShowLogName,		LOCAL_AUTH,
+	"Show wtmp logging name", StrNull},
+#endif
   { "version",  NULL,	  ShowVersion,		LOCAL_NO_AUTH | LOCAL_AUTH,
 	"Show version string", StrNull},
   { "help",     "?",      HelpCommand,		LOCAL_NO_AUTH | LOCAL_AUTH,
@@ -986,6 +998,9 @@
 #define	VAR_DEVICE	4
 #define	VAR_ACCMAP	5
 #define	VAR_PHONE	6
+#ifdef LOGWTMP
+#define VAR_LOGNAME	7
+#endif 
 
 static int
 SetVariable(list, argc, argv, param)
@@ -1030,6 +1045,12 @@
       strcpy(VarPhoneCopy, VarPhoneList);
       VarNextPhone = VarPhoneCopy;
       break;
+#ifdef LOGWTMP
+    case VAR_LOGNAME:
+      strncpy(VarLogName, *argv, sizeof(VarLogName)-1);
+      VarLogName[sizeof(VarLogName)-1] = '\0';
+      break;
+#endif
     }
   }
   return(1);
@@ -1123,6 +1144,10 @@
   { "nbns",	NULL,	  SetNBNS,		LOCAL_AUTH,
 	"Set NetBIOS NameServer", "pri-addr [sec-addr]"},
 #endif /* MSEXT */
+#ifdef LOGWTMP
+  { "logname",  NULL,     SetVariable,		LOCAL_AUTH,
+	"Set wtmp logging name", "logname", (void *)VAR_LOGNAME},
+#endif /* LOGWTMP */
   { "help",     "?",      HelpCommand,		LOCAL_AUTH | LOCAL_NO_AUTH,
 	"Display this message", StrNull, (void *)SetCommands},
   { NULL,       NULL,     NULL },
--- ppp.orig/modem.c	Tue May 13 21:20:28 1997
+++ ppp/modem.c	Sat Jun 28 22:53:15 1997
@@ -34,6 +34,9 @@
 #include "ip.h"
 #include "modem.h"
 #include "vars.h"
+#ifdef LOGWTMP
+#include <libutil.h>
+#endif
 
 #ifndef O_NONBLOCK
 #ifdef O_NDELAY
@@ -213,6 +216,10 @@
 {
   LogPrintf(LOG_PHASE_BIT, "Disconnected!\n");
   LogPrintf(LOG_PHASE_BIT, "Connect time: %d secs\n", time(NULL) - uptime);
+#ifdef LOGWTMP
+  if (VarLogName[0])
+      logwtmp(VarDevice + 5, "", "");
+#endif /* LOGWTMP */
   if (!TermMode) {
     CloseModem();
     LcpDown();
@@ -255,6 +262,10 @@
       if (Online) {
         time(&uptime);
         LogPrintf(LOG_PHASE_BIT, "*Connected!\n");
+#ifdef LOGWTMP
+	if (VarLogName[0])
+	  logwtmp(VarDevice + 5, VarLogName, "");
+#endif /* LOGWTMP */
         connect_count++;
         /*
          * In dedicated mode, start packet mode immediate
@@ -270,6 +281,10 @@
     if (!Online) {
       time(&uptime);
       LogPrintf(LOG_PHASE_BIT, "Connected!\n");
+#ifdef LOGWTMP
+	if (VarLogName[0])
+	  logwtmp(VarDevice + 5, VarLogName, "");
+#endif /* LOGWTMP */
       mbits = TIOCM_CD;
       connect_count++;
       connect_time = 0;
--- ppp.orig/vars.h	Fri May  9 23:42:36 1997
+++ ppp/vars.h	Sat Jun 28 22:04:09 1997
@@ -24,6 +24,9 @@
 #define	_VARS_H_
 
 #include <sys/param.h>
+#ifdef LOGWTMP
+#include <utmp.h>
+#endif /* LOGWTMP */
 
 struct confdesc {
   char *name;
@@ -83,6 +86,9 @@
   char   phone_copy[200];       /* copy for strsep() */
   char   *next_phone;           /* Next phone from the list */
   char   shostname[MAXHOSTNAMELEN];/* Local short Host Name */
+#ifdef LOGWTMP
+  char   log_name[UT_NAMESIZE];	/* name used for wtmp logging */
+#endif /* LOGWTMP */
 };
 
 #define VarAccmap	pppVars.var_accmap
@@ -110,6 +116,9 @@
 #define VarRedialTimeout pppVars.redial_timeout
 #define VarRedialNextTimeout pppVars.redial_next_timeout
 #define VarDialTries	pppVars.dial_tries
+#ifdef LOGWTMP
+#define VarLogName	pppVars.log_name
+#endif /* LOGWTMP */
 
 #define	DEV_IS_SYNC	(VarSpeed == 0)
 
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Sun Jun 29 07:30:30 PDT 1997 
Responsible-Changed-Why:  
ppp is mine ;-) 

From: Brian Somers <brian@awfulhak.org>
To: dbj@pelops.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG,
        David Nugent <davidn@labs.usn.blaze.net.au>
Subject: Re: misc/3981: User-mode ppp doesn't track online time in a 
 structured manner
Date: Sun, 29 Jun 1997 15:31:41 +0100

 > 
 > >Number:         3981
 > >Category:       misc
 > >Synopsis:       wtmp logging of ppp activity would be nice
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Class:          change-request
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Sat Jun 28 20:20:01 PDT 1997
 > >Last-Modified:
 > >Originator:     David E. Brooks Jr
 > >Organization:
 > Tantalus Incorporated of Kentucky
 > >Release:        FreeBSD 2.2.2-RELEASE i386
 > >Environment:
 > 
 > 	
 > 
 > >Description:
 > 
 > For some of us, the need to track time used on a link is useful,
 > especially if we're charged for time used.  User-mode ppp doesn't
 > provide a structured method of obtaining this information.
 > 
 > >How-To-Repeat:
 > 
 > Get an ISDN line in the Louisville, Kentucky area :-)
 > 
 > >Fix:
 > 	
 > The following patch allows ppp (if compiled with -DLOGWTMP) to write
 > entries into wtmp whenver a link goes up or down.  By placing a 'set
 > logname' command into /etc/ppp/ppp.conf, the name used in the wtmp
 > file can be set (If not set, no logging occurs).
 > 
 > -- Dave
 
 AFAIK, Dave Nugent has plans in this area for ppp.  Is this true
 Dave (N) ?
 
 Also, the enclosed patches are based on a very old version of
 ppp (relatively).
 
 Dave (N), if you give me the goahead, I'll merge these changes
 in by hand, but switched on by default and #define'able out.
 -- 
 Brian <brian@awfulhak.org>, <brian@freebsd.org>
       <http://www.awfulhak.org>
 Don't _EVER_ lose your sense of humour....
 
 

From: David Nugent <davidn@labs.usn.blaze.net.au>
To: Brian Somers <brian@awfulhak.org>
Cc: dbj@pelops.com, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/3981: User-mode ppp doesn't track online time in a 
 structured manner
Date: Mon, 30 Jun 1997 02:40:53 +1000

 >  > For some of us, the need to track time used on a link is useful,
 >  > especially if we're charged for time used.  User-mode ppp doesn't
 >  > provide a structured method of obtaining this information.
 
 Actually, I didn't know this! I've never used user-mode ppp as a server,
 you see. Kernel ppp does provide the facility already if you use its
 "login" option.
 
 >  AFAIK, Dave Nugent has plans in this area for ppp.  Is this true
 >  Dave (N) ?
 
 No, not for ppp. As I said, I wasn't aware that it didn't support it
 in some form, so go head and merge! I had assumed it already did this.
 
 What is missing currently is that CHAP ppp logins in pppd don't support
 "login", that *that* is something I've been wanting to fix. I'd far
 prefer our users do chap than pap in any case, but right now I have to
 disable it, otherwise we have no trace of where logins are coming
 from except if you keep a verbose pppd login and pull it out from there
 (pppd also lacks a "setlogin", so that data in /proc still refers to
 auto-ppp logins as owned by "root", which is yet another thing that
 needs to be fixed).
 
 BTW, I also noticed recently that even with -chap on pppd's commandline,
 it will still attempt to negotiate chap if chap-secrets exists in
 /etc/ppp. This seems to be a side-effect of a commit that happened
 recently. I noticed it first around 3 weeks ago.
 
 
 >  Dave (N), if you give me the goahead, I'll merge these changes
 >  in by hand, but switched on by default and #define'able out.
 
 Hmm, if a "set login" is required anyway, I don't see any reason not
 to put it in anyway without requiring a #define, assuming it works ok. :-)
 Personally, I'd find it less than useful if a ppp server didn't log a
 remote system in, and I daresay that most providers would be in the
 same situation. I guess the lack of this feature is fairly indicative
 of how few providers use user-mode ppp as a server (although I can't
 for the life of me know why, since there seems to be very little
 practical difference in terms of performance, stability etc. and user-
 mode ppp seems to be somewhat easier to configure and manipulate).
 
 Also, the wtmp/utmp/lastlog api is more or less done, just lacking me
 putting it up on freefall for comment. Time of late has been very scarce. 
 :(
 These will affect this patch by significantly simplifying them, but go
 ahead anyway and we'll look at a complete "utmp/wtmp" cleanup to the
 entire tree once the interface has been examined, "approved" and
 committed.
 
 Regards,
 David
 
 David Nugent - Unique Computing Pty Ltd - Melbourne, Australia
 Voice +61-3-9791-9547  Data/BBS +61-3-9792-3507  3:632/348@fidonet
 davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/
 

From: "David E. Brooks Jr" <dbj@pelops.com>
To: freebsd-gnats-submit@freebsd.org, davidn@labs.usn.blaze.net.au
Cc:  Subject: Re: misc/3981: wtmp logging of ppp activity would be nice
Date: Mon, 30 Jun 1997 16:45:52 -0400

 Uhm, I had a nagging suspicion when I send the PR that I forgot
 something.  And, sure enough, I forgot to handle the PPP over TCP case
 properly.  Do you guys want me to look into this?
 
 -- Dave
State-Changed-From-To: open->closed 
State-Changed-By: brian 
State-Changed-When: Mon Sep 29 16:58:45 PDT 1997 
State-Changed-Why:  
utmp/wtmp capabilities are now the default - not just 
for passwdauth logins.  They're disabled by "disable utmp". 
>Unformatted:
