Subject: bin/8453: Add pppd option to log to screen
To: None <gnats-bugs@gnats.netbsd.org>
From: Michael Eriksson <eramore@era-t.ericsson.se>
List: netbsd-bugs
Date: 09/20/1999 14:21:00
>Number:         8453
>Category:       bin
>Synopsis:       Add pppd option to log to screen
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 20 14:20:01 1999
>Last-Modified:
>Originator:     Michael Eriksson
>Organization:
Ericsson Radio Systems AB
>Release:        NetBSD-release as of early September 1999 or so
>Environment:
System: NetBSD burken 1.4.1 NetBSD 1.4.1 (EMT) #0: Mon Sep 13 09:41:04 CEST 1999 eramore@burken:/var/home/eramore/wrk/maestro2/sys/arch/i386/compile/EMT i386


>Description:

When setting up a PPP connection, it is nice to follow the connection
setup on screen, rather than looking at the log files.

>How-To-Repeat:

Set up a PPP connection with existing pppd, and observe the lack of
interesting output. :-)

>Fix:

Add this patch. (If this patch is accepted, it should probably be
forwarded to Paul Mackerras for inclusion in the main PPP
distribution).

Index: pppd/main.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pppd/pppd/main.c,v
retrieving revision 1.34
diff -u -r1.34 main.c
--- main.c	1998/09/04 19:13:05	1.34
+++ main.c	1999/09/20 20:55:06
@@ -267,6 +267,18 @@
 	nodetach = 1;
 
     /*
+     * Give a copy of the syslog messages to the screen, if the user
+     * wants it.
+     */
+#ifndef ULTRIX    
+    if (verbose) {
+	closelog();
+	openlog("pppd", LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_PPP);
+	setlogmask(LOG_UPTO(LOG_INFO));
+    }
+#endif
+
+    /*
      * Initialize system-dependent stuff and magic number package.
      */
     sys_init();
@@ -621,10 +633,21 @@
 {
     if (detached)
 	return;
+    if (nodetach == -1)
+	syslog(LOG_NOTICE, "daemonizing...");
     if (daemon(0, 0) < 0) {
 	perror("Couldn't detach from controlling terminal");
 	die(1);
     }
+#ifndef ULTRIX
+    if (verbose) {
+	int logmask = setlogmask(LOG_INFO);
+	closelog();
+	openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
+	setlogmask(logmask);
+	verbose = 0;
+    }
+#endif
     detached = 1;
     pid = getpid();
     /* update pid file if it has been written already */
Index: pppd/options.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pppd/pppd/options.c,v
retrieving revision 1.27
diff -u -r1.27 options.c
--- options.c	1998/09/04 19:13:05	1.27
+++ options.c	1999/09/20 20:55:13
@@ -94,6 +94,7 @@
 u_int32_t netmask = 0;		/* IP netmask to set on interface */
 int	lockflag = 0;		/* Create lock file to lock the serial dev */
 int	nodetach = 0;		/* Don't detach from controlling tty */
+int	verbose;		/* Log also to screen during setup */
 char	*connector = NULL;	/* Script to establish physical link */
 char	*disconnector = NULL;	/* Script to disestablish physical link */
 char	*welcomer = NULL;	/* Script to run after phys link estab. */
@@ -182,6 +183,7 @@
 static int setxonxoff __P((char **));
 static int setnodetach __P((char **));
 static int setupdetach __P((char **));
+static int setverbose __P((char **));
 static int setmodem __P((char **));
 static int setlocal __P((char **));
 static int setlock __P((char **));
@@ -285,6 +287,7 @@
     {"nodetach", 0, setnodetach}, /* Don't detach from controlling tty */
     {"-detach", 0, setnodetach}, /* don't fork */
     {"updetach", 0, setupdetach}, /* Detach once an NP has come up */
+    {"verbose", 0, setverbose}, /* Log also to screen during setup */
     {"noip", 0, noip},		/* Disable IP and IPCP */
     {"-ip", 0, noip},		/* Disable IP and IPCP */
     {"nomagic", 0, nomagicnumber}, /* Disable magic number negotiation */
@@ -1897,6 +1900,14 @@
     char **argv;
 {
     nodetach = -1;
+    return (1);
+}
+
+static int
+setverbose(argv)
+    char **argv;
+{
+    verbose = 1;
     return (1);
 }
 
Index: pppd/pppd.h
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pppd/pppd/pppd.h,v
retrieving revision 1.17
diff -u -r1.17 pppd.h
--- pppd.h	1998/09/04 19:13:06	1.17
+++ pppd.h	1999/09/20 20:55:15
@@ -87,6 +87,7 @@
 extern u_int32_t netmask;	/* IP netmask to set on interface */
 extern int	lockflag;	/* Create lock file to lock the serial dev */
 extern int	nodetach;	/* Don't detach from controlling tty */
+extern int	verbose;	/* Log also to screen during setup */
 extern char	*connector;	/* Script to establish physical link */
 extern char	*disconnector;	/* Script to disestablish physical link */
 extern char	*welcomer;	/* Script to welcome client after connection */
>Audit-Trail:
>Unformatted: