aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pppd/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pppd/main.c')
-rw-r--r--usr.sbin/pppd/main.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c
index ee7dec1dd99d..c13a90d5f1d6 100644
--- a/usr.sbin/pppd/main.c
+++ b/usr.sbin/pppd/main.c
@@ -18,7 +18,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id$";
+static char rcsid[] = "$Id: main.c,v 1.10 1997/02/22 16:11:48 peter Exp $";
#endif
#include <stdio.h>
@@ -67,6 +67,7 @@ int ifunit; /* Interface unit number */
char *progname; /* Name of this program */
char hostname[MAXNAMELEN]; /* Our hostname */
static char pidfilename[MAXPATHLEN]; /* name of pid file */
+static char iffilename[MAXPATHLEN]; /* name of if file */
static char default_devnam[MAXPATHLEN]; /* name of default device */
static pid_t pid; /* Our pid */
static pid_t pgrpid; /* Process Group ID */
@@ -154,10 +155,11 @@ main(argc, argv)
int argc;
char *argv[];
{
- int i, nonblock;
+ int i, n, nonblock;
struct sigaction sa;
struct cmd *cmdp;
FILE *pidfile;
+ FILE *iffile;
char *p;
struct passwd *pw;
struct timeval timo;
@@ -393,6 +395,21 @@ main(argc, argv)
pidfilename[0] = 0;
}
+ /* write interface unit number to file */
+ for (n = strlen(devnam); n > 0 ; n--)
+ if (devnam[n] == '/') {
+ n = n++;
+ break;
+ }
+ (void) sprintf(iffilename, "%s%s.if", _PATH_VARRUN, &devnam[n]);
+ if ((iffile = fopen(iffilename, "w")) != NULL) {
+ fprintf(iffile, "ppp%d\n", ifunit);
+ (void) fclose(iffile);
+ } else {
+ syslog(LOG_ERR, "Failed to create if file %s: %m", iffilename);
+ iffilename[0] = 0;
+ }
+
/*
* Set device for non-blocking reads.
*/
@@ -448,6 +465,11 @@ main(argc, argv)
syslog(LOG_WARNING, "unable to delete pid file: %m");
pidfilename[0] = 0;
+ if (iffile)
+ if (unlink(iffilename) < 0 && errno != ENOENT)
+ syslog(LOG_WARNING, "unable to delete if file: %m");
+ iffilename[0] = 0;
+
} while (persist);
die(0);