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-2004 Marc Lehmann <pcg@goof.com> |
6 | |
6 | |
7 | This program is free software; you can redistribute it and/or modify |
7 | This program is free software; you can redistribute it and/or modify |
8 | 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 |
9 | the Free Software Foundation; either version 2 of the License, or |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
10 | (at your option) any later version. |
… | |
… | |
21 | |
21 | |
22 | #include "config.h" |
22 | #include "config.h" |
23 | |
23 | |
24 | #include <cstdio> |
24 | #include <cstdio> |
25 | #include <cstring> |
25 | #include <cstring> |
|
|
26 | #include <cstdlib> |
|
|
27 | #include <clocale> |
26 | |
28 | |
27 | #include <errno.h> |
29 | #include <errno.h> |
28 | #include <fcntl.h> |
30 | #include <fcntl.h> |
29 | #include <getopt.h> |
31 | #include <getopt.h> |
30 | #include <signal.h> |
32 | #include <signal.h> |
… | |
… | |
124 | kill_vped = SIGKILL; |
126 | kill_vped = SIGKILL; |
125 | else if (!strcasecmp (optarg, "USR1")) |
127 | else if (!strcasecmp (optarg, "USR1")) |
126 | kill_vped = SIGUSR1; |
128 | kill_vped = SIGUSR1; |
127 | else if (!strcasecmp (optarg, "USR2")) |
129 | else if (!strcasecmp (optarg, "USR2")) |
128 | kill_vped = SIGUSR2; |
130 | kill_vped = SIGUSR2; |
129 | else if (!strcasecmp (optarg, "WINCH")) |
|
|
130 | kill_vped = SIGWINCH; |
|
|
131 | else if (!strcasecmp (optarg, "INT")) |
131 | else if (!strcasecmp (optarg, "INT")) |
132 | kill_vped = SIGINT; |
132 | kill_vped = SIGINT; |
133 | else if (!strcasecmp (optarg, "ALRM")) |
133 | else if (!strcasecmp (optarg, "ALRM")) |
134 | kill_vped = SIGALRM; |
134 | kill_vped = SIGALRM; |
135 | else |
135 | else |
… | |
… | |
236 | f = fopen (fname, "a"); |
236 | f = fopen (fname, "a"); |
237 | |
237 | |
238 | if (!f) |
238 | if (!f) |
239 | { |
239 | { |
240 | perror (fname); |
240 | perror (fname); |
241 | exit (1); |
241 | exit (EXIT_FAILURE); |
242 | } |
242 | } |
243 | |
243 | |
244 | if (ftell (f)) |
244 | if (ftell (f)) |
245 | { |
245 | { |
246 | fprintf (stderr, "'%s' already exists, skipping this node\n", |
246 | fprintf (stderr, "'%s' already exists, skipping this node\n", |
… | |
… | |
260 | return -1; |
260 | return -1; |
261 | } |
261 | } |
262 | else |
262 | else |
263 | fprintf (stderr, _("Done.\n")); |
263 | fprintf (stderr, _("Done.\n")); |
264 | |
264 | |
265 | PEM_write_RSAPublicKey (f, rsa_key); |
265 | require (PEM_write_RSAPublicKey (f, rsa_key)); |
266 | fclose (f); |
266 | fclose (f); |
267 | free (fname); |
267 | free (fname); |
268 | |
268 | |
269 | asprintf (&fname, "%s/hostkeys/%s", confbase, node->nodename); |
269 | asprintf (&fname, "%s/hostkeys/%s", confbase, node->nodename); |
270 | |
270 | |
271 | f = fopen (fname, "a"); |
271 | f = fopen (fname, "a"); |
272 | if (!f) |
272 | if (!f) |
273 | { |
273 | { |
274 | perror (fname); |
274 | perror (fname); |
275 | exit (1); |
275 | exit (EXIT_FAILURE); |
276 | } |
276 | } |
277 | |
277 | |
278 | PEM_write_RSAPrivateKey (f, rsa_key, NULL, NULL, 0, NULL, NULL); |
278 | require (PEM_write_RSAPrivateKey (f, rsa_key, NULL, NULL, 0, NULL, NULL)); |
279 | fclose (f); |
279 | fclose (f); |
280 | free (fname); |
280 | free (fname); |
281 | } |
281 | } |
282 | |
282 | |
283 | return 0; |
283 | return 0; |
… | |
… | |
297 | |
297 | |
298 | if (show_version) |
298 | if (show_version) |
299 | { |
299 | { |
300 | printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), |
300 | printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), |
301 | VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); |
301 | VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); |
|
|
302 | printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); |
302 | printf (_ |
303 | printf (_ |
303 | ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" |
304 | ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" |
304 | "See the AUTHORS file for a complete list.\n\n" |
305 | "See the AUTHORS file for a complete list.\n\n" |
305 | "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n" |
306 | "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n" |
306 | "and you are welcome to redistribute it under certain conditions;\n" |
307 | "and you are welcome to redistribute it under certain conditions;\n" |
… | |
… | |
310 | } |
311 | } |
311 | |
312 | |
312 | if (show_help) |
313 | if (show_help) |
313 | usage (0); |
314 | usage (0); |
314 | |
315 | |
315 | make_names (); |
|
|
316 | conf.read_config (false); |
316 | conf.read_config (false); |
317 | |
317 | |
318 | if (generate_keys) |
318 | if (generate_keys) |
319 | { |
319 | { |
320 | RAND_load_file ("/dev/urandom", 1024); |
320 | RAND_load_file ("/dev/urandom", 1024); |
… | |
… | |
325 | exit (kill_other (kill_vped)); |
325 | exit (kill_other (kill_vped)); |
326 | |
326 | |
327 | if (show_config) |
327 | if (show_config) |
328 | { |
328 | { |
329 | conf.print (); |
329 | conf.print (); |
330 | exit (0); |
330 | exit (EXIT_SUCCESS); |
331 | } |
331 | } |
332 | |
332 | |
333 | usage (1); |
333 | usage (1); |
334 | } |
334 | } |