@@ -990,6 +990,11 @@ do_gen_all_hostkeys(struct passwd *pw)
990
990
}
991
991
sshkey_free (private );
992
992
strlcat (identity_file , ".pub" , sizeof (identity_file ));
993
+ #ifdef WINDOWS
994
+ if ((f = fopen (identity_file , "w" )) == NULL ) {
995
+ error ("fopen %s failed: %s" , identity_file , strerror (errno ));
996
+ /* TODO - set permissions on file */
997
+ #else
993
998
fd = open (identity_file , O_WRONLY | O_CREAT | O_TRUNC , 0644 );
994
999
if (fd == -1 ) {
995
1000
error ("Could not save your public key in %s" ,
@@ -999,9 +1004,11 @@ do_gen_all_hostkeys(struct passwd *pw)
999
1004
continue ;
1000
1005
}
1001
1006
f = fdopen (fd , "w" );
1007
+
1002
1008
if (f == NULL ) {
1003
1009
error ("fdopen %s failed" , identity_file );
1004
1010
close (fd );
1011
+ #endif
1005
1012
sshkey_free (public );
1006
1013
first = 0 ;
1007
1014
continue ;
@@ -2765,10 +2772,10 @@ main(int argc, char **argv)
2765
2772
printf ("Your identification has been saved in %s.\n" , identity_file );
2766
2773
2767
2774
strlcat (identity_file , ".pub" , sizeof (identity_file ));
2768
- /* TODO - for windows call fopen directly*/
2769
2775
#ifdef WINDOWS
2770
2776
if ((f = fopen (identity_file , "w" )) == NULL )
2771
2777
fatal ("fopen %s failed: %s" , identity_file , strerror (errno ));
2778
+ /* TODO - set permissions on file */
2772
2779
#else
2773
2780
if ((fd = open (identity_file , O_WRONLY |O_CREAT |O_TRUNC , 0644 )) == -1 )
2774
2781
fatal ("Unable to save public key to %s: %s" ,
0 commit comments