@@ -776,24 +776,6 @@ static void key_gen_check(const char *kfilename)
776776 unlink (kfilename );
777777 }
778778 }
779- #if 0
780- f = fopen (pubkeyfile , "rb" );
781- if (!force && (f != NULL )) {
782- char reply [40 ];
783- int replySz ;
784- printf ("** Warning: keystore already exists! Are you sure you want to generate a new key and overwrite the existing key? [Type 'Yes']: " );
785- fflush (stdout );
786- replySz = scanf ("%s" , reply );
787- printf ("Reply is [%s]\n" , reply );
788- fclose (f );
789- if (replySz < 0 || strcmp (reply , "Yes" ) != 0 ) {
790- printf ("Operation aborted by user." );
791- exit (5 );
792- } else {
793- unlink (pubkeyfile );
794- }
795- }
796- #endif
797779}
798780
799781static void key_generate (uint32_t ktype , const char * kfilename , uint32_t id_mask )
@@ -1060,6 +1042,23 @@ int main(int argc, char** argv)
10601042 printf ("Keytype: %s\n" , KName [keytype ]);
10611043 if (keytype == 0 )
10621044 exit (0 );
1045+ fpub = fopen (pubkeyfile , "rb" );
1046+ if (!force && (fpub != NULL )) {
1047+ char reply [40 ];
1048+ int replySz ;
1049+ printf ("** Warning: keystore already exists! Are you sure you want to generate a new key and overwrite the existing key? [Type 'Yes']: " );
1050+ fflush (stdout );
1051+ replySz = scanf ("%s" , reply );
1052+ printf ("Reply is [%s]\n" , reply );
1053+ fclose (fpub );
1054+ if (replySz < 0 || strcmp (reply , "Yes" ) != 0 ) {
1055+ printf ("Operation aborted by user." );
1056+ exit (5 );
1057+ } else {
1058+ unlink (pubkeyfile );
1059+ }
1060+ fpub = NULL ;
1061+ }
10631062 fpub = fopen (pubkeyfile , "w" );
10641063 if (fpub == NULL ) {
10651064 fprintf (stderr , "Unable to open file '%s' for writing: %s" , pubkeyfile , strerror (errno ));
0 commit comments