*/
#ifndef lint
-static const char rcsid[] = "$Id: main.c,v 1.81 1999/08/12 04:17:07 paulus Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.82 1999/08/13 01:57:35 paulus Exp $";
#endif
#include <stdio.h>
char *progname; /* Name of this program */
char hostname[MAXNAMELEN]; /* Our hostname */
static char pidfilename[MAXPATHLEN]; /* name of pid file */
+static char linkpidfile[MAXPATHLEN]; /* name of linkname pid file */
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
static uid_t uid; /* Our real user-id */
static int conn_running; /* we have a [dis]connector running */
/* Prototypes for procedures local to this file. */
static void create_pidfile __P((void));
+static void create_linkpidfile __P((void));
static void cleanup __P((void));
static void close_tty __P((void));
static void get_input __P((void));
waiting = 0;
+ create_linkpidfile();
+
/*
* If we're doing dial-on-demand, set up the interface now.
*/
if (!demand) {
if (pidfilename[0] != 0
&& unlink(pidfilename) < 0 && errno != ENOENT)
- warn("unable to delete pid file: %m");
+ warn("unable to delete pid file %s: %m", pidfilename);
pidfilename[0] = 0;
}
close(2);
detached = 1;
log_to_fd = -1;
- /* update pid file if it has been written already */
+ /* update pid files if they have been written already */
if (pidfilename[0])
create_pidfile();
+ if (linkpidfile[0])
+ create_linkpidfile();
}
/*
}
slprintf(numbuf, sizeof(numbuf), "%d", getpid());
script_setenv("PPPD_PID", numbuf);
+ if (linkpidfile[0])
+ create_linkpidfile();
+}
+
+static void
+create_linkpidfile()
+{
+ FILE *pidfile;
+
+ if (linkname[0] == 0)
+ return;
+ slprintf(linkpidfile, sizeof(linkpidfile), "%sppp-%s.pid",
+ _PATH_VARRUN, linkname);
+ if ((pidfile = fopen(linkpidfile, "w")) != NULL) {
+ fprintf(pidfile, "%d\n", getpid());
+ if (pidfilename[0])
+ fprintf(pidfile, "%s\n", ifname);
+ (void) fclose(pidfile);
+ } else {
+ error("Failed to create pid file %s: %m", linkpidfile);
+ linkpidfile[0] = 0;
+ }
+ script_setenv("LINKNAME", linkname);
}
/*
close_tty();
if (pidfilename[0] != 0 && unlink(pidfilename) < 0 && errno != ENOENT)
- warn("unable to delete pid file: %m");
+ warn("unable to delete pid file %s: %m", pidfilename);
pidfilename[0] = 0;
+ if (linkpidfile[0] != 0 && unlink(linkpidfile) < 0 && errno != ENOENT)
+ warn("unable to delete pid file %s: %m", linkpidfile);
+ linkpidfile[0] = 0;
if (locked)
unlock();
*/
#ifndef lint
-static const char rcsid[] = "$Id: options.c,v 1.62 1999/08/12 04:25:10 paulus Exp $";
+static const char rcsid[] = "$Id: options.c,v 1.63 1999/08/13 01:57:36 paulus Exp $";
#endif
#include <ctype.h>
bool sync_serial = 0; /* Device is synchronous serial device */
int log_to_fd = 1; /* send log messages to this fd too */
int maxfail = 10; /* max # of unsuccessful connection attempts */
+char linkname[MAXPATHLEN]; /* logical name for link */
extern option_t auth_options[];
extern struct stat devstat;
{ "nologfd", o_int, &log_to_fd,
"Don't send log messages to any file descriptor",
OPT_NOARG | OPT_VAL(-1) },
+ { "linkname", o_string, linkname,
+ "Set logical name for link",
+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "maxfail", o_int, &maxfail,
"Maximum number of unsuccessful connection attempts to allow" },
.\" manual page [] for pppd 2.3
-.\" $Id: pppd.8,v 1.43 1999/08/12 04:22:53 paulus Exp $
+.\" $Id: pppd.8,v 1.44 1999/08/13 01:57:36 paulus Exp $
.\" SH section heading
.\" SS subsection heading
.\" LP paragraph
Set the LCP restart interval (retransmission timeout) to \fIn\fR
seconds (default 3).
.TP
+.B linkname \fIname\fR
+Sets the logical name of the link to \fIname\fR. Pppd will create a
+file named \fBppp-\fIname\fB.pid\fR in /var/run (or /etc/ppp on some
+systems) containing its process ID. This can be useful in determining
+which instance of pppd is responsible for the link to a given peer
+system. This is a privileged option.
+.TP
.B local
Don't use the modem control lines. With this option, pppd will ignore
the state of the CD (Carrier Detect) signal from the modem and will
.B BYTES_RCVD
The number of bytes received (at the level of the serial port) during
the connection.
+.TP
+.B LINKNAME
+The logical name of the link, set with the \fIlinkname\fR option.
.P
Pppd invokes the following scripts, if they exist. It is not an error
if they don't exist.
.B /var/run/ppp\fIn\fB.pid \fR(BSD or Linux), \fB/etc/ppp/ppp\fIn\fB.pid \fR(others)
Process-ID for pppd process on ppp interface unit \fIn\fR.
.TP
+.B /var/run/ppp-\fIname\fB.pid \fR(BSD or Linux), \fB/etc/ppp/ppp-\fIname\fB.pid \fR(others)
+Process-ID for pppd process for logical link \fIname\fR (see the
+\fIlinkname\fR option).
+.TP
.B /etc/ppp/pap-secrets
Usernames, passwords and IP addresses for PAP authentication. This
file should be owned by root and not readable or writable by any other
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pppd.h,v 1.43 1999/08/12 04:22:53 paulus Exp $
+ * $Id: pppd.h,v 1.44 1999/08/13 01:57:37 paulus Exp $
*/
/*
extern char *record_file; /* File to record chars sent/received */
extern bool sync_serial; /* Device is synchronous serial device */
extern int maxfail; /* Max # of unsuccessful connection attempts */
+extern char linkname[MAXPATHLEN]; /* logical name for link */
#ifdef PPP_FILTER
extern struct bpf_program pass_filter; /* Filter for pkts to pass */