From 846af6dc99519ef1bec1d0674ded8799548ddd5a Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Fri, 8 May 1998 18:50:24 +0000 Subject: [PATCH] o When specifying the diagnostic port (`set server'), replace the first ``%d'' in the unix-domain socket name with the current interface unit number. In the case of tcp ports, allow a ``+'' prefix to add the unit number to the specified port number. o Remove all mention of SIGUSR1 (was already #ifdef'd out). We can't create diagnostic sockets on-the-fly with a signal any more because there's no way of specifying the password without confusing matters with the previous ppp.secret scenario. --- usr.sbin/ppp/command.c | 26 ++++++++++++++++++++++---- usr.sbin/ppp/main.c | 19 +------------------ usr.sbin/ppp/ppp.8 | 40 ++++++++++++++++++++++------------------ 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index ab7340ada793..e5974cb09cc3 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.131.2.79 1998/05/06 23:50:06 brian Exp $ + * $Id: command.c,v 1.131.2.80 1998/05/08 18:49:53 brian Exp $ * */ #include @@ -123,7 +123,7 @@ #define NEG_DNS 50 const char Version[] = "2.0-beta"; -const char VersionDate[] = "$Date: 1998/05/06 23:50:06 $"; +const char VersionDate[] = "$Date: 1998/05/08 18:49:53 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -926,6 +926,7 @@ SetServer(struct cmdargs const *arg) if (*port == '/') { mode_t imask; + char *ptr, name[LINE_LEN + 12]; if (mask != NULL) { unsigned m; @@ -936,13 +937,24 @@ SetServer(struct cmdargs const *arg) return -1; } else imask = (mode_t)-1; + + ptr = strstr(port, "%d"); + if (ptr) { + snprintf(name, sizeof name, "%.*s%d%s", + ptr - port, port, arg->bundle->unit, ptr + 2); + port = name; + } res = server_LocalOpen(arg->bundle, port, imask); } else { - int iport; + int iport, add = 0; if (mask != NULL) return -1; + if (*port == '+') { + port++; + add = 1; + } if (strspn(port, "0123456789") != strlen(port)) { struct servent *s; @@ -953,7 +965,13 @@ SetServer(struct cmdargs const *arg) iport = ntohs(s->s_port); } else iport = atoi(port); - res = iport ? server_TcpOpen(arg->bundle, iport) : -1; + + if (iport) { + if (add) + iport += arg->bundle->unit; + res = server_TcpOpen(arg->bundle, iport); + } else + res = -1; } } diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 20625ae244c9..1ac9ac453ae0 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.121.2.56 1998/05/06 18:50:09 brian Exp $ + * $Id: main.c,v 1.121.2.57 1998/05/08 01:15:11 brian Exp $ * * TODO: */ @@ -147,20 +147,6 @@ TerminalStop(int signo) raise(SIGSTOP); } -#if 0 /* What's our passwd :-O */ -static void -SetUpServer(int signo) -{ - int res; - - VarHaveLocalAuthKey = 0; - LocalAuthInit(); - if ((res = ServerTcpOpen(SERVER_PORT + SignalBundle->unit)) != 0) - log_Printf(LogERROR, "SIGUSR1: Failed %d to open port %d\n", - res, SERVER_PORT + SignalBundle->unit); -} -#endif - static void BringDownServer(int signo) { @@ -362,9 +348,6 @@ main(int argc, char **argv) if (mode == PHYS_MANUAL) sig_signal(SIGTSTP, TerminalStop); -#if 0 /* What's our passwd :-O */ - sig_signal(SIGUSR1, SetUpServer); -#endif sig_signal(SIGUSR2, BringDownServer); if (label) { diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 5f2729d233b4..cdfcdd2d8b1c 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.97.2.28 1998/05/05 23:30:09 brian Exp $ +.\" $Id: ppp.8,v 1.97.2.29 1998/05/08 18:49:59 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -569,10 +569,10 @@ configuration by using the .Dq set server command in .Pa /etc/ppp/ppp.conf , -.Pq for example, Dq set server 3000 mypasswd +.Pq for example, Dq set server +3000 mypasswd and connecting to the diagnostic port as follows: .Bd -literal -offset indent -# pppctl 3000 +# pppctl 3000 (assuming tun0 - see the ``set server'' description) Password: PPP ON awfulhak> show who tcp (127.0.0.1:1028) * @@ -1605,17 +1605,11 @@ mode. These signals tell .Nm to exit. -.It USR1 -This signal, when not in interactive mode, tells -.Nm -to close any existing server socket and open an Internet socket using -port 3000 plus the current tunnel device number. This can only be -achieved if a suitable local password is specified in -.Pa /etc/ppp/ppp.secret . .It USR2 This signal, tells .Nm -to close any existing server socket. +to close any existing server socket, dropping all existing diagnostic +connections. .El .Pp .Sh PPP COMMAND LIST @@ -2234,9 +2228,7 @@ command). .Ar Pass is specified on the .Dq set server -command line (see -.Dq set server -below). The value of +command line. The value of .Ar pass is not logged when .Ar command @@ -2780,10 +2772,22 @@ for umask details. Refer to .Xr services 5 for details of how to translate TCP port names. .Pp -You must also specify the password that must be used by the client when -connecting to this socket. -If a password is specified as the empty string, -no password is required of connecting clients. +You must also specify the password that must be entered by the client +(using the +.Dq passwd +command above) when connecting to this socket. If the password is +specified as an empty string, no password is required for connecting clients. +.Pp +When specifying a unix domain socket, the first +.Dq %d +sequence found in the socket name will be replaced with the current +interface unit number. This is useful when you wish to use the same +profile for more than one connection. +.Pp +In a similar manner TCP sockets may be prefixed with the +.Dq + +character, in which case the current interface unit number is added to +the port number. .Pp When using .Nm