Fixing minor bug and allow help(Not for all command) and quit

but not close line connection by "quit all" command if not
authorized.

Reviewed by:	amurai@spec.co.jp
Submitted by:	tony-o@iij.ad.jp amurai@spec.co.jp
This commit is contained in:
Atsushi Murai 1995-02-27 10:57:54 +00:00
parent ce83f1d6d8
commit 41db65649e
4 changed files with 41 additions and 20 deletions

View File

@ -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.
@ -37,11 +37,12 @@ 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, "" );
}

View File

@ -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 <ctype.h>
@ -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++) {
if (cmd->name && (cmd->lauth & VarLocalAuth)) {
c = (n & 1)? '\n' : '\t';
if (cmd->name) {
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;

View File

@ -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);
}

View File

@ -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 <termios.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <errno.h>
#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,9 +677,11 @@ int fd;
logprintf(" mbfree\n");
#endif
}
} else if (nw < 0)
} else if (nw < 0) {
if (errno != EAGAIN)
perror("modem write");
}
}
}
int