Changeset - 8feb0005e773
[Not reviewed]
default
0 3 0
ethanzonca - 16 years ago 2009-07-28 17:04:15

ssh_keygen executes nicely, someone find the args for non-interactive, dies on errors, but doesn't die hard enough.
3 files changed with 22 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -33,6 +33,7 @@
 
#include "slavefuncs.h" // Slave functions
 
#include <string.h>
 
#include <stdio.h>
 
#include <unistd.h>
 

	
 
int slavestatus = 0; // Ugh global vars
 

	
 
@@ -73,10 +74,10 @@ for(counter=0; counter<argc; counter++){
 
		}
 
		if( register_user(username, email) == 1){
 
			// register_user generates a key, too */
 
			fprintf(stderr,"Registration successfull. You may now invoke distrenslave with no arguments.");
 
			fprintf(stderr,"Registration successfull. You may now invoke distrenslave with no arguments.\n");
 
		}
 
		else{
 
			fprintf(stderr,"Registration failed. Sorry!");
 
			fprintf(stderr,"Registration failed. Sorry!\n");
 
		}
 
	}
 
/* End arg parser */
src/server/slavefuncs.c
Show inline comments
 
@@ -23,10 +23,24 @@
 
 */
 
#include <stdio.h>
 
#include <string.h>
 

	
 
#include <unistd.h>
 

	
 
void ssh_keygen(){
 
	// Give me some args!
 
int ssh_keygen(){
 
	fprintf(stderr, "We're generating your SSH key. Please be patient.\n");
 
	char *command = "ssh-keygenn"; // append .exe if win32?
 
	char *path_to_command = "/usr/bin/ssh-keygenn";
 
	int ret;
 
	char *cmd[] = { command, "-b", "-o", (char *)0 }; // TODO: Give me the correct args!
 
	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...
 
		return 0;
 
	}
 
	else{
 
		fprintf(stderr,"We successfully generated your key! Yay!");
 
		return 1;
 
	}
 
return 0;
 
}
 

	
 
int register_user(char *username, char *email)
 
@@ -36,7 +50,6 @@ int register_user(char *username, char *
 
   * All created user accounts should be sandboxed accordingly, requiring a different skel, and the default shell to be rbash. Also,
 
   * a custom path defined in the .bash_profile of the skel is needed.
 
   */
 
  char *keyname; // Url to the key
 
  char buf[10];
 
  struct execio *testrem;
 
  char *execargv[] =
 
@@ -71,7 +84,7 @@ int register_user(char *username, char *
 
    }
 
  execio_close(testrem);
 

	
 
  ssh_keygen(); // Should return relative path to keyfile, or jus the keyname
 
  ssh_keygen(); // generates username.rsa
 

	
 
  /* TODO: Scan distrenslave.conf for !username and !key and replace them with "keyname" and the "username" */
 
  return 1;
src/server/slavefuncs.h
Show inline comments
 
@@ -21,7 +21,7 @@
 
#define _DISTREN_SLAVEFUNCS_H
 
#include "blendjob.h"
 

	
 
void ssh_keygen();
 
int ssh_keygen();
 
int register_user(char *username, char *email);
 
int login_user(char *username);
 
void conf_replace(char *username, char *key);
0 comments (0 inline, 0 general)