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.59 by root, Tue Dec 4 10:29:43 2012 UTC vs.
Revision 1.61 by root, Tue Jul 16 16:44:36 2013 UTC

161 dns_send_interval = DEFAULT_DNS_SEND_INTERVAL; 161 dns_send_interval = DEFAULT_DNS_SEND_INTERVAL;
162 dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR; 162 dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR;
163 dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING; 163 dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING;
164#endif 164#endif
165 165
166 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); 166 pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
167 seed_dev = strdup ("/dev/urandom");
168 reseed = DEFAULT_RESEED;
167} 169}
168 170
169void 171void
170configuration::cleanup () 172configuration::cleanup ()
171{ 173{
172 if (rsa_key) 174 if (rsa_key)
173 RSA_free (rsa_key); 175 RSA_free (rsa_key);
174 176
175 rsa_key = 0; 177 rsa_key = 0;
176 178
179 free (seed_dev); seed_dev = 0;
177 free (pidfilename); pidfilename = 0; 180 free (pidfilename); pidfilename = 0;
178 free (ifname); ifname = 0; 181 free (ifname); ifname = 0;
179#if ENABLE_HTTP_PROXY 182#if ENABLE_HTTP_PROXY
180 free (proxy_host); proxy_host = 0; 183 free (proxy_host); proxy_host = 0;
181 free (proxy_auth); proxy_auth = 0; 184 free (proxy_auth); proxy_auth = 0;
351 conf.keepalive = atoi (val); 354 conf.keepalive = atoi (val);
352 else if (!strcmp (var, "mtu")) 355 else if (!strcmp (var, "mtu"))
353 conf.mtu = atoi (val); 356 conf.mtu = atoi (val);
354 else if (!strcmp (var, "nfmark")) 357 else if (!strcmp (var, "nfmark"))
355 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);
356 else if (!strcmp (var, "if-up")) 363 else if (!strcmp (var, "if-up"))
357 free (conf.script_if_up), conf.script_if_up = strdup (val); 364 free (conf.script_if_up), conf.script_if_up = strdup (val);
358 else if (!strcmp (var, "node-up")) 365 else if (!strcmp (var, "node-up"))
359 free (conf.script_node_up), conf.script_node_up = strdup (val); 366 free (conf.script_node_up), conf.script_node_up = strdup (val);
360 else if (!strcmp (var, "node-change")) 367 else if (!strcmp (var, "node-change"))
629 636
630 fclose (f); 637 fclose (f);
631 } 638 }
632 else 639 else
633 { 640 {
634 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno));
635
636 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));
637 exit (EXIT_FAILURE); 644 exit (EXIT_FAILURE);
645 }
638 } 646 }
639 647
640 free (fname); 648 free (fname);
641 649
642 if (need_keys && ::thisnode 650 if (need_keys && ::thisnode
646 { 654 {
647 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);
648 exit (EXIT_FAILURE); 656 exit (EXIT_FAILURE);
649 } 657 }
650 658
659 fname = conf.config_filename (conf.pidfilename);
660 free (conf.pidfilename); conf.pidfilename = fname;
661
651 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)
652 (*i)->finalise (); 663 (*i)->finalise ();
653} 664}
654 665
655char * 666char *
656configuration::config_filename (const char *name, const char *dflt) 667configuration::config_filename (const char *name, const char *dflt)
657{ 668{
658 char *fname; 669 char *fname;
659 670
660 asprintf (&fname, name ? name : dflt, ::thisnode); 671 asprintf (&fname, name ? name : dflt, ::thisnode ? ::thisnode : "<unset>");
661 672
662 if (!ABSOLUTE_PATH (fname)) 673 if (!ABSOLUTE_PATH (fname))
663 { 674 {
664 char *rname = fname; 675 char *rname = fname;
665 asprintf (&fname, "%s/%s", confbase, rname); 676 asprintf (&fname, "%s/%s", confbase, rname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines