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.56 by root, Sun Mar 6 21:01:36 2011 UTC vs.
Revision 1.61 by root, Tue Jul 16 16:44:36 2013 UTC

38#include <errno.h> 38#include <errno.h>
39#include <netdb.h> 39#include <netdb.h>
40#include <sys/stat.h> 40#include <sys/stat.h>
41#include <sys/types.h> 41#include <sys/types.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <pwd.h>
43 44
44#include "netcompat.h" 45#include "netcompat.h"
45 46
46#include <openssl/err.h> 47#include <openssl/err.h>
47#include <openssl/pem.h> 48#include <openssl/pem.h>
160 dns_send_interval = DEFAULT_DNS_SEND_INTERVAL; 161 dns_send_interval = DEFAULT_DNS_SEND_INTERVAL;
161 dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR; 162 dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR;
162 dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING; 163 dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING;
163#endif 164#endif
164 165
165 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); 166 pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
167 seed_dev = strdup ("/dev/urandom");
168 reseed = DEFAULT_RESEED;
166} 169}
167 170
168void 171void
169configuration::cleanup () 172configuration::cleanup ()
170{ 173{
171 if (rsa_key) 174 if (rsa_key)
172 RSA_free (rsa_key); 175 RSA_free (rsa_key);
173 176
174 rsa_key = 0; 177 rsa_key = 0;
175 178
179 free (seed_dev); seed_dev = 0;
176 free (pidfilename); pidfilename = 0; 180 free (pidfilename); pidfilename = 0;
177 free (ifname); ifname = 0; 181 free (ifname); ifname = 0;
178#if ENABLE_HTTP_PROXY 182#if ENABLE_HTTP_PROXY
179 free (proxy_host); proxy_host = 0; 183 free (proxy_host); proxy_host = 0;
180 free (proxy_auth); proxy_auth = 0; 184 free (proxy_auth); proxy_auth = 0;
181#endif 185#endif
182#if ENABLE_DNS 186#if ENABLE_DNS
183 free (dns_forw_host); dns_forw_host = 0; 187 free (dns_forw_host); dns_forw_host = 0;
184#endif 188#endif
189 free (change_root); change_root = 0;
185 free (script_if_up); script_if_up = 0; 190 free (script_if_up); script_if_up = 0;
186 free (script_node_up); script_node_up = 0; 191 free (script_node_up); script_node_up = 0;
187 free (script_node_change); script_node_change = 0; 192 free (script_node_change); script_node_change = 0;
188 free (script_node_down); script_node_down = 0; 193 free (script_node_down); script_node_down = 0;
189} 194}
273 { 278 {
274#if ENABLE_ICMP 279#if ENABLE_ICMP
275 conf.icmp_type = atoi (val); 280 conf.icmp_type = atoi (val);
276#endif 281#endif
277 } 282 }
283 else if (!strcmp (var, "chuser"))
284 {
285 struct passwd *pw = getpwnam (val);
286 if (!pw)
287 return _("user specified for chuser not found");
278 288
279 // per config 289 conf.change_uid = pw->pw_uid;
290 conf.change_gid = pw->pw_gid;
291 }
292 else if (!strcmp (var, "chuid"))
293 conf.change_uid = atoi (val);
294 else if (!strcmp (var, "chgid"))
295 conf.change_gid = atoi (val);
296 else if (!strcmp (var, "chroot"))
297 free (conf.change_root), conf.change_root = strdup (val);
298
299 // per node
280 else if (!strcmp (var, "node")) 300 else if (!strcmp (var, "node"))
281 { 301 {
282 parse_argv (); 302 parse_argv ();
283 303
284 conf.default_node.id++; 304 conf.default_node.id++;
334 conf.keepalive = atoi (val); 354 conf.keepalive = atoi (val);
335 else if (!strcmp (var, "mtu")) 355 else if (!strcmp (var, "mtu"))
336 conf.mtu = atoi (val); 356 conf.mtu = atoi (val);
337 else if (!strcmp (var, "nfmark")) 357 else if (!strcmp (var, "nfmark"))
338 conf.nfmark = atoi (val); 358 conf.nfmark = atoi (val);
359 else if (!strcmp (var, "seed-device"))
360 free (conf.seed_dev), conf.seed_dev = strdup (val);
361 else if (!strcmp (var, "seed-interval"))
362 conf.reseed = atoi (val);
339 else if (!strcmp (var, "if-up")) 363 else if (!strcmp (var, "if-up"))
340 free (conf.script_if_up), conf.script_if_up = strdup (val); 364 free (conf.script_if_up), conf.script_if_up = strdup (val);
341 else if (!strcmp (var, "node-up")) 365 else if (!strcmp (var, "node-up"))
342 free (conf.script_node_up), conf.script_node_up = strdup (val); 366 free (conf.script_node_up), conf.script_node_up = strdup (val);
343 else if (!strcmp (var, "node-change")) 367 else if (!strcmp (var, "node-change"))
612 636
613 fclose (f); 637 fclose (f);
614 } 638 }
615 else 639 else
616 { 640 {
617 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno));
618
619 if (need_keys) 641 if (need_keys)
642 {
643 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno));
620 exit (EXIT_FAILURE); 644 exit (EXIT_FAILURE);
645 }
621 } 646 }
622 647
623 free (fname); 648 free (fname);
624 649
625 if (need_keys && ::thisnode 650 if (need_keys && ::thisnode
629 { 654 {
630 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode); 655 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode);
631 exit (EXIT_FAILURE); 656 exit (EXIT_FAILURE);
632 } 657 }
633 658
659 fname = conf.config_filename (conf.pidfilename);
660 free (conf.pidfilename); conf.pidfilename = fname;
661
634 for (configuration::node_vector::iterator i = conf.nodes.begin(); i != conf.nodes.end(); ++i) 662 for (configuration::node_vector::iterator i = conf.nodes.begin(); i != conf.nodes.end(); ++i)
635 (*i)->finalise (); 663 (*i)->finalise ();
636} 664}
637 665
638char * 666char *
639configuration::config_filename (const char *name, const char *dflt) 667configuration::config_filename (const char *name, const char *dflt)
640{ 668{
641 char *fname; 669 char *fname;
642 670
643 asprintf (&fname, name ? name : dflt, ::thisnode); 671 asprintf (&fname, name ? name : dflt, ::thisnode ? ::thisnode : "<unset>");
644 672
645 if (!ABSOLUTE_PATH (fname)) 673 if (!ABSOLUTE_PATH (fname))
646 { 674 {
647 char *rname = fname; 675 char *rname = fname;
648 asprintf (&fname, "%s/%s", confbase, rname); 676 asprintf (&fname, "%s/%s", confbase, rname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines