Changeset - 6b9ed6648d87
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-31 19:39:35

Added ssh_keygen return checks
1 file changed with 8 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -122,13 +122,17 @@ 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");
 
  }
 
  ssh_keygen(); // generates keys for login, @TODO: pub key must somehow be sent to the server.
 

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

	
 
  return 1;
 
}
 

	
 
/** Logs the user into the server with a nice ssh session */
 
int login_user(char *username)
 
@@ -204,15 +208,17 @@ void conf_replace(char *username){
 
  FILE *fp1, *fp2;
 
  size_t find_len = strlen(text2find);
 
  fp1 = fopen(fileOrig,"r");
 
  fp2 = fopen(fileRepl,"w");
 
  if (fp1 ==NULL){
 
	  fprintf(stderr, "%s doesn't exist\n",fileOrig);
 
	  return 0;
 
  }
 
  else if(fp2 ==NULL){
 
	  fprintf(stderr, "Can't write a file to disk! Check permissions.\n");
 
	  return 0;
 
  }
 
  else{
 
    while(fgets(buffer,maxlinelen+2,fp1))
 
      {
 
          buff_ptr = buffer;
 
          while ((find_ptr = strstr(buff_ptr,text2find)))
 
@@ -222,12 +228,13 @@ void conf_replace(char *username){
 
          fputs(text2repl,fp2);
 
          buff_ptr += find_len;
 
          }
 
          fputs(buff_ptr,fp2);
 
      }
 
    rename(fileRepl, fileOrig);
 
    return 1;
 
  }
 

	
 
  fclose(fp2);
 
  fclose(fp1);
 
  fprintf(stderr,"Wrote conf file...\n");
 
}
0 comments (0 inline, 0 general)