1/* 2 * PPP Secret Key Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: auth.c,v 1.5 1995/09/02 17:20:49 amurai Exp $ |
21 * 22 * TODO: 23 * o Implement check against with registered IP addresses. 24 */ 25#include "fsm.h" 26#include "lcpproto.h" 27#include "ipcp.h" 28#include "vars.h" |
29#include "filter.h" |
30#include "auth.h" |
31#include "chat.h" |
32 33extern FILE *OpenSecret(); 34extern void CloseSecret(); 35 36LOCAL_AUTH_VALID |
37LocalAuthInit(void) 38{ |
39 40 char *p; 41 42 if ( gethostname( VarShortHost, sizeof(VarShortHost))) { 43 return(NOT_FOUND); 44 } |
45 p = strchr( VarShortHost, '.' ); 46 if (p) |
47 *p = '\0'; 48 49 VarLocalAuth = LOCAL_NO_AUTH; 50 return LocalAuthValidate( SECRETFILE, VarShortHost, "" ); 51 52} 53 54LOCAL_AUTH_VALID --- 8 unchanged lines hidden (view full) --- 63 fp = OpenSecret(fname); 64 if (fp == NULL) 65 return( rc ); 66 while (fgets(buff, sizeof(buff), fp)) { 67 if (buff[0] == '#') 68 continue; 69 buff[strlen(buff)-1] = 0; 70 bzero(vector, sizeof(vector)); |
71 n = MakeArgs(buff, vector); |
72 if (n < 1) 73 continue; 74 if (strcmp(vector[0], system) == 0) { 75 if ( vector[1] != (char *) NULL && strcmp(vector[1], key) == 0) { 76 rc = VALID; /* Valid */ 77 } else { 78 rc = INVALID; /* Invalid */ 79 } --- 17 unchanged lines hidden (view full) --- 97 fp = OpenSecret(fname); 98 if (fp == NULL) 99 return(0); 100 while (fgets(buff, sizeof(buff), fp)) { 101 if (buff[0] == '#') 102 continue; 103 buff[strlen(buff)-1] = 0; 104 bzero(vector, sizeof(vector)); |
105 n = MakeArgs(buff, vector); |
106 if (n < 2) 107 continue; 108 if (strcmp(vector[0], system) == 0) { 109 ExpandString(vector[1], passwd, 0); 110 if (strcmp(passwd, key) == 0) { 111 CloseSecret(fp); 112 bzero(&DefHisAddress, sizeof(DefHisAddress)); 113 n -= 2; --- 24 unchanged lines hidden (view full) --- 138 fp = OpenSecret(fname); 139 if (fp == NULL) 140 return(NULL); 141 while (fgets(buff, sizeof(buff), fp)) { 142 if (buff[0] == '#') 143 continue; 144 buff[strlen(buff)-1] = 0; 145 bzero(vector, sizeof(vector)); |
146 n = MakeArgs(buff, vector); |
147 if (n < 2) 148 continue; 149 if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) { 150 ExpandString(vector[1], passwd, 0); 151 if (setaddr) { 152 bzero(&DefHisAddress, sizeof(DefHisAddress)); 153 } 154 n -= 2; --- 53 unchanged lines hidden --- |