summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ppp/command.c47
-rw-r--r--usr.sbin/ppp/main.c109
-rw-r--r--usr.sbin/ppp/ppp.810
-rw-r--r--usr.sbin/ppp/ppp.8.m410
-rw-r--r--usr.sbin/ppp/systems.c37
-rw-r--r--usr.sbin/ppp/systems.h4
6 files changed, 116 insertions, 101 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 3e20df7..0ef359b 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.173 1998/10/27 22:53:19 brian Exp $
+ * $Id: command.c,v 1.174 1998/10/27 22:53:22 brian Exp $
*
*/
#include <sys/types.h>
@@ -134,7 +134,7 @@
#define NEG_DNS 50
const char Version[] = "2.0";
-const char VersionDate[] = "$Date: 1998/10/27 22:53:19 $";
+const char VersionDate[] = "$Date: 1998/10/27 22:53:22 $";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
@@ -274,29 +274,32 @@ RenameCommand(struct cmdargs const *arg)
int
LoadCommand(struct cmdargs const *arg)
{
- const char *name;
+ const char *err;
+ int n, mode;
- if (arg->argc > arg->argn)
- name = arg->argv[arg->argn];
- else
- name = "default";
+ mode = arg->bundle->phys_type.all;
+
+ if (arg->argn < arg->argc) {
+ for (n = arg->argn; n < arg->argc; n++)
+ if ((err = system_IsValid(arg->argv[n], arg->prompt, mode)) != NULL) {
+ log_Printf(LogWARN, "%s: %s\n", arg->argv[n], err);
+ return 1;
+ }
- if (!system_IsValid(name, arg->prompt, arg->bundle->phys_type.all)) {
- log_Printf(LogWARN, "%s: Label not allowed\n", name);
+ for (n = arg->argn; n < arg->argc; n++) {
+ bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]);
+ system_Select(arg->bundle, arg->argv[n], CONFFILE, arg->prompt, arg->cx);
+ }
+ bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]);
+ } else if ((err = system_IsValid("default", arg->prompt, mode)) != NULL) {
+ log_Printf(LogWARN, "default: %s\n", err);
return 1;
} else {
- /*
- * Set the label before & after so that `set enddisc' works and
- * we handle nested `load' commands.
- */
- bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
- if (system_Select(arg->bundle, name, CONFFILE, arg->prompt, arg->cx) < 0) {
- bundle_SetLabel(arg->bundle, NULL);
- log_Printf(LogWARN, "%s: label not found.\n", name);
- return -1;
- }
- bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
+ bundle_SetLabel(arg->bundle, "default");
+ system_Select(arg->bundle, "default", CONFFILE, arg->prompt, arg->cx);
+ bundle_SetLabel(arg->bundle, "default");
}
+
return 0;
}
@@ -614,7 +617,7 @@ static struct cmdtab const Commands[] = {
{"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Deny option request", "deny option .."},
{"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
- "Dial and login", "dial|call [remote]", NULL},
+ "Dial and login", "dial|call [system ...]", NULL},
{"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Disable option", "disable option .."},
{"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
@@ -626,7 +629,7 @@ static struct cmdtab const Commands[] = {
{"link", "datalink", LinkCommand, LOCAL_AUTH,
"Link specific commands", "link name command ..."},
{"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
- "Load settings", "load [remote]"},
+ "Load settings", "load [system ...]"},
{"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
"Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1},
{"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 14aad68..218d193 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.143 1998/09/17 00:45:27 brian Exp $
+ * $Id: main.c,v 1.144 1998/10/22 02:32:49 brian Exp $
*
* TODO:
*/
@@ -179,27 +179,27 @@ Usage(void)
#ifndef NOALIAS
" [ -alias ]"
#endif
- " [system]\n");
+ " [system ...]\n");
exit(EX_START);
}
-static char *
+static int
ProcessArgs(int argc, char **argv, int *mode, int *alias)
{
- int optc, labelrequired, newmode;
+ int optc, newmode, arg;
char *cp;
- optc = labelrequired = 0;
+ optc = 0;
*mode = PHYS_INTERACTIVE;
*alias = 0;
- while (argc > 0 && **argv == '-') {
- cp = *argv + 1;
+ for (arg = 1; arg < argc && *argv[arg] == '-'; arg++, optc++) {
+ cp = argv[arg] + 1;
newmode = Nam2mode(cp);
switch (newmode) {
case PHYS_NONE:
if (strcmp(cp, "alias") == 0) {
#ifdef NOALIAS
- log_Printf(LogWARN, "Cannot load alias library\n");
+ log_Printf(LogWARN, "Cannot load alias library (compiled out)\n");
#else
*alias = 1;
#endif
@@ -212,23 +212,9 @@ ProcessArgs(int argc, char **argv, int *mode, int *alias)
Usage();
break;
- case PHYS_AUTO:
- case PHYS_BACKGROUND:
- case PHYS_DDIAL:
- labelrequired = 1;
- /* fall through */
-
default:
*mode = newmode;
}
- optc++;
- argv++;
- argc--;
- }
-
- if (argc > 1) {
- fprintf(stderr, "You may specify only one system label.\n");
- exit(EX_START);
}
if (optc > 1) {
@@ -236,20 +222,36 @@ ProcessArgs(int argc, char **argv, int *mode, int *alias)
exit(EX_START);
}
- if (labelrequired && argc != 1) {
- fprintf(stderr, "Destination system must be specified in"
- " auto, background or ddial mode.\n");
+ if (*mode == PHYS_AUTO && arg == argc) {
+ fprintf(stderr, "A system must be specified in auto mode.\n");
exit(EX_START);
}
- return argc == 1 ? *argv : NULL; /* Don't SetLabel yet ! */
+ return arg; /* Don't SetLabel yet ! */
+}
+
+static void
+CheckLabel(const char *label, struct prompt *prompt, int mode)
+{
+ const char *err;
+
+ if ((err = system_IsValid(label, prompt, mode)) != NULL) {
+ fprintf(stderr, "You may not use ppp in this mode with this label\n");
+ fprintf(stderr, "%s: %s\n", label, err);
+ if (mode == PHYS_DIRECT)
+ log_Printf(LogWARN, "Label %s rejected -direct connection: %s\n",
+ label, err);
+ log_Close();
+ exit(1);
+ }
}
+
int
main(int argc, char **argv)
{
- char *name, *label;
- int nfds, mode, alias;
+ char *name;
+ int nfds, mode, alias, label, arg;
struct bundle *bundle;
struct prompt *prompt;
@@ -269,7 +271,7 @@ main(int argc, char **argv)
#ifndef NOALIAS
PacketAliasInit();
#endif
- label = ProcessArgs(argc - 1, argv + 1, &mode, &alias);
+ label = ProcessArgs(argc, argv, &mode, &alias);
#ifdef __FreeBSD__
/*
@@ -313,16 +315,11 @@ main(int argc, char **argv)
} while (ptr >= conf);
}
- if (!system_IsValid(label, prompt, mode)) {
- fprintf(stderr, "You may not use ppp in this mode with this label\n");
- if (mode == PHYS_DIRECT) {
- const char *l;
- l = label ? label : "default";
- log_Printf(LogWARN, "Label %s rejected -direct connection\n", l);
- }
- log_Close();
- return 1;
- }
+ if (label < argc)
+ for (arg = label; arg < argc; arg++)
+ CheckLabel(argv[arg], prompt, mode);
+ else
+ CheckLabel("default", prompt, mode);
if ((bundle = bundle_Create(TUN_PREFIX, mode, (const char **)argv)) == NULL) {
log_Printf(LogWARN, "bundle_Create: %s\n", strerror(errno));
@@ -352,25 +349,21 @@ main(int argc, char **argv)
sig_signal(SIGUSR2, BringDownServer);
- if (label) {
- /*
- * Set label both before and after system_Select !
- * This way, "set enddisc label" works during system_Select, and we
- * also end up with the correct label if we have embedded load
- * commands.
- */
- bundle_SetLabel(bundle, label);
- if (system_Select(bundle, label, CONFFILE, prompt, NULL) < 0) {
- prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
- AbortProgram(EX_START);
- }
- bundle_SetLabel(bundle, label);
- if (mode == PHYS_AUTO &&
- bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
- prompt_Printf(prompt, "You must \"set ifaddr\" with a peer address "
- "in label %s for auto mode.\n", label);
- AbortProgram(EX_START);
- }
+ for (arg = label; arg < argc; arg++) {
+ /* In case we use LABEL or ``set enddisc label'' */
+ bundle_SetLabel(bundle, argv[argc - 1]);
+ system_Select(bundle, argv[arg], CONFFILE, prompt, NULL);
+ }
+
+ if (label < argc)
+ /* In case the last label did a ``load'' */
+ bundle_SetLabel(bundle, argv[argc - 1]);
+
+ if (mode == PHYS_AUTO &&
+ bundle->ncp.ipcp.cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
+ prompt_Printf(prompt, "You must ``set ifaddr'' with a peer address "
+ "in auto mode.\n");
+ AbortProgram(EX_START);
}
if (mode != PHYS_INTERACTIVE) {
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index e868941..2571a0a 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.131 1998/10/27 22:53:19 brian Exp $
+.\" $Id: ppp.8,v 1.132 1998/10/27 22:53:22 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -15,7 +15,7 @@
.Fl dedicated
.Oc
.Op Fl alias
-.Op Ar system
+.Op Ar system ...
.Sh DESCRIPTION
This is a user process
.Em PPP
@@ -2471,7 +2471,7 @@ will not complain if the route does not already exist.
.It dial|call Op Ar label
When used with no argument, this command is the same as the
.Dq open
-command. When
+command. When one or more
.Ar label
is specified, a
.Dq load
@@ -2572,9 +2572,9 @@ is
.Dq * ,
.Ar command
is executed on all links.
-.It load Op Ar label
+.It load Op Ar label ...
Load the given
-.Ar label
+.Ar label(s)
from the
.Pa ppp.conf
file. If
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index e868941..2571a0a 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.131 1998/10/27 22:53:19 brian Exp $
+.\" $Id: ppp.8,v 1.132 1998/10/27 22:53:22 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -15,7 +15,7 @@
.Fl dedicated
.Oc
.Op Fl alias
-.Op Ar system
+.Op Ar system ...
.Sh DESCRIPTION
This is a user process
.Em PPP
@@ -2471,7 +2471,7 @@ will not complain if the route does not already exist.
.It dial|call Op Ar label
When used with no argument, this command is the same as the
.Dq open
-command. When
+command. When one or more
.Ar label
is specified, a
.Dq load
@@ -2572,9 +2572,9 @@ is
.Dq * ,
.Ar command
is executed on all links.
-.It load Op Ar label
+.It load Op Ar label ...
Load the given
-.Ar label
+.Ar label(s)
from the
.Pa ppp.conf
file. If
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index 9962ed6..f786b1b 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.c,v 1.38 1998/06/15 19:06:25 brian Exp $
+ * $Id: systems.c,v 1.39 1998/10/17 12:28:03 brian Exp $
*
* TODO:
*/
@@ -156,7 +156,10 @@ DecodeCtrlCommand(char *line, char *arg)
return CTRL_UNKNOWN;
}
-/* Initialised in system_IsValid(), set in ReadSystem(), used by system_IsValid() */
+/*
+ * Initialised in system_IsValid(), set in ReadSystem(),
+ * used by system_IsValid()
+ */
static int modeok;
static int userok;
static int modereq;
@@ -341,22 +344,38 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
return -1;
}
-int
+const char *
system_IsValid(const char *name, struct prompt *prompt, int mode)
{
/*
* Note: The ReadSystem() calls only result in calls to the Allow*
* functions. arg->bundle will be set to NULL for these commands !
*/
- if (ID0realuid() == 0)
- return userok = modeok = 1;
+ int def;
+
+ if (ID0realuid() == 0) {
+ userok = modeok = 1;
+ return NULL;
+ }
+
+ def = !strcmp(name, "default");
userok = 0;
modeok = 1;
modereq = mode;
- ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL);
- if (name != NULL)
- ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL);
- return userok && modeok;
+
+ if (ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL) != 0 && def)
+ return "System not found";
+
+ if (!def && ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL) != 0)
+ return "System not found";
+
+ if (!userok)
+ return "Invalid user id";
+
+ if (!modeok)
+ return "Invalid mode";
+
+ return NULL;
}
int
diff --git a/usr.sbin/ppp/systems.h b/usr.sbin/ppp/systems.h
index 5d3c311..e85b865 100644
--- a/usr.sbin/ppp/systems.h
+++ b/usr.sbin/ppp/systems.h
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.h,v 1.11 1998/05/21 21:48:36 brian Exp $
+ * $Id: systems.h,v 1.12 1998/06/15 19:05:51 brian Exp $
*
*/
@@ -28,7 +28,7 @@ struct cmdargs;
extern int system_Select(struct bundle *bundle, const char *, const char *,
struct prompt *, struct datalink *);
-extern int system_IsValid(const char *, struct prompt *, int);
+extern const char *system_IsValid(const char *, struct prompt *, int);
extern FILE *OpenSecret(const char *);
extern void CloseSecret(FILE *);
extern int AllowUsers(struct cmdargs const *);
OpenPOWER on IntegriCloud