Changeset - addf1a3579d8
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-08-01 14:39:06

Moved ssh_keygen() and conf_replace() before the useradd code to avoid duplicate user creation, etc.
1 file changed with 14 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -109,7 +109,20 @@ return 0;
 
/** Registers the user on the DistRen server */
 
int register_user(char *username, char *email)
 
{
 
	/* @TODO: Check for problems (e.g. existing rsa key) BEFORE useradding! */
 

	
 
/* Note: this code moved here from after the useradd code, so useradd doesn't happen if there is an existing key, etc */
 
  /* puts the person's username in the conf */
 
  if(conf_replace(username) == 0){
 
	fprintf(stderr, "Failed!\n");
 
	return 0;
 
	}
 

	
 
  /* generates keys for login, @TODO: pub key must somehow be sent to the server. */
 
  if(ssh_keygen() == 0){
 
	  fprintf(stderr, "Failed!\n");
 
	  return 0;
 
  }
 

	
 
  /*
 
   * 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 .bashrc of the skel is needed.
 
@@ -150,18 +163,6 @@ int register_user(char *username, char *
 

	
 
  /* @TODO: Parse the output buffer or something to check when user creation fails due to duplicate users. This is pretty important. */
 

	
 
  // puts the person's username in the conf
 
  if(conf_replace(username) == 0){
 
	  fprintf(stderr, "Failed!\n");
 
	  return 0;
 
  }
 

	
 
  // generates keys for login, @TODO: pub key must somehow be sent to the server.
 
  if(ssh_keygen() == 0){
 
	  fprintf(stderr, "Failed!\n");
 
	  return 0;
 
  }
 

	
 
  return 1; // 1 is success
 
}
 

	
0 comments (0 inline, 0 general)