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
 
@@ -30,12 +30,13 @@
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal) in the minds of your average joe
 
#include "protocol.h"
 
#include "options.h" // Confuse, etc.
 
#include "slavefuncs.h" // Slave functions
 
#include <string.h>
 
#include <stdio.h>
 
#include <unistd.h>
 

	
 
int slavestatus = 0; // Ugh global vars
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 
@@ -70,16 +71,16 @@ for(counter=0; counter<argc; counter++){
 
		{
 
			fprintf(stderr, "I want to see an '@' in your email address!\n%s may be good enough for you, but I need more!\n", email);
 
			return 235;
 
		}
 
		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
 
@@ -20,26 +20,39 @@
 
 /*
 
  * Registration on server. Needs attention. Prevent account spamming.
 
  * distrenslave -c username email@example.com
 
 */
 
#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)
 
{
 
  /*
 
   * Logs into sandboxed user on zserver2 and registers a user. Should eventually generate a key on the server and return it to the user.
 
   * 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[] =
 
    {
 
      "ssh",
 
      "distren_setup@protofusion.org",
 
@@ -68,13 +81,13 @@ int register_user(char *username, char *
 
      }
 
      buf[readlen] = '\0'; // Null-terminating the end of it again based on how large the data is?
 
      fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  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
 
@@ -18,13 +18,13 @@
 
*/
 

	
 
#ifndef _DISTREN_SLAVEFUNCS_H
 
#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);
 
void exec_blender(struct blendjob* blendjob, char *input, char *output, int frame);
 

	
 

	
0 comments (0 inline, 0 general)