summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/vars.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-06-09 03:27:43 +0000
committerbrian <brian@FreeBSD.org>1997-06-09 03:27:43 +0000
commit94d661ac8cb907e0a869759f76cd7134c9105e6c (patch)
tree5fa88c28cbdec0d4a0d3d118b33c1042dc49c526 /usr.sbin/ppp/vars.c
parent328d28c6502cfec45b8ead98e18b2d8638499efb (diff)
downloadFreeBSD-src-94d661ac8cb907e0a869759f76cd7134c9105e6c.zip
FreeBSD-src-94d661ac8cb907e0a869759f76cd7134c9105e6c.tar.gz
Overhaul ppp:
o Use syslog o Remove references to stdout/stderr (incl perror()) o Introduce VarTerm - the interactive terminal or zero o Allow "set timeout" to affect current session o Change "set debug" to "set log" o Allow "set log [+|-]flag" o Make MSEXT and PASSWDAUTH stuff the default o Move all #ifdef DEBUG stuff into the code - this shouldn't be too much overhead. It's now controlled with "set log +debug" o Add "set log command, debug, tun, warn, error, alert" o Remove cdefs.h, and assume an ansi compiler. o Improve all diagnostic output o Don't trap SIGSEGV o SIGHUP now terminates again (log files are controlled by syslog) o Call CloseModem() when changing devices o Fix parsing of third arg of "delete" I think this fixes the "magic is same" problems that some people have been experiencing. The man page is being rewritten. It'll follow soon.
Diffstat (limited to 'usr.sbin/ppp/vars.c')
-rw-r--r--usr.sbin/ppp/vars.c151
1 files changed, 50 insertions, 101 deletions
diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c
index f9e4d1d..918fb7d 100644
--- a/usr.sbin/ppp/vars.c
+++ b/usr.sbin/ppp/vars.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vars.c,v 1.17 1997/05/26 00:44:09 brian Exp $
+ * $Id: vars.c,v 1.18 1997/06/01 01:13:03 brian Exp $
*
*/
#include "fsm.h"
@@ -30,7 +30,7 @@
#include "defs.h"
char VarVersion[] = "Version 0.94";
-char VarLocalVersion[] = "$Date: 1997/05/26 00:44:09 $";
+char VarLocalVersion[] = "$Date: 1997/06/01 01:13:03 $";
/*
* Order of conf option is important. See vars.h.
@@ -53,7 +53,7 @@ struct pppvars pppVars = {
DEF_MRU, DEF_MTU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3,
RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD,
NEXT_REDIAL_PERIOD, 1, MODEM_DEV, BASE_MODEM_DEV,
- OPEN_ACTIVE, LOCAL_NO_AUTH,
+ OPEN_ACTIVE, LOCAL_NO_AUTH,0
};
int
@@ -61,122 +61,73 @@ DisplayCommand()
{
struct confdesc *vp;
- printf("Current configuration option settings..\n\n");
- printf("Name\t\tMy Side\t\tHis Side\n");
- printf("----------------------------------------\n");
+ if (!VarTerm)
+ return 1;
+
+ fprintf(VarTerm, "Current configuration option settings..\n\n");
+ fprintf(VarTerm, "Name\t\tMy Side\t\tHis Side\n");
+ fprintf(VarTerm, "----------------------------------------\n");
for (vp = pppConfs; vp->name; vp++)
- printf("%-10s\t%s\t\t%s\n", vp->name,
+ fprintf(VarTerm, "%-10s\t%s\t\t%s\n", vp->name,
(vp->myside == CONF_ENABLE)? "enable" : "disable",
(vp->hisside == CONF_ACCEPT)? "accept" : "deny");
- return(1);
+
+ return 0;
}
-int
-DisableCommand(list, argc, argv)
-struct cmdtab *list;
-int argc;
-char **argv;
+static int
+ConfigCommand(struct cmdtab *list, int argc, char **argv, int mine, int val)
{
struct confdesc *vp;
- int found = FALSE;
+ int err;
- if (argc < 1) {
- printf("disable what?\n");
- return(1);
- }
+ if (argc < 1)
+ return -1;
+
+ err = 0;
do {
- for (vp = pppConfs; vp->name; vp++) {
+ for (vp = pppConfs; vp->name; vp++)
if (strcasecmp(vp->name, *argv) == 0) {
- vp->myside = CONF_DISABLE;
- found = TRUE;
+ if (mine)
+ vp->myside = val;
+ else
+ vp->hisside = val;
+ break;
}
+
+ if (!vp->name) {
+ LogPrintf(LogWARN, "Config: %s: No such key word\n", *argv );
+ err++;
}
- if ( found == FALSE )
- printf("%s - No such key word\n", *argv );
- argc--; argv++;
+ argc--;
+ argv++;
} while (argc > 0);
- return(1);
+
+ return err;
}
int
-EnableCommand(list, argc, argv)
-struct cmdtab *list;
-int argc;
-char **argv;
+EnableCommand(struct cmdtab *list, int argc, char **argv)
{
- struct confdesc *vp;
- int found = FALSE;
-
- if (argc < 1) {
- printf("enable what?\n");
- return(1);
- }
- do {
- for (vp = pppConfs; vp->name; vp++) {
- if (strcasecmp(vp->name, *argv) == 0) {
- vp->myside = CONF_ENABLE;
- found = TRUE;
- }
- }
- if ( found == FALSE )
- printf("%s - No such key word\n", *argv );
- argc--; argv++;
- } while (argc > 0);
- return(1);
+ return ConfigCommand(list, argc, argv, 1, CONF_ENABLE);
}
int
-AcceptCommand(list, argc, argv)
-struct cmdtab *list;
-int argc;
-char **argv;
+DisableCommand(struct cmdtab *list, int argc, char **argv)
{
- struct confdesc *vp;
- int found = FALSE;
-
- if (argc < 1) {
- printf("accept what?\n");
- return(1);
- }
- do {
- for (vp = pppConfs; vp->name; vp++) {
- if (strcasecmp(vp->name, *argv) == 0) {
- vp->hisside = CONF_ACCEPT;
- found = TRUE;
- }
- }
- if ( found == FALSE )
- printf("%s - No such key word\n", *argv );
- argc--; argv++;
- } while (argc > 0);
- return(1);
+ return ConfigCommand(list, argc, argv, 1, CONF_DISABLE);
}
int
-DenyCommand(list, argc, argv)
-struct cmdtab *list;
-int argc;
-char **argv;
+AcceptCommand(struct cmdtab *list, int argc, char **argv)
{
- struct confdesc *vp;
- int found = FALSE;
+ return ConfigCommand(list, argc, argv, 0, CONF_ACCEPT);
+}
- if (argc < 1) {
- printf("enable what?\n");
- return(1);
- }
- do {
- for (vp = pppConfs; vp->name; vp++) {
- if (strcasecmp(vp->name, *argv) == 0) {
- vp->hisside = CONF_DENY;
- found = TRUE;
- }
- }
- if ( found == FALSE )
- printf("%s - No such key word\n", *argv );
- argc--; argv++;
- } while (argc > 0);
- return(1);
+int
+DenyCommand(struct cmdtab *list, int argc, char **argv)
+{
+ return ConfigCommand(list, argc, argv, 0, CONF_DENY);
}
int
@@ -185,10 +136,8 @@ struct cmdtab *list;
int argc;
char **argv;
{
- if (argc < 1) {
- printf("Please Enter passwd for manipulating.\n");
- return(1);
- }
+ if (argc != 1)
+ return -1;
switch ( LocalAuthValidate( SECRETFILE, VarShortHost, *argv ) ) {
case INVALID:
@@ -199,12 +148,12 @@ char **argv;
break;
case NOT_FOUND:
pppVars.lauth = LOCAL_AUTH;
- printf("WARING: No Entry for this system\n");
+ LogPrintf(LogWARN, "WARING: No Entry for this system\n");
break;
default:
pppVars.lauth = LOCAL_NO_AUTH;
- printf("Ooops?\n");
- break;
+ LogPrintf(LogERROR, "LocalAuthCommand: Ooops?\n");
+ return 1;
}
- return(1);
+ return 0;
}
OpenPOWER on IntegriCloud