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.21 by root, Wed Nov 2 05:58:53 2016 UTC vs.
Revision 1.25 by root, Thu Oct 6 03:03:09 2022 UTC

1/* 1/*
2 gvpectrl.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-2013 Marc Lehmann <gvpe@schmorp.de> 5 2003-2016 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 it 9 GVPE is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
246 * generate public/private RSA keypairs for all hosts that don't have one. 246 * generate public/private RSA keypairs for all hosts that don't have one.
247 */ 247 */
248static int 248static int
249keygen (const char *pub, const char *priv) 249keygen (const char *pub, const char *priv)
250{ 250{
251 /* some libcs are buggy and require an extra seek to the end */
251 252
252 FILE *pubf = fopen (pub, "ab"); 253 FILE *pubf = fopen (pub, "ab");
253 if (!pubf || fseek (pubf, 0, SEEK_END)) 254 if (!pubf || fseek (pubf, 0, SEEK_END))
254 { 255 {
255 perror (pub); 256 perror (pub);
261 fclose (pubf); 262 fclose (pubf);
262 return 1; 263 return 1;
263 } 264 }
264 265
265 FILE *privf = fopen (priv, "ab"); 266 FILE *privf = fopen (priv, "ab");
266
267 /* some libcs are buggy and require an extra seek to the end */
268 if (!privf || fseek (privf, 0, SEEK_END)) 267 if (!privf || fseek (privf, 0, SEEK_END))
269 { 268 {
270 perror (priv); 269 perror (priv);
271 exit (EXIT_FAILURE); 270 exit (EXIT_FAILURE);
272 } 271 }
347static int 346static int
348keygen_one (const char *pubname) 347keygen_one (const char *pubname)
349{ 348{
350 char *privname; 349 char *privname;
351 350
352 asprintf (&privname, "%s.key", pubname); 351 asprintf (&privname, "%s.privkey", pubname);
353 352
354 int status = keygen (pubname, privname); 353 int status = keygen (pubname, privname);
355 354
356 if (status == 0) 355 if (status == 0)
357 { 356 {
362 { 361 {
363 fprintf (stderr, _("'%s' keypair already exists, not generating key.\n"), pubname); 362 fprintf (stderr, _("'%s' keypair already exists, not generating key.\n"), pubname);
364 exit (EXIT_FAILURE); 363 exit (EXIT_FAILURE);
365 } 364 }
366 365
367 free(privname); 366 free (privname);
367
368 return 0;
368} 369}
369 370
370int 371int
371main (int argc, char **argv, char **envp) 372main (int argc, char **argv, char **envp)
372{ 373{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines