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

Comparing gvpe/src/gvpectrl.C (file contents):
Revision 1.1 by pcg, Fri Mar 18 01:53:05 2005 UTC vs.
Revision 1.7 by pcg, Thu Aug 7 17:54:27 2008 UTC

1/* 1/*
2 vpectrl.C -- the main file for gvpectrl 2 gvpectrl.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-2005 Marc Lehmann <gvpe@schmorp.de> 5 2003-2008 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE. 7 This file is part of GVPE.
8 8
9 GVPE is free software; you can redistribute it and/or modify 9 GVPE is free software; you can redistribute it and/or modify it
10 it under the terms of the GNU General Public License as published by 10 under the terms of the GNU General Public License as published by the
11 the Free Software Foundation; either version 2 of the License, or 11 Free Software Foundation; either version 3 of the License, or (at your
12 (at your option) any later version. 12 option) any later version.
13 13
14 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, but
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 GNU General Public License for more details. 17 Public License for more details.
18 18
19 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 along
20 along with gvpe; if not, write to the Free Software 20 with this program; if not, see <http://www.gnu.org/licenses/>.
21 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21
22 Additional permission under GNU GPL version 3 section 7
23
24 If you modify this Program, or any covered work, by linking or
25 combining it with the OpenSSL project's OpenSSL library (or a modified
26 version of that library), containing parts covered by the terms of the
27 OpenSSL or SSLeay licenses, the licensors of this Program grant you
28 additional permission to convey the resulting work. Corresponding
29 Source for a non-source form of such a combination shall include the
30 source code for the parts of OpenSSL used as well as that of the
31 covered work.
22*/ 32*/
23 33
24#include "config.h" 34#include "config.h"
25 35
26#include <cstdio> 36#include <cstdio>
52static int show_help; 62static int show_help;
53 63
54/* If nonzero, print the version on standard output and exit. */ 64/* If nonzero, print the version on standard output and exit. */
55static int show_version; 65static int show_version;
56 66
57/* If nonzero, it will attempt to kill a running vped and exit. */ 67/* If nonzero, it will attempt to kill a running gvpe and exit. */
58static int kill_vped; 68static int kill_gvpe;
59 69
60/* If nonzero, it will attempt to kill a running vped and exit. */ 70/* If nonzero, it will attempt to kill a running gvpe and exit. */
61static int show_config; 71static int show_config;
62 72
63/* If nonzero, generate public/private keypair for this net. */ 73/* If nonzero, generate public/private keypair for this net. */
64static int generate_keys; 74static int generate_keys;
65 75
82 else 92 else
83 { 93 {
84 printf (_("Usage: %s [option]...\n\n"), get_identity ()); 94 printf (_("Usage: %s [option]...\n\n"), get_identity ());
85 printf (_ 95 printf (_
86 (" -c, --config=DIR Read configuration options from DIR.\n" 96 (" -c, --config=DIR Read configuration options from DIR.\n"
87 " -k, --kill[=SIGNAL] Attempt to kill a running vped and exit.\n" 97 " -k, --kill[=SIGNAL] Attempt to kill a running gvpe and exit.\n"
88 " -g, --generate-keys Generate public/private RSA keypair.\n" 98 " -g, --generate-keys Generate public/private RSA keypair.\n"
89 " -s, --show-config Display the configuration information.\n" 99 " -s, --show-config Display the configuration information.\n"
90 " --help Display this help and exit.\n" 100 " --help Display this help and exit.\n"
91 " --version Output version information and exit.\n\n")); 101 " --version Output version information and exit.\n\n"));
92 printf (_("Report bugs to <vpe@plan9.de>.\n")); 102 printf (_("Report bugs to <gvpe@schmorp.de>.\n"));
93 } 103 }
94 104
95 exit (status); 105 exit (status);
96} 106}
97 107
112 122
113 case 'c': /* config file */ 123 case 'c': /* config file */
114 confbase = strdup (optarg); 124 confbase = strdup (optarg);
115 break; 125 break;
116 126
117 case 'k': /* kill old vpeds */ 127 case 'k': /* kill old gvpes */
118 if (optarg) 128 if (optarg)
119 { 129 {
120 if (!strcasecmp (optarg, "HUP")) 130 if (!strcasecmp (optarg, "HUP"))
121 kill_vped = SIGHUP; 131 kill_gvpe = SIGHUP;
122 else if (!strcasecmp (optarg, "TERM")) 132 else if (!strcasecmp (optarg, "TERM"))
123 kill_vped = SIGTERM; 133 kill_gvpe = SIGTERM;
124 else if (!strcasecmp (optarg, "KILL")) 134 else if (!strcasecmp (optarg, "KILL"))
125 kill_vped = SIGKILL; 135 kill_gvpe = SIGKILL;
126 else if (!strcasecmp (optarg, "USR1")) 136 else if (!strcasecmp (optarg, "USR1"))
127 kill_vped = SIGUSR1; 137 kill_gvpe = SIGUSR1;
128 else if (!strcasecmp (optarg, "USR2")) 138 else if (!strcasecmp (optarg, "USR2"))
129 kill_vped = SIGUSR2; 139 kill_gvpe = SIGUSR2;
130 else if (!strcasecmp (optarg, "INT")) 140 else if (!strcasecmp (optarg, "INT"))
131 kill_vped = SIGINT; 141 kill_gvpe = SIGINT;
132 else if (!strcasecmp (optarg, "ALRM")) 142 else if (!strcasecmp (optarg, "ALRM"))
133 kill_vped = SIGALRM; 143 kill_gvpe = SIGALRM;
134 else 144 else
135 { 145 {
136 kill_vped = atoi (optarg); 146 kill_gvpe = atoi (optarg);
137 147
138 if (!kill_vped) 148 if (!kill_gvpe)
139 { 149 {
140 fprintf (stderr, 150 fprintf (stderr,
141 _ 151 _
142 ("Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n"), 152 ("Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n"),
143 optarg); 153 optarg);
144 usage (1); 154 usage (1);
145 } 155 }
146 } 156 }
147 } 157 }
148 else 158 else
149 kill_vped = SIGTERM; 159 kill_gvpe = SIGTERM;
150 160
151 break; 161 break;
152 162
153 case 'g': /* generate public/private keypair */ 163 case 'g': /* generate public/private keypair */
154 generate_keys = RSA_KEYBITS; 164 generate_keys = RSA_KEYBITS;
294 304
295 parse_options (argc, argv, envp); 305 parse_options (argc, argv, envp);
296 306
297 if (show_version) 307 if (show_version)
298 { 308 {
299 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), 309 printf (_("%s version %s (built %s %s, protocol version %d.%d)\n"), get_identity (),
300 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 310 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
301 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); 311 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
302 printf (_ 312 printf (_
303 ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" 313 ("Copyright (C) 2003 Marc Lehmann <gvpe@schmorp.de> and others.\n"
304 "See the AUTHORS file for a complete list.\n\n" 314 "See the AUTHORS file for a complete list.\n\n"
305 "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n" 315 "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
306 "and you are welcome to redistribute it under certain conditions;\n" 316 "and you are welcome to redistribute it under certain conditions;\n"
307 "see the file COPYING for details.\n")); 317 "see the file COPYING for details.\n"));
308 318
310 } 320 }
311 321
312 if (show_help) 322 if (show_help)
313 usage (0); 323 usage (0);
314 324
315 conf.read_config (false); 325 {
326 configuration_parser (conf, false, 0, 0);
327 }
316 328
317 if (generate_keys) 329 if (generate_keys)
318 { 330 {
319 RAND_load_file ("/dev/urandom", 1024); 331 RAND_load_file ("/dev/urandom", 1024);
320 exit (keygen (generate_keys)); 332 exit (keygen (generate_keys));
321 } 333 }
322 334
323 if (kill_vped) 335 if (kill_gvpe)
324 exit (kill_other (kill_vped)); 336 exit (kill_other (kill_gvpe));
325 337
326 if (show_config) 338 if (show_config)
327 { 339 {
328 conf.print (); 340 conf.print ();
329 exit (EXIT_SUCCESS); 341 exit (EXIT_SUCCESS);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines