Date: Sat, 28 Jun 1997 23:10:24 -0400 (EDT) From: dbj@pelops.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: misc/3981: User-mode ppp doesn't track online time in a structured manner Message-ID: <199706290310.XAA07417@home.pelops.com> Resent-Message-ID: <199706290320.UAA14553@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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
--- 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)
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706290310.XAA07417>
