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.9 by pcg, Fri Nov 21 05:02:08 2008 UTC vs.
Revision 1.10 by root, Tue Feb 8 23:11:36 2011 UTC

75 75
76/* If nonzero, generate public/private keypair for this net. */ 76/* If nonzero, generate public/private keypair for this net. */
77static int generate_keys; 77static int generate_keys;
78 78
79static struct option const long_options[] = 79static struct option const long_options[] =
80 { 80{
81 {"config", required_argument, NULL, 'c'}, 81 {"config", required_argument, NULL, 'c'},
82 {"kill", optional_argument, NULL, 'k'}, 82 {"kill", optional_argument, NULL, 'k'},
83 {"help", no_argument, &show_help, 1}, 83 {"help", no_argument, &show_help, 1},
84 {"version", no_argument, &show_version, 1}, 84 {"version", no_argument, &show_version, 1},
85 {"generate-keys", no_argument, NULL, 'g'}, 85 {"generate-keys", no_argument, NULL, 'g'},
86 {"quiet", no_argument, &quiet, 1}, 86 {"quiet", no_argument, &quiet, 1},
87 {"show-config", no_argument, &show_config, 's'}, 87 {"show-config", no_argument, &show_config, 's'},
88 {NULL, 0, NULL, 0} 88 {NULL, 0, NULL, 0}
89 }; 89};
90 90
91static void 91static void
92usage (int status) 92usage (int status)
93{ 93{
94 if (status != 0) 94 if (status != 0)
108 } 108 }
109 109
110 exit (status); 110 exit (status);
111} 111}
112 112
113void 113static void
114parse_options (int argc, char **argv, char **envp) 114parse_options (int argc, char **argv, char **envp)
115{ 115{
116 int r; 116 int r;
117 int option_index = 0; 117 int option_index = 0;
118 118
119 while ((r = getopt_long (argc, argv, "c:k::qgs", long_options, &option_index)) != EOF) 119 while ((r = getopt_long (argc, argv, "c:k::qgs", long_options, &option_index)) != EOF)
120 { 120 {
121 switch (r) 121 switch (r)
122 { 122 {
123 case 0: /* long option */ 123 case 0: /* long option */
124 break; 124 break;
125 125
126 case 'c': /* config file */ 126 case 'c': /* config file */
127 confbase = strdup (optarg); 127 confbase = strdup (optarg);
128 break; 128 break;
129 129
130 case 'k': /* kill old gvpes */ 130 case 'k': /* kill old gvpes */
131 if (optarg) 131 if (optarg)
132 { 132 {
133 if (!strcasecmp (optarg, "HUP")) 133 if (!strcasecmp (optarg, "HUP"))
134 kill_gvpe = SIGHUP; 134 kill_gvpe = SIGHUP;
135 else if (!strcasecmp (optarg, "TERM")) 135 else if (!strcasecmp (optarg, "TERM"))
136 kill_gvpe = SIGTERM; 136 kill_gvpe = SIGTERM;
137 else if (!strcasecmp (optarg, "KILL")) 137 else if (!strcasecmp (optarg, "KILL"))
138 kill_gvpe = SIGKILL; 138 kill_gvpe = SIGKILL;
139 else if (!strcasecmp (optarg, "USR1")) 139 else if (!strcasecmp (optarg, "USR1"))
140 kill_gvpe = SIGUSR1; 140 kill_gvpe = SIGUSR1;
141 else if (!strcasecmp (optarg, "USR2")) 141 else if (!strcasecmp (optarg, "USR2"))
142 kill_gvpe = SIGUSR2; 142 kill_gvpe = SIGUSR2;
143 else if (!strcasecmp (optarg, "INT")) 143 else if (!strcasecmp (optarg, "INT"))
144 kill_gvpe = SIGINT; 144 kill_gvpe = SIGINT;
145 else if (!strcasecmp (optarg, "ALRM")) 145 else if (!strcasecmp (optarg, "ALRM"))
146 kill_gvpe = SIGALRM; 146 kill_gvpe = SIGALRM;
147 else 147 else
148 { 148 {
149 kill_gvpe = atoi (optarg); 149 kill_gvpe = atoi (optarg);
150 150
151 if (!kill_gvpe) 151 if (!kill_gvpe)
152 { 152 {
153 fprintf (stderr, 153 fprintf (stderr,
154 _ 154 _
155 ("Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n"), 155 ("Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n"),
156 optarg); 156 optarg);
157 usage (1); 157 usage (1);
158 } 158 }
159 } 159 }
160 } 160 }
161 else 161 else
162 kill_gvpe = SIGTERM; 162 kill_gvpe = SIGTERM;
163 163
164 break; 164 break;
165 165
166 case 'g': /* generate public/private keypair */ 166 case 'g': /* generate public/private keypair */
167 generate_keys = RSA_KEYBITS; 167 generate_keys = RSA_KEYBITS;
168 break; 168 break;
169 169
170 case 's': 170 case 's':
171 show_config = 1; 171 show_config = 1;
172 break; 172 break;
173 173
174 case 'q': 174 case 'q':
175 quiet = 1; 175 quiet = 1;
176 break; 176 break;
177 177
178 case '?': 178 case '?':
179 usage (1); 179 usage (1);
180 180
181 default: 181 default:
182 break; 182 break;
183 } 183 }
184 } 184 }
185} 185}
186 186
187/* This function prettyprints the key generation process */ 187// this function prettyprints the key generation process
188 188static void
189void
190indicator (int a, int b, void *p) 189indicator (int a, int b, void *p)
191{ 190{
192 if (quiet) 191 if (quiet)
193 return; 192 return;
194 193
195 switch (a) 194 switch (a)
196 { 195 {
197 case 0: 196 case 0:
198 fprintf (stderr, "."); 197 fprintf (stderr, ".");
199 break; 198 break;
200 199
201 case 1: 200 case 1:
202 fprintf (stderr, "+"); 201 fprintf (stderr, "+");
203 break; 202 break;
204 203
205 case 2: 204 case 2:
206 fprintf (stderr, "-"); 205 fprintf (stderr, "-");
207 break; 206 break;
208 207
209 case 3: 208 case 3:
210 switch (b) 209 switch (b)
211 { 210 {
212 case 0: 211 case 0:
213 fprintf (stderr, " p\n"); 212 fprintf (stderr, " p\n");
214 break; 213 break;
215 214
216 case 1: 215 case 1:
217 fprintf (stderr, " q\n"); 216 fprintf (stderr, " q\n");
218 break; 217 break;
219 218
220 default: 219 default:
221 fprintf (stderr, "?"); 220 fprintf (stderr, "?");
222 } 221 }
223 break; 222 break;
224 223
225 default: 224 default:
226 fprintf (stderr, "?"); 225 fprintf (stderr, "?");
227 } 226 }
228} 227}
229 228
230/* 229/*
231 * generate public/private RSA keypairs for all hosts that don't have one. 230 * generate public/private RSA keypairs for all hosts that don't have one.
232 */ 231 */
233int 232static int
234keygen (int bits) 233keygen (int bits)
235{ 234{
236 RSA *rsa_key; 235 RSA *rsa_key;
237 FILE *f; 236 FILE *f;
238 char *name = NULL; 237 char *name = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines