annotate packages/net/ppp/current/src/auth.c @ 1628:2e1811d4f88c

* src/auth.c: Don't use non-eCos <paths.h> * src/pppd.c: Don't use non-eCos <sys/wait.h> and <sys/resource.h> * src/sys-ecos.c: netmask must be extern - not all tools have COMMON section support.
author jlarmour
date Thu, 06 May 2004 13:54:56 +0000
parents e0d88dc6a92f
children 5629b7c30ed2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
1 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
2 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
3 // src/auth.c
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
4 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
5 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
6 //####ECOSGPLCOPYRIGHTBEGIN####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
7 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
8 // This file is part of eCos, the Embedded Configurable Operating System.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
9 // Portions created by Nick Garnett are
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
10 // Copyright (C) 2003 eCosCentric Ltd.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
11 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
12 // eCos is free software; you can redistribute it and/or modify it under
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
13 // the terms of the GNU General Public License as published by the Free
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
14 // Software Foundation; either version 2 or (at your option) any later version.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
15 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
16 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
17 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
18 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
19 // for more details.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
20 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
21 // You should have received a copy of the GNU General Public License along
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
22 // with eCos; if not, write to the Free Software Foundation, Inc.,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
23 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
24 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
25 // As a special exception, if other files instantiate templates or use macros
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
26 // or inline functions from this file, or you compile this file and link it
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
27 // with other works to produce a work based on this file, this file does not
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
28 // by itself cause the resulting work to be covered by the GNU General Public
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
29 // License. However the source code for this file must still be made available
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
30 // in accordance with section (3) of the GNU General Public License.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
31 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
32 // This exception does not invalidate any other reasons why a work based on
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
33 // this file might be covered by the GNU General Public License.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
34 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
35 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
36 //####ECOSGPLCOPYRIGHTEND####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
37 //####BSDCOPYRIGHTBEGIN####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
38 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
39 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
40 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
41 // Portions of this software may have been derived from OpenBSD,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
42 // FreeBSD or other sources, and are covered by the appropriate
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
43 // copyright disclaimers included herein.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
44 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
45 // -------------------------------------------
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
46 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
47 //####BSDCOPYRIGHTEND####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
48 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
49
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
50 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
51 * auth.c - PPP authentication and phase control.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
52 *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
53 * Copyright (c) 1993 The Australian National University.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
54 * All rights reserved.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
55 *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
56 * Redistribution and use in source and binary forms are permitted
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
57 * provided that the above copyright notice and this paragraph are
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
58 * duplicated in all such forms and that any documentation,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
59 * advertising materials, and other materials related to such
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
60 * distribution and use acknowledge that the software was developed
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
61 * by the Australian National University. The name of the University
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
62 * may not be used to endorse or promote products derived from this
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
63 * software without specific prior written permission.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
64 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
65 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
66 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
67 *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
68 * Copyright (c) 1989 Carnegie Mellon University.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
69 * All rights reserved.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
70 *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
71 * Redistribution and use in source and binary forms are permitted
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
72 * provided that the above copyright notice and this paragraph are
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
73 * duplicated in all such forms and that any documentation,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
74 * advertising materials, and other materials related to such
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
75 * distribution and use acknowledge that the software was developed
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
76 * by Carnegie Mellon University. The name of the
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
77 * University may not be used to endorse or promote products derived
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
78 * from this software without specific prior written permission.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
79 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
80 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
81 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
82 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
83
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
84 #ifndef lint
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
85 //static char rcsid[] = "$FreeBSD: src/usr.sbin/pppd/auth.c,v 1.24.2.1 2000/12/11 01:03:37 obrien Exp $";
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
86 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
87
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
88 #include <stdio.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
89 #include <stddef.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
90 #include <stdlib.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
91 #include <unistd.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
92 #include <cyg/ppp/syslog.h>
1628
2e1811d4f88c * src/auth.c: Don't use non-eCos <paths.h>
jlarmour
parents: 1586
diff changeset
93 #ifndef __ECOS
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
94 #include <paths.h>
1628
2e1811d4f88c * src/auth.c: Don't use non-eCos <paths.h>
jlarmour
parents: 1586
diff changeset
95 #endif
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
96 //#include <pwd.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
97 #include <string.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
98 #include <sys/types.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
99 #include <sys/stat.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
100 #include <sys/socket.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
101 //#include <utmp.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
102 #include <fcntl.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
103 #if defined(_PATH_LASTLOG) && defined(_linux_)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
104 #include <lastlog.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
105 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
106
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
107 #include <netdb.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
108 #include <netinet/in.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
109 #include <arpa/inet.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
110 #include <sys/time.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
111 //#include <utmp.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
112
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
113 #ifdef USE_PAM
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
114 #include <security/pam_appl.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
115 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
116
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
117 #ifdef HAS_SHADOW
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
118 #include <shadow.h>
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
119 #ifndef PW_PPP
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
120 #define PW_PPP PW_LOGIN
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
121 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
122 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
123
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
124 #include "cyg/ppp/pppd.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
125 #include "cyg/ppp/fsm.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
126 #include "cyg/ppp/lcp.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
127 #include "cyg/ppp/ipcp.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
128 #include "cyg/ppp/upap.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
129 #include "cyg/ppp/chap.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
130 #ifdef CBCP_SUPPORT
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
131 #include "cyg/ppp/cbcp.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
132 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
133 //#include "cyg/ppp/pathnames.h"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
134
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
135 /* Used for storing a sequence of words. Usually malloced. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
136 struct wordlist {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
137 struct wordlist *next;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
138 char word[1];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
139 };
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
140
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
141 /* Bits in scan_authfile return value */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
142 #define NONWILD_SERVER 1
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
143 #define NONWILD_CLIENT 2
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
144
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
145 #define ISWILD(word) (word[0] == '*' && word[1] == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
146
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
147 #define FALSE 0
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
148 #define TRUE 1
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
149
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
150 /* The name by which the peer authenticated itself to us. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
151 char peer_authname[MAXNAMELEN];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
152
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
153 /* Records which authentication operations haven't completed yet. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
154 static int auth_pending[NUM_PPP];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
155
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
156 /* Set if we have successfully called plogin() */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
157 //static int logged_in;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
158
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
159 /* Set if not wild or blank */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
160 //static int non_wildclient;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
161
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
162 /* Set if we have run the /etc/ppp/auth-up script. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
163 //static int did_authup;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
164
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
165 /* List of addresses which the peer may use. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
166 static struct wordlist *addresses[NUM_PPP];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
167
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
168 /* Number of network protocols which we have opened. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
169 static int num_np_open;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
170
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
171 /* Number of network protocols which have come up. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
172 static int num_np_up;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
173
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
174 /* Set if we got the contents of passwd[] from the pap-secrets file. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
175 static int passwd_from_file;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
176
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
177 /* Bits in auth_pending[] */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
178 #define PAP_WITHPEER 1
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
179 #define PAP_PEER 2
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
180 #define CHAP_WITHPEER 4
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
181 #define CHAP_PEER 8
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
182
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
183 extern char *crypt __P((const char *, const char *));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
184
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
185 /* Prototypes for procedures local to this file. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
186
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
187 static void network_phase __P((int));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
188 static void check_idle __P((void *));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
189 static void connect_time_expired __P((void *));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
190 static int null_login __P((int));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
191 static int get_pap_passwd __P((char *));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
192 static int have_pap_secret __P((void));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
193 static int have_chap_secret __P((char *, char *, u_int32_t));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
194 static int ip_addr_check __P((u_int32_t, struct wordlist *));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
195
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
196 static void auth_set_ip_addr __P((int));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
197
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
198 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
199 * An Open on LCP has requested a change from Dead to Establish phase.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
200 * Do what's necessary to bring the physical layer up.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
201 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
202 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
203 link_required(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
204 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
205 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
206 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
207
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
208 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
209 * LCP has terminated the link; go to the Dead phase and take the
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
210 * physical layer down.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
211 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
212 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
213 link_terminated(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
214 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
215 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
216 extern time_t etime, stime;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
217 extern int minutes;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
218
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
219 db_printf("%s()\n",__PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
220 if (phase == PHASE_DEAD)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
221 return;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
222 phase = PHASE_DEAD;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
223 etime = time((time_t *) NULL);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
224 minutes = (etime-stime)/60;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
225 syslog(LOG_NOTICE, "Connection terminated, connected for %d minutes\n",
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
226 minutes > 1 ? minutes : 1);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
227 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
228
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
229 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
230 * LCP has gone down; it will either die or try to re-establish.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
231 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
232 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
233 link_down(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
234 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
235 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
236 int i;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
237 struct protent *protp;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
238
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
239 db_printf("%s()\n",__PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
240 for (i = 0; (protp = protocols[i]) != NULL; ++i) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
241 if (!protp->enabled_flag)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
242 continue;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
243 if (protp->protocol != PPP_LCP && protp->lowerdown != NULL)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
244 (*protp->lowerdown)(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
245 if (protp->protocol < 0xC000 && protp->close != NULL)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
246 (*protp->close)(unit, "LCP down");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
247 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
248 num_np_open = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
249 num_np_up = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
250 if (phase != PHASE_DEAD)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
251 phase = PHASE_TERMINATE;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
252 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
253
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
254 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
255 * The link is established.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
256 * Proceed to the Dead, Authenticate or Network phase as appropriate.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
257 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
258 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
259 link_established(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
260 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
261 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
262 int auth;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
263 lcp_options *wo = &lcp_wantoptions[unit];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
264 lcp_options *go = &lcp_gotoptions[unit];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
265 lcp_options *ho = &lcp_hisoptions[unit];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
266 int i;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
267 struct protent *protp;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
268
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
269 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
270 * Tell higher-level protocols that LCP is up.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
271 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
272 for (i = 0; (protp = protocols[i]) != NULL; ++i)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
273 if (protp->protocol != PPP_LCP && protp->enabled_flag
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
274 && protp->lowerup != NULL)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
275 (*protp->lowerup)(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
276
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
277 if (auth_required && !(go->neg_chap || go->neg_upap)) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
278 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
279 * We wanted the peer to authenticate itself, and it refused:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
280 * treat it as though it authenticated with PAP using a username
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
281 * of "" and a password of "". If that's not OK, boot it out.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
282 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
283 if (!wo->neg_upap || !null_login(unit)) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
284 syslog(LOG_WARNING, "peer refused to authenticate");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
285 lcp_close(unit, "peer refused to authenticate");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
286 return;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
287 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
288 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
289
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
290 phase = PHASE_AUTHENTICATE;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
291 auth = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
292 if (go->neg_chap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
293 ChapAuthPeer(unit, our_name, go->chap_mdtype);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
294 auth |= CHAP_PEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
295 } else if (go->neg_upap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
296 upap_authpeer(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
297 auth |= PAP_PEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
298 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
299 if (ho->neg_chap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
300 ChapAuthWithPeer(unit, user, ho->chap_mdtype);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
301 auth |= CHAP_WITHPEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
302 } else if (ho->neg_upap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
303 if (passwd[0] == 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
304 passwd_from_file = 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
305 if (!get_pap_passwd(passwd))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
306 syslog(LOG_ERR, "No secret found for PAP login");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
307 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
308 upap_authwithpeer(unit, user, passwd);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
309 auth |= PAP_WITHPEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
310 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
311 auth_pending[unit] = auth;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
312
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
313 if (!auth)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
314 network_phase(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
315 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
316
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
317 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
318 * Proceed to the network phase.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
319 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
320 static void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
321 network_phase(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
322 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
323 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
324 int i;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
325 struct protent *protp;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
326
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
327 #ifdef CBCP_SUPPORT
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
328 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
329 * If we negotiated callback, do it now.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
330 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
331 if (go->neg_cbcp) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
332 phase = PHASE_CALLBACK;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
333 (*cbcp_protent.open)(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
334 return;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
335 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
336 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
337
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
338 phase = PHASE_NETWORK;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
339 for (i = 0; (protp = protocols[i]) != NULL; ++i)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
340 if (protp->protocol < 0xC000 && protp->enabled_flag
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
341 && protp->open != NULL) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
342 (*protp->open)(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
343 if (protp->protocol != PPP_CCP)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
344 ++num_np_open;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
345 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
346
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
347 if (num_np_open == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
348 /* nothing to do */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
349 lcp_close(0, "No network protocols running");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
350 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
351
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
352 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
353 * The peer has failed to authenticate himself using `protocol'.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
354 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
355 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
356 auth_peer_fail(unit, protocol)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
357 int unit, protocol;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
358 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
359 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
360 * Authentication failure: take the link down
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
361 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
362 lcp_close(unit, "Authentication failed");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
363 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
364
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
365 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
366 * The peer has been successfully authenticated using `protocol'.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
367 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
368 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
369 auth_peer_success(unit, protocol, name, namelen)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
370 int unit, protocol;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
371 char *name;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
372 int namelen;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
373 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
374 int bit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
375
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
376 switch (protocol) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
377 case PPP_CHAP:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
378 bit = CHAP_PEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
379 break;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
380 case PPP_PAP:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
381 bit = PAP_PEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
382 break;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
383 default:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
384 syslog(LOG_WARNING, "auth_peer_success: unknown protocol %x",
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
385 protocol);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
386 return;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
387 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
388
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
389 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
390 * Save the authenticated name of the peer for later.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
391 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
392 if (namelen > sizeof(peer_authname) - 1)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
393 namelen = sizeof(peer_authname) - 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
394 BCOPY(name, peer_authname, namelen);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
395 peer_authname[namelen] = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
396
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
397 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
398 * If we have overridden addresses based on auth info
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
399 * then set that information now before continuing.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
400 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
401 auth_set_ip_addr(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
402
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
403 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
404 * If there is no more authentication still to be done,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
405 * proceed to the network (or callback) phase.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
406 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
407 if ((auth_pending[unit] &= ~bit) == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
408 network_phase(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
409 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
410
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
411 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
412 * We have failed to authenticate ourselves to the peer using `protocol'.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
413 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
414 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
415 auth_withpeer_fail(unit, protocol)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
416 int unit, protocol;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
417 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
418 if (passwd_from_file)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
419 BZERO(passwd, MAXSECRETLEN);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
420 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
421 * We've failed to authenticate ourselves to our peer.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
422 * He'll probably take the link down, and there's not much
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
423 * we can do except wait for that.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
424 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
425 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
426
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
427 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
428 * We have successfully authenticated ourselves with the peer using `protocol'.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
429 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
430 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
431 auth_withpeer_success(unit, protocol)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
432 int unit, protocol;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
433 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
434 int bit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
435
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
436 switch (protocol) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
437 case PPP_CHAP:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
438 bit = CHAP_WITHPEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
439 break;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
440 case PPP_PAP:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
441 if (passwd_from_file)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
442 BZERO(passwd, MAXSECRETLEN);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
443 bit = PAP_WITHPEER;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
444 break;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
445 default:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
446 syslog(LOG_WARNING, "auth_peer_success: unknown protocol %x",
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
447 protocol);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
448 bit = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
449 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
450
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
451 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
452 * If we have overridden addresses based on auth info
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
453 * then set that information now before continuing.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
454 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
455 auth_set_ip_addr(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
456
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
457 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
458 * If there is no more authentication still being done,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
459 * proceed to the network (or callback) phase.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
460 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
461 if ((auth_pending[unit] &= ~bit) == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
462 network_phase(unit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
463 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
464
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
465
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
466 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
467 * np_up - a network protocol has come up.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
468 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
469 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
470 np_up(unit, proto)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
471 int unit, proto;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
472 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
473 if (num_np_up == 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
474 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
475 * At this point we consider that the link has come up successfully.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
476 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
477 need_holdoff = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
478
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
479 if (idle_time_limit > 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
480 TIMEOUT(check_idle, NULL, idle_time_limit);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
481
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
482 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
483 * Set a timeout to close the connection once the maximum
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
484 * connect time has expired.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
485 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
486 if (maxconnect > 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
487 TIMEOUT(connect_time_expired, 0, maxconnect);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
488
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
489 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
490 ++num_np_up;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
491 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
492
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
493 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
494 * np_down - a network protocol has gone down.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
495 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
496 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
497 np_down(unit, proto)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
498 int unit, proto;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
499 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
500 if (--num_np_up == 0 && idle_time_limit > 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
501 UNTIMEOUT(check_idle, NULL);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
502 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
503 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
504
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
505 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
506 * np_finished - a network protocol has finished using the link.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
507 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
508 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
509 np_finished(unit, proto)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
510 int unit, proto;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
511 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
512 if (--num_np_open <= 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
513 /* no further use for the link: shut up shop. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
514 lcp_close(0, "No network protocols running");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
515 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
516 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
517
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
518 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
519 * check_idle - check whether the link has been idle for long
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
520 * enough that we can shut it down.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
521 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
522 static void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
523 check_idle(arg)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
524 void *arg;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
525 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
526 struct ppp_idle idle;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
527 time_t itime;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
528
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
529 if (!get_idle_time(0, &idle))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
530 return;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
531 itime = MIN(idle.xmit_idle, idle.recv_idle);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
532 if (itime >= idle_time_limit) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
533 /* link is idle: shut it down. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
534 syslog(LOG_INFO, "Terminating connection due to lack of activity.");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
535 lcp_close(0, "Link inactive");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
536 } else {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
537 TIMEOUT(check_idle, NULL, idle_time_limit - itime);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
538 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
539 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
540
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
541 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
542 * connect_time_expired - log a message and close the connection.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
543 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
544 static void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
545 connect_time_expired(arg)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
546 void *arg;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
547 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
548 syslog(LOG_INFO, "Connect time expired");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
549 lcp_close(0, "Connect time expired"); /* Close connection */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
550 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
551
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
552 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
553 * auth_check_options - called to check authentication options.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
554 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
555 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
556 auth_check_options()
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
557 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
558 lcp_options *wo = &lcp_wantoptions[0];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
559 int can_auth;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
560 ipcp_options *ipwo = &ipcp_wantoptions[0];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
561 u_int32_t remote;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
562
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
563 /* Default our_name to hostname, and user to our_name */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
564 if (our_name[0] == 0 || usehostname)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
565 strcpy(our_name, cyg_ppp_hostname);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
566 if (user[0] == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
567 strcpy(user, our_name);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
568
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
569 /* If authentication is required, ask peer for CHAP or PAP. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
570 if (auth_required && !wo->neg_chap && !wo->neg_upap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
571 wo->neg_chap = 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
572 wo->neg_upap = 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
573 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
574
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
575 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
576 * Check whether we have appropriate secrets to use
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
577 * to authenticate the peer.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
578 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
579 can_auth = wo->neg_upap && (uselogin || have_pap_secret());
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
580 if (!can_auth && wo->neg_chap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
581 remote = ipwo->accept_remote? 0: ipwo->hisaddr;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
582 can_auth = have_chap_secret(remote_name, our_name, remote);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
583 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
584
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
585 if (auth_required && !can_auth) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
586 option_error("peer authentication required but no suitable secret(s) found\n");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
587 if (remote_name[0] == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
588 option_error("for authenticating any peer to us (%s)\n", our_name);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
589 else
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
590 option_error("for authenticating peer %s to us (%s)\n",
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
591 remote_name, our_name);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
592 exit(1);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
593 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
594
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
595 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
596 * Check whether the user tried to override certain values
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
597 * set by root.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
598 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
599 if (!auth_required && auth_req_info.priv > 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
600 if (!default_device && devnam_info.priv == 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
601 option_error("can't override device name when noauth option used");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
602 exit(1);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
603 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
604 if ((connector != NULL && connector_info.priv == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
605 || (disconnector != NULL && disconnector_info.priv == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
606 || (welcomer != NULL && welcomer_info.priv == 0)) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
607 option_error("can't override connect, disconnect or welcome");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
608 option_error("option values when noauth option used");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
609 exit(1);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
610 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
611 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
612 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
613
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
614 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
615 * auth_reset - called when LCP is starting negotiations to recheck
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
616 * authentication options, i.e. whether we have appropriate secrets
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
617 * to use for authenticating ourselves and/or the peer.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
618 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
619 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
620 auth_reset(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
621 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
622 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
623 lcp_options *go = &lcp_gotoptions[unit];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
624 lcp_options *ao = &lcp_allowoptions[0];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
625 ipcp_options *ipwo = &ipcp_wantoptions[0];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
626 u_int32_t remote;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
627 ao->neg_upap = !refuse_pap && (passwd[0] != 0 || get_pap_passwd(NULL));
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
628 ao->neg_chap = !refuse_chap
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
629 && have_chap_secret(user, remote_name, (u_int32_t)0);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
630 if (go->neg_upap && !uselogin && !have_pap_secret())
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
631 go->neg_upap = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
632 if (go->neg_chap) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
633 remote = ipwo->accept_remote? 0: ipwo->hisaddr;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
634 if (!have_chap_secret(remote_name, our_name, remote))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
635 go->neg_chap = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
636 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
637 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
638
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
639
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
640 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
641 * check_passwd - Check the user name and passwd against the PAP secrets
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
642 * file. If requested, also check against the system password database,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
643 * and login the user if OK.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
644 *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
645 * returns:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
646 * UPAP_AUTHNAK: Authentication failed.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
647 * UPAP_AUTHACK: Authentication succeeded.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
648 * In either case, msg points to an appropriate message.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
649 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
650 int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
651 check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
652 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
653 char *auser;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
654 int userlen;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
655 char *apasswd;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
656 int passwdlen;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
657 char **msg;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
658 int *msglen;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
659 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
660 db_printf("%s called\n", __PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
661 return 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
662 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
663
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
664 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
665 * null_login - Check if a username of "" and a password of "" are
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
666 * acceptable, and iff so, set the list of acceptable IP addresses
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
667 * and return 1.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
668 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
669 static int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
670 null_login(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
671 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
672 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
673 db_printf("%s called\n", __PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
674 return 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
675 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
676
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
677
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
678 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
679 * get_pap_passwd - get a password for authenticating ourselves with
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
680 * our peer using PAP. Returns 1 on success, 0 if no suitable password
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
681 * could be found.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
682 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
683 static int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
684 get_pap_passwd(passwd)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
685 char *passwd;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
686 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
687 db_printf("%s called\n", __PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
688 return 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
689 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
690
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
691
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
692 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
693 * have_pap_secret - check whether we have a PAP file with any
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
694 * secrets that we could possibly use for authenticating the peer.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
695 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
696 static int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
697 have_pap_secret()
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
698 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
699 db_printf("%s called\n", __PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
700 return 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
701 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
702
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
703
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
704 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
705 * have_chap_secret - check whether we have a CHAP file with a
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
706 * secret that we could possibly use for authenticating `client'
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
707 * on `server'. Either can be the null string, meaning we don't
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
708 * know the identity yet.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
709 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
710 static int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
711 have_chap_secret(client, server, remote)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
712 char *client;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
713 char *server;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
714 u_int32_t remote;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
715 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
716 // db_printf("%s(%s,%s,%d) called\n", __PRETTY_FUNCTION__,client,server,remote);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
717 return 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
718 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
719
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
720
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
721 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
722 * get_secret - open the CHAP secret file and return the secret
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
723 * for authenticating the given client on the given server.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
724 * (We could be either client or server).
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
725 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
726 int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
727 get_secret(unit, client, server, secret, secret_len, save_addrs)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
728 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
729 char *client;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
730 char *server;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
731 char *secret;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
732 int *secret_len;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
733 int save_addrs;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
734 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
735 db_printf("%s(%d,%s,%s,%08x,%d,%d) called\n", __PRETTY_FUNCTION__,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
736 unit, client, server, secret, secret_len, save_addrs);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
737 // We use the PAP password as the CHAP secret also.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
738 strncpy( secret, passwd, MAXNAMELEN );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
739 *secret_len = strlen(secret);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
740 return 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
741 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
742
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
743 static void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
744 auth_set_ip_addr(unit)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
745 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
746 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
747 db_printf("%s called\n", __PRETTY_FUNCTION__);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
748 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
749
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
750 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
751 * auth_ip_addr - check whether the peer is authorized to use
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
752 * a given IP address. Returns 1 if authorized, 0 otherwise.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
753 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
754 int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
755 auth_ip_addr(unit, addr)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
756 int unit;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
757 u_int32_t addr;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
758 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
759 return ip_addr_check(addr, addresses[unit]);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
760 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
761
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
762 static int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
763 ip_addr_check(addr, addrs)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
764 u_int32_t addr;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
765 struct wordlist *addrs;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
766 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
767 int x, y;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
768 // u_int32_t a, mask, ah;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
769 u_int32_t a = -1, mask;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
770 int accept;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
771 char *ptr_word, *ptr_mask;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
772 // struct hostent *hp;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
773 // struct netent *np;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
774
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
775 /* don't allow loopback or multicast address */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
776 if (bad_ip_adrs(addr))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
777 return 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
778
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
779 if (addrs == NULL)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
780 return !auth_required; /* no addresses authorized */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
781
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
782 x = y = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
783 for (; addrs != NULL; addrs = addrs->next) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
784 y++;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
785 /* "-" means no addresses authorized, "*" means any address allowed */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
786 ptr_word = addrs->word;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
787 if (strcmp(ptr_word, "-") == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
788 break;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
789 if (strcmp(ptr_word, "*") == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
790 return 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
791
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
792 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
793 * A colon in the string means that we wish to force a specific
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
794 * local:remote address, but we ignore these for now.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
795 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
796 if (strchr(addrs->word, ':') != NULL)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
797 x++;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
798 else {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
799
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
800 accept = 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
801 if (*ptr_word == '!') {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
802 accept = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
803 ++ptr_word;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
804 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
805
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
806 mask = ~ (u_int32_t) 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
807 ptr_mask = strchr (ptr_word, '/');
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
808 if (ptr_mask != NULL) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
809 int bit_count;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
810
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
811 bit_count = (int) strtol (ptr_mask+1, (char **) 0, 10);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
812 if (bit_count <= 0 || bit_count > 32) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
813 syslog (LOG_WARNING,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
814 "invalid address length %s in auth. address list",
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
815 ptr_mask);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
816 continue;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
817 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
818 *ptr_mask = '\0';
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
819 mask <<= 32 - bit_count;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
820 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
821
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
822 #ifndef __ECOS
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
823 hp = gethostbyname(ptr_word);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
824 if (hp != NULL && hp->h_addrtype == AF_INET) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
825 a = *(u_int32_t *)hp->h_addr;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
826 } else {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
827 np = getnetbyname (ptr_word);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
828 if (np != NULL && np->n_addrtype == AF_INET) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
829 a = htonl (*(u_int32_t *)np->n_net);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
830 if (ptr_mask == NULL) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
831 /* calculate appropriate mask for net */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
832 ah = ntohl(a);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
833 if (IN_CLASSA(ah))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
834 mask = IN_CLASSA_NET;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
835 else if (IN_CLASSB(ah))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
836 mask = IN_CLASSB_NET;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
837 else if (IN_CLASSC(ah))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
838 mask = IN_CLASSC_NET;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
839 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
840 } else {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
841 a = inet_addr (ptr_word);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
842 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
843 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
844 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
845
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
846 if (ptr_mask != NULL)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
847 *ptr_mask = '/';
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
848
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
849 if (a == (u_int32_t)-1L)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
850 syslog (LOG_WARNING,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
851 "unknown host %s in auth. address list",
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
852 addrs->word);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
853 else
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
854 /* Here a and addr are in network byte order,
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
855 and mask is in host order. */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
856 if (((addr ^ a) & htonl(mask)) == 0)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
857 return accept;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
858 } /* else */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
859 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
860 return x == y; /* not in list => can't have it */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
861 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
862
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
863 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
864 * bad_ip_adrs - return 1 if the IP address is one we don't want
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
865 * to use, such as an address in the loopback net or a multicast address.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
866 * addr is in network byte order.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
867 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
868 int
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
869 bad_ip_adrs(addr)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
870 u_int32_t addr;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
871 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
872 addr = ntohl(addr);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
873 return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
874 || IN_MULTICAST(addr) || IN_BADCLASS(addr);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
875 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
876
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
877 /*
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
878 * check_access - complain if a secret file has too-liberal permissions.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
879 */
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
880 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
881 check_access(f, filename)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
882 FILE *f;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
883 char *filename;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
884 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
885 struct stat sbuf;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
886
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
887 if (fstat(fileno(f), &sbuf) < 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
888 syslog(LOG_WARNING, "cannot stat secret file %s: %m", filename);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
889 } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
890 syslog(LOG_WARNING, "Warning - secret file %s has world and/or group access", filename);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
891 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
892 }