ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/conf.C
(Generate patch)

Comparing gvpe/src/conf.C (file contents):
Revision 1.16 by pcg, Tue Oct 14 03:22:09 2003 UTC vs.
Revision 1.38 by pcg, Wed Mar 23 17:03:58 2005 UTC

1/* 1/*
2 conf.c -- configuration code 2 conf.c -- configuration code
3 Copyright (C) 1998 Robert van der Meulen 3 Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de>
4 1998-2002 Ivo Timmermans <ivo@o2w.nl>
5 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
6 2000 Cris van Pelt <tribbel@arise.dhs.org>
7 2003 Marc Lehmann <pcg@goof.com>
8 4
5 This file is part of GVPE.
6
9 This program is free software; you can redistribute it and/or modify 7 GVPE is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 10 (at your option) any later version.
13 11
14 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 15 GNU General Public License for more details.
18 16
19 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 18 along with gvpe; if not, write to the Free Software
21 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/ 20*/
23 21
24#include "config.h" 22#include "config.h"
25 23
31#include <netdb.h> 29#include <netdb.h>
32#include <sys/stat.h> 30#include <sys/stat.h>
33#include <sys/types.h> 31#include <sys/types.h>
34#include <unistd.h> 32#include <unistd.h>
35 33
36#include <netinet/in.h> 34#include "netcompat.h"
37#include <arpa/inet.h>
38#ifdef ENABLE_ICMP
39# ifdef HAVE_NETINET_IN_SYSTM_H
40# include <netinet/in_systm.h>
41# endif
42# ifdef HAVE_NETINET_IP_H
43# include <netinet/ip.h>
44# endif
45# include <netinet/ip_icmp.h>
46#endif
47 35
48#include <openssl/err.h> 36#include <openssl/err.h>
49#include <openssl/pem.h> 37#include <openssl/pem.h>
50#include <openssl/rsa.h> 38#include <openssl/rsa.h>
51#include <openssl/rand.h> 39#include <openssl/rand.h>
52 40#include <openssl/bn.h>
53#include "gettext.h"
54 41
55#include "conf.h" 42#include "conf.h"
56#include "slog.h" 43#include "slog.h"
57#include "util.h" 44#include "util.h"
58 45
59char *confbase; 46char *confbase;
60char *thisnode; 47char *thisnode;
61char *identname; 48char *identname;
62char *pidfilename;
63 49
64struct configuration conf; 50struct configuration conf;
65 51
66u8 best_protocol (u8 protset) 52u8 best_protocol (u8 protset)
67{ 53{
68 if (protset & PROT_IPv4 ) return PROT_IPv4; 54 if (protset & PROT_IPv4 ) return PROT_IPv4;
69 if (protset & PROT_ICMPv4) return PROT_ICMPv4; 55 if (protset & PROT_ICMPv4) return PROT_ICMPv4;
70 if (protset & PROT_UDPv4 ) return PROT_UDPv4; 56 if (protset & PROT_UDPv4 ) return PROT_UDPv4;
71 if (protset & PROT_TCPv4 ) return PROT_TCPv4; 57 if (protset & PROT_TCPv4 ) return PROT_TCPv4;
58 if (protset & PROT_DNSv4 ) return PROT_DNSv4;
72 59
73 return 0; 60 return 0;
74} 61}
75 62
76const char *strprotocol (u8 protocol) 63const char *strprotocol (u8 protocol)
77{ 64{
78 if (protocol & PROT_IPv4 ) return "rawip"; 65 if (protocol & PROT_IPv4 ) return "rawip";
79 if (protocol & PROT_ICMPv4) return "icmp"; 66 if (protocol & PROT_ICMPv4) return "icmp";
80 if (protocol & PROT_UDPv4 ) return "udp"; 67 if (protocol & PROT_UDPv4 ) return "udp";
81 if (protocol & PROT_TCPv4 ) return "tcp"; 68 if (protocol & PROT_TCPv4 ) return "tcp";
69 if (protocol & PROT_DNSv4 ) return "dns";
82 70
83 return "<unknown>"; 71 return "<unknown>";
84} 72}
85 73
86void 74void
105 if (rsa_key) 93 if (rsa_key)
106 RSA_free (rsa_key); 94 RSA_free (rsa_key);
107 95
108 free (nodename); 96 free (nodename);
109 free (hostname); 97 free (hostname);
98#if ENABLE_DNS
99 free (domain);
100 free (dns_hostname);
101#endif
110} 102}
111 103
112void configuration::init () 104void configuration::init ()
113{ 105{
114 memset (this, 0, sizeof (*this)); 106 memset (this, 0, sizeof (*this));
115 107
108 mtu = DEFAULT_MTU;
116 rekey = DEFAULT_REKEY; 109 rekey = DEFAULT_REKEY;
117 keepalive = DEFAULT_KEEPALIVE; 110 keepalive = DEFAULT_KEEPALIVE;
118 llevel = L_INFO; 111 llevel = L_INFO;
119 ip_proto = IPPROTO_GRE; 112 ip_proto = IPPROTO_GRE;
120#if ENABLE_ICMP 113#if ENABLE_ICMP
121 icmp_type = ICMP_ECHOREPLY; 114 icmp_type = ICMP_ECHOREPLY;
122#endif 115#endif
123 116
124 default_node.udp_port = DEFAULT_UDPPORT; 117 default_node.udp_port = DEFAULT_UDPPORT;
125 default_node.tcp_port = DEFAULT_UDPPORT; 118 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
126 default_node.connectmode = conf_node::C_ALWAYS; 119 default_node.connectmode = conf_node::C_ALWAYS;
127 default_node.compress = true; 120 default_node.compress = true;
128 default_node.protocols = PROT_UDPv4; 121 default_node.protocols = 0;
122 default_node.max_retry = DEFAULT_MAX_RETRY;
123
124#if ENABLE_DNS
125 default_node.dns_port = 0; // default is 0 == client
126
127 dns_forw_host = strdup ("127.0.0.1");
128 dns_forw_port = 53;
129 dns_timeout_factor = DEFAULT_DNS_TIMEOUT_FACTOR;
130 dns_send_interval = DEFAULT_DNS_SEND_INTERVAL;
131 dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR;
132 dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING;
133#endif
134
135 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
129} 136}
130 137
131void configuration::cleanup() 138void configuration::cleanup()
132{ 139{
133 if (rsa_key) 140 if (rsa_key)
134 RSA_free (rsa_key); 141 RSA_free (rsa_key);
135 142
136 rsa_key = 0; 143 rsa_key = 0;
137 144
145 free (pidfilename); pidfilename = 0;
138 free (ifname); ifname = 0; 146 free (ifname); ifname = 0;
139#if ENABLE_HTTP_PROXY 147#if ENABLE_HTTP_PROXY
140 free (proxy_host); proxy_host = 0; 148 free (proxy_host); proxy_host = 0;
141 free (proxy_auth); proxy_auth = 0; 149 free (proxy_auth); proxy_auth = 0;
150#endif
151#if ENABLE_DNS
152 free (dns_forw_host); dns_forw_host = 0;
142#endif 153#endif
143} 154}
144 155
145void 156void
146configuration::clear_config () 157configuration::clear_config ()
152 163
153 cleanup (); 164 cleanup ();
154 init (); 165 init ();
155} 166}
156 167
157#define parse_bool(target,name,trueval,falseval) \ 168#define parse_bool(target,name,trueval,falseval) do { \
158 if (!strcmp (val, "yes")) target = trueval; \ 169 if (!strcmp (val, "yes")) target = trueval; \
159 else if (!strcmp (val, "no")) target = falseval; \ 170 else if (!strcmp (val, "no")) target = falseval; \
160 else if (!strcmp (val, "true")) target = trueval; \ 171 else if (!strcmp (val, "true")) target = trueval; \
161 else if (!strcmp (val, "false")) target = falseval; \ 172 else if (!strcmp (val, "false")) target = falseval; \
162 else if (!strcmp (val, "on")) target = trueval; \ 173 else if (!strcmp (val, "on")) target = trueval; \
163 else if (!strcmp (val, "off")) target = falseval; \ 174 else if (!strcmp (val, "off")) target = falseval; \
164 else \ 175 else \
165 slog (L_WARN, \ 176 slog (L_WARN, \
166 _("illegal value for '%s', only 'yes|true|on' or 'no|false|off' allowed, at '%s' line %d"), \ 177 _("illegal value for '%s', only 'yes|true|on' or 'no|false|off' allowed, at '%s' line %d"), \
167 name, var, fname, lineno); 178 name, var, fname, lineno); \
179} while (0)
168 180
169void configuration::read_config (bool need_keys) 181void configuration::read_config (bool need_keys)
170{ 182{
171 char *fname; 183 char *fname;
172 FILE *f; 184 FILE *f;
173 185
174 clear_config (); 186 clear_config ();
175 187
176 asprintf (&fname, "%s/vped.conf", confbase); 188 asprintf (&fname, "%s/gvpe.conf", confbase);
177 f = fopen (fname, "r"); 189 f = fopen (fname, "r");
178 190
179 if (f) 191 if (f)
180 { 192 {
181 char line[16384]; 193 char line[16384];
211 val = strtok (NULL, "\t\n\r ="); 223 val = strtok (NULL, "\t\n\r =");
212 224
213 if (!val || val[0] == '#') 225 if (!val || val[0] == '#')
214 { 226 {
215 slog (L_WARN, 227 slog (L_WARN,
216 _("no value for variable `%s', at '%s' line %d"), 228 _("no value for variable `%s', at '%s' line %d, skipping."),
217 var, fname, lineno); 229 var, fname, lineno);
218 break; 230 continue;
219 } 231 }
220 232
221 if (!strcmp (var, "on")) 233 if (!strcmp (var, "on"))
222 { 234 {
223 if (!::thisnode 235 if (!::thisnode
238 else 250 else
239 slog (L_WARN, "'%s': %s, at '%s' line %d", val, UNKNOWN_LOGLEVEL, fname, line); 251 slog (L_WARN, "'%s': %s, at '%s' line %d", val, UNKNOWN_LOGLEVEL, fname, line);
240 } 252 }
241 else if (!strcmp (var, "ip-proto")) 253 else if (!strcmp (var, "ip-proto"))
242 ip_proto = atoi (val); 254 ip_proto = atoi (val);
255 else if (!strcmp (var, "icmp-type"))
256 {
243#if ENABLE_ICMP 257#if ENABLE_ICMP
244 //TODO: error message
245 else if (!strcmp (var, "icmp-type"))
246 icmp_type = atoi (val); 258 icmp_type = atoi (val);
247#endif 259#endif
260 }
248 261
249 // per config 262 // per config
250 else if (!strcmp (var, "node")) 263 else if (!strcmp (var, "node"))
251 { 264 {
252 default_node.id++; 265 default_node.id++;
270 283
271 if (!PEM_read_RSAPublicKey(f, &node->rsa_key, NULL, NULL)) 284 if (!PEM_read_RSAPublicKey(f, &node->rsa_key, NULL, NULL))
272 { 285 {
273 ERR_load_RSA_strings (); ERR_load_PEM_strings (); 286 ERR_load_RSA_strings (); ERR_load_PEM_strings ();
274 slog (L_ERR, _("unable to open public rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0)); 287 slog (L_ERR, _("unable to open public rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0));
275 exit (1); 288 exit (EXIT_FAILURE);
276 } 289 }
277 290
278 RSA_blinding_on (node->rsa_key, 0); 291 require (RSA_blinding_on (node->rsa_key, 0));
279 292
280 fclose (f); 293 fclose (f);
281 } 294 }
282 else 295 else
283 { 296 {
284 slog (need_keys ? L_ERR : L_NOTICE, _("unable to read public rsa key file '%s': %s"), fname, strerror (errno)); 297 slog (need_keys ? L_ERR : L_NOTICE, _("unable to read public rsa key file '%s': %s"), fname, strerror (errno));
285 298
286 if (need_keys) 299 if (need_keys)
287 exit (1); 300 exit (EXIT_FAILURE);
288 } 301 }
289 302
290 free (fname); 303 free (fname);
291 } 304 }
292 305
293 if (!::thisnode || !strcmp (node->nodename, ::thisnode)) 306 if (::thisnode && !strcmp (node->nodename, ::thisnode))
294 thisnode = node; 307 thisnode = node;
295 } 308 }
296 else if (!strcmp (var, "private-key")) 309 else if (!strcmp (var, "private-key"))
297 prikeyfile = strdup (val); 310 free (prikeyfile), prikeyfile = strdup (val);
298 else if (!strcmp (var, "ifpersist")) 311 else if (!strcmp (var, "ifpersist"))
299 {
300 parse_bool (ifpersist, "ifpersist", true, false); 312 parse_bool (ifpersist, "ifpersist", true, false);
301 }
302 else if (!strcmp (var, "ifname")) 313 else if (!strcmp (var, "ifname"))
303 ifname = strdup (val); 314 free (ifname), ifname = strdup (val);
304 else if (!strcmp (var, "rekey")) 315 else if (!strcmp (var, "rekey"))
305 rekey = atoi (val); 316 rekey = atoi (val);
306 else if (!strcmp (var, "keepalive")) 317 else if (!strcmp (var, "keepalive"))
307 keepalive = atoi (val); 318 keepalive = atoi (val);
308 else if (!strcmp (var, "mtu")) 319 else if (!strcmp (var, "mtu"))
309 mtu = atoi (val); 320 mtu = atoi (val);
310 else if (!strcmp (var, "if-up")) 321 else if (!strcmp (var, "if-up"))
311 script_if_up = strdup (val); 322 free (script_if_up), script_if_up = strdup (val);
312 else if (!strcmp (var, "node-up")) 323 else if (!strcmp (var, "node-up"))
313 script_node_up = strdup (val); 324 free (script_node_up), script_node_up = strdup (val);
314 else if (!strcmp (var, "node-down")) 325 else if (!strcmp (var, "node-down"))
315 script_node_down = strdup (val); 326 free (script_node_down), script_node_down = strdup (val);
327 else if (!strcmp (var, "pid-file"))
328 free (pidfilename), pidfilename = strdup (val);
329 else if (!strcmp (var, "dns-forw-host"))
330 {
331#if ENABLE_DNS
332 free (dns_forw_host), dns_forw_host = strdup (val);
333#endif
334 }
335 else if (!strcmp (var, "dns-forw-port"))
336 {
337#if ENABLE_DNS
338 dns_forw_port = atoi (val);
339#endif
340 }
341 else if (!strcmp (var, "dns-timeout-factor"))
342 {
343#if ENABLE_DNS
344 dns_timeout_factor = atof (val);
345#endif
346 }
347 else if (!strcmp (var, "dns-send-interval"))
348 {
349#if ENABLE_DNS
350 dns_send_interval = atoi (val);
351#endif
352 }
353 else if (!strcmp (var, "dns-overlap-factor"))
354 {
355#if ENABLE_DNS
356 dns_overlap_factor = atof (val);
357#endif
358 }
359 else if (!strcmp (var, "dns-max-outstanding"))
360 {
361#if ENABLE_DNS
362 dns_max_outstanding = atoi (val);
363#endif
364 }
365 else if (!strcmp (var, "http-proxy-host"))
366 {
316#if ENABLE_HTTP_PROXY 367#if ENABLE_HTTP_PROXY
317 else if (!strcmp (var, "http-proxy-host"))
318 proxy_host = strdup (val); 368 free (proxy_host), proxy_host = strdup (val);
369#endif
370 }
319 else if (!strcmp (var, "http-proxy-port")) 371 else if (!strcmp (var, "http-proxy-port"))
372 {
373#if ENABLE_HTTP_PROXY
320 proxy_port = atoi (val); 374 proxy_port = atoi (val);
375#endif
376 }
321 else if (!strcmp (var, "http-proxy-auth")) 377 else if (!strcmp (var, "http-proxy-auth"))
378 {
379#if ENABLE_HTTP_PROXY
322 proxy_auth = (char *)base64_encode ((const u8 *)val, strlen (val)); 380 proxy_auth = (char *)base64_encode ((const u8 *)val, strlen (val));
323#endif 381#endif
382 }
324 383
325 /* node-specific, non-defaultable */ 384 /* node-specific, non-defaultable */
326 else if (node != &default_node && !strcmp (var, "hostname")) 385 else if (node != &default_node && !strcmp (var, "hostname"))
327 {
328 free (node->hostname);
329 node->hostname = strdup (val); 386 free (node->hostname), node->hostname = strdup (val);
330 }
331 387
332 /* node-specific, defaultable */ 388 /* node-specific, defaultable */
333 else if (!strcmp (var, "udp-port")) 389 else if (!strcmp (var, "udp-port"))
334 node->udp_port = atoi (val); 390 node->udp_port = atoi (val);
335 else if (!strcmp (var, "tcp-port")) 391 else if (!strcmp (var, "tcp-port"))
336 node->tcp_port = atoi (val); 392 node->tcp_port = atoi (val);
393 else if (!strcmp (var, "dns-hostname"))
394 {
395#if ENABLE_DNS
396 free (node->dns_hostname), node->dns_hostname = strdup (val);
397#endif
398 }
399 else if (!strcmp (var, "dns-port"))
400 {
401#if ENABLE_DNS
402 node->dns_port = atoi (val);
403#endif
404 }
405 else if (!strcmp (var, "dns-domain"))
406 {
407#if ENABLE_DNS
408 free (node->domain), node->domain = strdup (val);
409#endif
410 }
337 else if (!strcmp (var, "router-priority")) 411 else if (!strcmp (var, "router-priority"))
338 node->routerprio = atoi (val); 412 node->routerprio = atoi (val);
413 else if (!strcmp (var, "max-retry"))
414 node->max_retry = atoi (val);
339 else if (!strcmp (var, "connect")) 415 else if (!strcmp (var, "connect"))
340 { 416 {
341 if (!strcmp (val, "ondemand")) 417 if (!strcmp (val, "ondemand"))
342 node->connectmode = conf_node::C_ONDEMAND; 418 node->connectmode = conf_node::C_ONDEMAND;
343 else if (!strcmp (val, "never")) 419 else if (!strcmp (val, "never"))
346 node->connectmode = conf_node::C_ALWAYS; 422 node->connectmode = conf_node::C_ALWAYS;
347 else if (!strcmp (val, "disabled")) 423 else if (!strcmp (val, "disabled"))
348 node->connectmode = conf_node::C_DISABLED; 424 node->connectmode = conf_node::C_DISABLED;
349 else 425 else
350 slog (L_WARN, 426 slog (L_WARN,
351 _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), 427 _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d, ignoring."),
352 var, fname, lineno); 428 var, fname, lineno);
353 } 429 }
354 else if (!strcmp (var, "inherit-tos")) 430 else if (!strcmp (var, "inherit-tos"))
355 {
356 parse_bool (node->inherit_tos, "inherit-tos", true, false); 431 parse_bool (node->inherit_tos, "inherit-tos", true, false);
357 }
358 else if (!strcmp (var, "compress")) 432 else if (!strcmp (var, "compress"))
359 {
360 parse_bool (node->compress, "compress", true, false); 433 parse_bool (node->compress, "compress", true, false);
361 }
362 // all these bool options really really cost a lot of executable size! 434 // all these bool options really really cost a lot of executable size!
363 else if (!strcmp (var, "enable-tcp")) 435 else if (!strcmp (var, "enable-tcp"))
364 { 436 {
365#if ENABLE_TCP 437#if ENABLE_TCP
366 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; 438 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v;
368 } 440 }
369 else if (!strcmp (var, "enable-icmp")) 441 else if (!strcmp (var, "enable-icmp"))
370 { 442 {
371#if ENABLE_ICMP 443#if ENABLE_ICMP
372 u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v; 444 u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v;
445#endif
446 }
447 else if (!strcmp (var, "enable-dns"))
448 {
449#if ENABLE_DNS
450 u8 v; parse_bool (v, "enable-dns" , PROT_DNSv4, 0); node->protocols = (node->protocols & ~PROT_DNSv4) | v;
373#endif 451#endif
374 } 452 }
375 else if (!strcmp (var, "enable-udp")) 453 else if (!strcmp (var, "enable-udp"))
376 { 454 {
377 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 455 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
382 } 460 }
383 461
384 // unknown or misplaced 462 // unknown or misplaced
385 else 463 else
386 slog (L_WARN, 464 slog (L_WARN,
387 _("unknown or misplaced variable `%s', at '%s' line %d"), 465 _("unknown or misplaced variable `%s', at '%s' line %d, skipping."),
388 var, fname, lineno); 466 var, fname, lineno);
389 } 467 }
390 468
391 fclose (f); 469 fclose (f);
392 } 470 }
393 else 471 else
394 { 472 {
395 slog (L_ERR, _("unable to read config file '%s': %s"), fname, strerror (errno)); 473 slog (L_ERR, _("unable to read config file '%s': %s"), fname, strerror (errno));
396 exit (1); 474 exit (EXIT_FAILURE);
397 } 475 }
398 476
399 free (fname); 477 free (fname);
400 478
401 fname = config_filename (prikeyfile, "hostkey"); 479 fname = config_filename (prikeyfile, "hostkey");
407 485
408 if (!PEM_read_RSAPrivateKey (f, &rsa_key, NULL, NULL)) 486 if (!PEM_read_RSAPrivateKey (f, &rsa_key, NULL, NULL))
409 { 487 {
410 ERR_load_RSA_strings (); ERR_load_PEM_strings (); 488 ERR_load_RSA_strings (); ERR_load_PEM_strings ();
411 slog (L_ERR, _("unable to read private rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0)); 489 slog (L_ERR, _("unable to read private rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0));
412 exit (1); 490 exit (EXIT_FAILURE);
413 } 491 }
414 492
415 RSA_blinding_on (rsa_key, 0); 493 require (RSA_blinding_on (rsa_key, 0));
416 494
417 fclose (f); 495 fclose (f);
418 } 496 }
419 else 497 else
420 { 498 {
421 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno)); 499 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno));
422 500
423 if (need_keys) 501 if (need_keys)
424 exit (1); 502 exit (EXIT_FAILURE);
425 } 503 }
504
505 if (need_keys && ::thisnode
506 && rsa_key && thisnode && thisnode->rsa_key)
507 if (BN_cmp (rsa_key->n, thisnode->rsa_key->n) != 0
508 || BN_cmp (rsa_key->e, thisnode->rsa_key->e) != 0)
509 {
510 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode);
511 exit (EXIT_FAILURE);
512 }
426 513
427 free (fname); 514 free (fname);
428} 515}
429 516
430char *configuration::config_filename (const char *name, const char *dflt) 517char *configuration::config_filename (const char *name, const char *dflt)
466 printf ("\n"); 553 printf ("\n");
467} 554}
468 555
469configuration::configuration () 556configuration::configuration ()
470{ 557{
558 asprintf (&confbase, "%s/gvpe", CONFDIR);
559
471 init (); 560 init ();
472} 561}
473 562
474configuration::~configuration () 563configuration::~configuration ()
475{ 564{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines