Changeset - 5b11cfeabe1c
[Not reviewed]
default
0 3 0
ethanzonca - 16 years ago 2009-07-28 00:59:56

Added returns, error messages.
3 files changed with 22 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -71,8 +71,13 @@ 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;
 
		}
 
		register_user(username, email); // register_user returns a uniquely random url to a key */
 
		fprintf(stderr, "You registered, hopefully successfully. Invoke distrenslave with no args now.");
 
		if( register_user(username, email) == 1){
 
			// register_user generates a key, too */
 
			fprintf(stderr,"Registration successfull. You may now invoke distrenslave with no arguments.");
 
		}
 
		else{
 
			fprintf(stderr,"Registration failed. Sorry!");
 
		}
 
	}
 
/* End arg parser */
 

	
 
@@ -100,7 +105,14 @@ options_init(argc,argv,&my_cfg, myopts, 
 
	}
 
	else if(key != NULL && username != NULL || key != "!key" && username != "username" ){
 
		fprintf(stderr, "Your username is %s, and your key is %s.\n",username, key);
 
		login_user(username); // Logs in user to the server
 
		// Logs ya in:
 
		if(login_user(username) == 1){
 
			fprintf(stderr,"You should now be logged into distren.\n");
 
		}
 
		else{
 
			fprintf(stderr,"Login failed. I have no clue why. Goodbye.\n");
 
			return 0;
 
		}
 
	}
 
	else{
 
	  fprintf(stderr,"Something is terribly wrong!!!");
src/server/slavefuncs.c
Show inline comments
 
@@ -29,7 +29,7 @@ void ssh_keygen(){
 
	// Give me some args!
 
}
 

	
 
void register_user(char *username, char *email)
 
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.
 
@@ -74,11 +74,11 @@ void register_user(char *username, char 
 
  ssh_keygen(); // Should return relative path to keyfile, or jus the keyname
 

	
 
  /* TODO: Scan distrenslave.conf for !username and !key and replace them with "keyname" and the "username" */
 

	
 
  return 1;
 
}
 

	
 

	
 
void login_user(char *username){
 
int login_user(char *username){
 
	// TODO: Why does this segfault???
 
  fprintf(stderr, "Logging you in...");
 
  char *userhost = strcpy(userhost, username);
 
@@ -88,7 +88,7 @@ void login_user(char *username){
 
  fprintf(stderr, "i'm here");
 
  if(fopen(userkey, "r") == NULL){
 
	  fprintf(stderr,"Your key, %s, has not been found! Re-register or somehow regenerate your key! We need a way to regenerate keys coded in, but we don't have the facilities yet!",userkey);
 
	  return; // Maybe return something?
 
	  return 0;
 
  }
 
  char buf[10];
 
  struct execio *testrem;
 
@@ -116,6 +116,7 @@ void login_user(char *username){
 
    fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 
  execio_close(testrem);
 
  return 1; // 1 can be like... error-free login...
 
}
 

	
 
/* Replaces username and key in the slave's conf file, currently pseudo */
src/server/slavefuncs.h
Show inline comments
 
@@ -22,8 +22,8 @@
 
#include "blendjob.h"
 

	
 
void ssh_keygen();
 
void register_user(char *username, char *email);
 
void login_user(char *username);
 
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)