Deleted Added
full compact
auth.c (10528) auth.c (13389)
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 *
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.4 1995/05/30 03:50:25 rgrimes Exp $
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"
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"
29#include "auth.h"
30#include "auth.h"
31#include "chat.h"
30
31extern FILE *OpenSecret();
32extern void CloseSecret();
33
34LOCAL_AUTH_VALID
32
33extern FILE *OpenSecret();
34extern void CloseSecret();
35
36LOCAL_AUTH_VALID
35LocalAuthInit(void){
37LocalAuthInit(void)
38{
36
37 char *p;
38
39 if ( gethostname( VarShortHost, sizeof(VarShortHost))) {
40 return(NOT_FOUND);
41 }
39
40 char *p;
41
42 if ( gethostname( VarShortHost, sizeof(VarShortHost))) {
43 return(NOT_FOUND);
44 }
42 if ( p = strchr( VarShortHost, '.' ) )
45 p = strchr( VarShortHost, '.' );
46 if (p)
43 *p = '\0';
44
45 VarLocalAuth = LOCAL_NO_AUTH;
46 return LocalAuthValidate( SECRETFILE, VarShortHost, "" );
47
48}
49
50LOCAL_AUTH_VALID

--- 8 unchanged lines hidden (view full) ---

59 fp = OpenSecret(fname);
60 if (fp == NULL)
61 return( rc );
62 while (fgets(buff, sizeof(buff), fp)) {
63 if (buff[0] == '#')
64 continue;
65 buff[strlen(buff)-1] = 0;
66 bzero(vector, sizeof(vector));
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));
67 n = MakeArgs(buff, &vector);
71 n = MakeArgs(buff, vector);
68 if (n < 1)
69 continue;
70 if (strcmp(vector[0], system) == 0) {
71 if ( vector[1] != (char *) NULL && strcmp(vector[1], key) == 0) {
72 rc = VALID; /* Valid */
73 } else {
74 rc = INVALID; /* Invalid */
75 }

--- 17 unchanged lines hidden (view full) ---

93 fp = OpenSecret(fname);
94 if (fp == NULL)
95 return(0);
96 while (fgets(buff, sizeof(buff), fp)) {
97 if (buff[0] == '#')
98 continue;
99 buff[strlen(buff)-1] = 0;
100 bzero(vector, sizeof(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));
101 n = MakeArgs(buff, &vector);
105 n = MakeArgs(buff, vector);
102 if (n < 2)
103 continue;
104 if (strcmp(vector[0], system) == 0) {
105 ExpandString(vector[1], passwd, 0);
106 if (strcmp(passwd, key) == 0) {
107 CloseSecret(fp);
108 bzero(&DefHisAddress, sizeof(DefHisAddress));
109 n -= 2;

--- 24 unchanged lines hidden (view full) ---

134 fp = OpenSecret(fname);
135 if (fp == NULL)
136 return(NULL);
137 while (fgets(buff, sizeof(buff), fp)) {
138 if (buff[0] == '#')
139 continue;
140 buff[strlen(buff)-1] = 0;
141 bzero(vector, sizeof(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));
142 n = MakeArgs(buff, &vector);
146 n = MakeArgs(buff, vector);
143 if (n < 2)
144 continue;
145 if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) {
146 ExpandString(vector[1], passwd, 0);
147 if (setaddr) {
148 bzero(&DefHisAddress, sizeof(DefHisAddress));
149 }
150 n -= 2;

--- 53 unchanged lines hidden ---
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 ---