Changeset - 38944c233d6a
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-30 17:45:10

Added key existance checker, next step: execv => execio
1 file changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -27,6 +27,9 @@
 
#include <string.h>
 
#include <unistd.h>
 
#include <stdlib.h> /*< malloc(), free() */
 
#include <sys/stat.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 

	
 
/** Generates a SSH key with ssh-keygen */
 
int ssh_keygen(){
 
@@ -35,7 +38,15 @@ int ssh_keygen(){
 
	char *path_to_command = "/usr/bin/ssh-keygen";
 
	int ret;
 
	char *cmd[] = { command, "-q", "-f", SYSCONFDIR "/distren.id_rsa", "-N", "", (char *)0 }; // TODO: Give me the correct args!
 
	/** We're crashing right at this next statement below! */
 

	
 
	// Checks to see if the keys are already present.
 
	int status;
 
	struct stat buffer;
 
	status = stat(SYSCONFDIR "/distren.id_rsa", &buffer);
 
	if(status == -1){
 
		fprintf(stderr, "Please delete etc/distren.id_rsa and etc/distren.id_rsa.pub to register.");
 
	}
 

	
 
	ret = execv(path_to_command, cmd); // This path will be absolute for testing, should be relative to install on production
 
	if(ret == -1){
 
		fprintf(stderr, "Generating your key failed. Ensure that ssh-keygen is present!\n"); // Use different executor that searches the path? there is one...
0 comments (0 inline, 0 general)