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

Comparing gvpe/src/vpectrl.C (file contents):
Revision 1.6 by pcg, Thu Oct 16 21:57:54 2003 UTC vs.
Revision 1.13 by pcg, Thu Mar 3 16:54:34 2005 UTC

1/* 1/*
2 vpectrl.C -- the main file for vpectrl 2 vpectrl.C -- the main file for gvpectrl
3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl> 3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
4 2000-2002 Guus Sliepen <guus@sliepen.eu.org> 4 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
5 2003 Marc Lehmann <pcg@goof.com> 5 2003-2005 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE.
8
7 This program is free software; you can redistribute it and/or modify 9 GVPE is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 11 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 12 (at your option) any later version.
11 13
12 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 17 GNU General Public License for more details.
16 18
17 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 20 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/ 22*/
21 23
22#include "config.h" 24#include "config.h"
23 25
24#include <cstdio> 26#include <cstdio>
25#include <cstring> 27#include <cstring>
28#include <cstdlib>
29#include <locale.h>
26 30
27#include <errno.h> 31#include <errno.h>
28#include <fcntl.h> 32#include <fcntl.h>
29#include <getopt.h> 33#include <getopt.h>
30#include <signal.h> 34#include <signal.h>
124 kill_vped = SIGKILL; 128 kill_vped = SIGKILL;
125 else if (!strcasecmp (optarg, "USR1")) 129 else if (!strcasecmp (optarg, "USR1"))
126 kill_vped = SIGUSR1; 130 kill_vped = SIGUSR1;
127 else if (!strcasecmp (optarg, "USR2")) 131 else if (!strcasecmp (optarg, "USR2"))
128 kill_vped = SIGUSR2; 132 kill_vped = SIGUSR2;
129 else if (!strcasecmp (optarg, "WINCH"))
130 kill_vped = SIGWINCH;
131 else if (!strcasecmp (optarg, "INT")) 133 else if (!strcasecmp (optarg, "INT"))
132 kill_vped = SIGINT; 134 kill_vped = SIGINT;
133 else if (!strcasecmp (optarg, "ALRM")) 135 else if (!strcasecmp (optarg, "ALRM"))
134 kill_vped = SIGALRM; 136 kill_vped = SIGALRM;
135 else 137 else
236 f = fopen (fname, "a"); 238 f = fopen (fname, "a");
237 239
238 if (!f) 240 if (!f)
239 { 241 {
240 perror (fname); 242 perror (fname);
241 exit (1); 243 exit (EXIT_FAILURE);
242 } 244 }
243 245
244 if (ftell (f)) 246 if (ftell (f))
245 { 247 {
246 fprintf (stderr, "'%s' already exists, skipping this node\n", 248 fprintf (stderr, "'%s' already exists, skipping this node\n",
260 return -1; 262 return -1;
261 } 263 }
262 else 264 else
263 fprintf (stderr, _("Done.\n")); 265 fprintf (stderr, _("Done.\n"));
264 266
265 PEM_write_RSAPublicKey (f, rsa_key); 267 require (PEM_write_RSAPublicKey (f, rsa_key));
266 fclose (f); 268 fclose (f);
267 free (fname); 269 free (fname);
268 270
269 asprintf (&fname, "%s/hostkeys/%s", confbase, node->nodename); 271 asprintf (&fname, "%s/hostkeys/%s", confbase, node->nodename);
270 272
271 f = fopen (fname, "a"); 273 f = fopen (fname, "a");
272 if (!f) 274 if (!f)
273 { 275 {
274 perror (fname); 276 perror (fname);
275 exit (1); 277 exit (EXIT_FAILURE);
276 } 278 }
277 279
278 PEM_write_RSAPrivateKey (f, rsa_key, NULL, NULL, 0, NULL, NULL); 280 require (PEM_write_RSAPrivateKey (f, rsa_key, NULL, NULL, 0, NULL, NULL));
279 fclose (f); 281 fclose (f);
280 free (fname); 282 free (fname);
281 } 283 }
282 284
283 return 0; 285 return 0;
311 } 313 }
312 314
313 if (show_help) 315 if (show_help)
314 usage (0); 316 usage (0);
315 317
316 make_names ();
317 conf.read_config (false); 318 conf.read_config (false);
318 319
319 if (generate_keys) 320 if (generate_keys)
320 { 321 {
321 RAND_load_file ("/dev/urandom", 1024); 322 RAND_load_file ("/dev/urandom", 1024);
326 exit (kill_other (kill_vped)); 327 exit (kill_other (kill_vped));
327 328
328 if (show_config) 329 if (show_config)
329 { 330 {
330 conf.print (); 331 conf.print ();
331 exit (0); 332 exit (EXIT_SUCCESS);
332 } 333 }
333 334
334 usage (1); 335 usage (1);
335} 336}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines