diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index 1bd6e2eb5e17..a125abcb3143 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id:$ + * $Id: auth.c,v 1.2 1995/02/26 12:17:12 amurai Exp $ * * TODO: * o Imprement check against with registerd IP addresses. @@ -35,13 +35,14 @@ LOCAL_AUTH_VALID LocalAuthInit(void){ char *p; - + if ( gethostname( VarShortHost, sizeof(VarShortHost))) { - return(1); + return(NOT_FOUND); } if ( p = strchr( VarShortHost, '.' ) ) *p = '\0'; + VarLocalAuth = LOCAL_NO_AUTH; return LocalAuthValidate( SECRETFILE, VarShortHost, "" ); } diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index c7e195111827..bcd14e069026 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:$ + * $Id: command.c,v 1.2 1995/02/26 12:17:22 amurai Exp $ * */ #include @@ -67,7 +67,7 @@ struct cmdtab *plist; if (argc > 0) { for (cmd = plist; cmd->name; cmd++) { - if (strcmp(cmd->name, *argv) == 0) { + if (strcmp(cmd->name, *argv) == 0 && (cmd->lauth & VarLocalAuth)) { printf("%s %s\n", cmd->name, cmd->syntax); return(1); } @@ -76,8 +76,8 @@ struct cmdtab *plist; } n = 0; for (cmd = plist; cmd->func; cmd++) { - c = (n & 1)? '\n' : '\t'; - if (cmd->name) { + if (cmd->name && (cmd->lauth & VarLocalAuth)) { + c = (n & 1)? '\n' : '\t'; printf(" %-8s: %-20s%c", cmd->name, cmd->helpmes, c); n++; } @@ -160,7 +160,7 @@ struct cmdtab Commands[] = { "Display option configs", StrNull}, { "enable", NULL, EnableCommand, LOCAL_AUTH, "Enable option", StrOption}, - { "passwd", NULL, LocalAuthCommand,LOCAL_NO_AUTH | LOCAL_NO_AUTH, + { "passwd", NULL, LocalAuthCommand,LOCAL_NO_AUTH, "Password for manupilation", StrOption}, { "load", NULL, LoadCommand, LOCAL_AUTH, "Load settings", StrRemote}, @@ -172,7 +172,7 @@ struct cmdtab Commands[] = { "Show status and statictics", "var"}, { "term", NULL, TerminalCommand,LOCAL_AUTH, "Enter to terminal mode", StrNull}, - { "quit", "bye", QuitCommand, LOCAL_AUTH, + { "quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH, "Quit PPP program", StrNull}, { "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, "Display this message", "[command]", (void *)Commands }, @@ -439,7 +439,7 @@ int argc; char **argv; { if (mode & (MODE_DIRECT|MODE_DEDICATED|MODE_AUTO)) { - if (argc > 0) { + if (argc > 0 && (VarLocalAuth & LOCAL_AUTH)) { Cleanup(EX_NORMAL); } else { VarLocalAuth = LOCAL_NO_AUTH; diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 58a44386a871..e30ab4043d9a 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:$ + * $Id: main.c,v 1.2 1995/02/26 12:17:41 amurai Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -41,6 +41,9 @@ #include "vars.h" #include "auth.h" +#define LAUTH_M1 "Warning: No password entry for this host in ppp.secret\n" +#define LAUTH_M2 "Warning: All manipulation is allowed by anyone in a world\n" + #ifndef O_NONBLOCK #ifdef O_NDELAY #define O_NONBLOCK O_NDELAY @@ -242,8 +245,11 @@ char **argv; switch ( LocalAuthInit() ) { case NOT_FOUND: - fprintf(stderr, "Warning: No password entry in secret file\n"); - fprintf(stderr, "Warning: Anyone is allowd manipulating!!!\n"); + fprintf(stderr,LAUTH_M1); + fprintf(stderr,LAUTH_M2); + fflush (stderr); + /* Fall down */ + case VALID: VarLocalAuth = LOCAL_AUTH; break; default: @@ -409,7 +415,6 @@ ReadTty() #ifdef DEBUG logprintf("connection closed.\n"); #endif - VarLocalAuth = LOCAL_NO_AUTH; close(netfd); netfd = -1; mode &= ~MODE_INTER; @@ -639,6 +644,18 @@ DoLoop() perror("dup2"); mode |= MODE_INTER; Greetings(); + switch ( LocalAuthInit() ) { + case NOT_FOUND: + fprintf(stdout,LAUTH_M1); + fprintf(stdout,LAUTH_M2); + fflush(stdout); + /* Fall down */ + case VALID: + VarLocalAuth = LOCAL_AUTH; + break; + default: + break; + } (void) IsInteractive(); Prompt(0); } diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index f9638a278391..56a73ba7097e 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id:$ + * $Id: modem.c,v 1.2 1995/02/26 12:17:45 amurai Exp $ * * TODO: */ @@ -26,6 +26,7 @@ #include #include #include +#include #include "hdlc.h" #include "lcp.h" #include "modem.h" @@ -43,7 +44,7 @@ static int mbits; /* Current DCD status */ static int connect_time; /* connection time */ static int connect_count; static struct pppTimer ModemTimer; -static char *uucplock; +static char uucplock[10]; extern int uu_lock(), uu_unlock(); extern void PacketMode(); @@ -142,7 +143,7 @@ static struct speeds{ #ifdef B38400 { 38400, B38400, }, #endif -#ifndef POSIX_SOURCE +#ifndef _POSIX_SOURCE #ifdef B7200 { 7200, B7200, }, #endif @@ -372,7 +373,7 @@ int mode; modem = open(ctermid(NULL), O_RDWR|O_NONBLOCK); } else if (modem == 0) { if (strncmp(VarDevice, "/dev", 4) == 0) { - uucplock = rindex(VarDevice, '/')+1; + strcpy(uucplock, rindex(VarDevice, '/')+1); if (uu_lock(uucplock) < 0) { fprintf(stderr, "modem is in use.\n"); return(-1); @@ -676,8 +677,10 @@ int fd; logprintf(" mbfree\n"); #endif } - } else if (nw < 0) - perror("modem write"); + } else if (nw < 0) { + if (errno != EAGAIN) + perror("modem write"); + } } }