Changeset - 7511a4140204
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-30 15:37:19

conf_replace works nicely, ssh_keygen is disabled due to odd crashing without segfault.
1 file changed with 15 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -90,8 +90,8 @@ 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. */
 

	
 
  ssh_keygen(); // generates distren_rsa
 
  fprintf(stderr, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH");
 
  // ssh_keygen(); // generates distren_rsa
 

	
 
  conf_replace(username); // puts the person's username in the conf
 
  /* @TODO: Scan distrenslave.conf for !username and !key and replace them with "keyname" and the "username" */
 
  return 1;
 
@@ -172,9 +172,10 @@ void conf_replace(char *username){
 
	rename(); // rename the old file to the new file
 
*/
 

	
 
	/* Note: SYSCONFDIR doesn't include a trailing slash */
 
  int maxlinelen = 120;
 
  char *fileOrig = SYSCONFDIR "distrenslave.conf";
 
  char *fileRepl = SYSCONFDIR "distrenslave.conf.edited";
 
  char *fileOrig = SYSCONFDIR "/distrenslave.conf";
 
  char *fileRepl = SYSCONFDIR "/distrenslave.conf.edited";
 
  char *text2find = "!username";
 
  char *text2repl = username;
 
  char buffer[maxlinelen+2];
 
@@ -183,7 +184,13 @@ void conf_replace(char *username){
 
  size_t find_len = strlen(text2find);
 
  fp1 = fopen(fileOrig,"r");
 
  fp2 = fopen(fileRepl,"w");
 
  if (fp1 !=NULL || fp2 !=NULL){
 
  if (fp1 ==NULL){
 
	  fprintf(stderr, "%s doesn't exist\n",fileOrig);
 
  }
 
  else if(fp2 ==NULL){
 
	  fprintf(stderr, "Can't write a file to disk! Check permissions.\n");
 
  }
 
  else{
 
    while(fgets(buffer,maxlinelen+2,fp1))
 
      {
 
          buff_ptr = buffer;
 
@@ -196,13 +203,12 @@ void conf_replace(char *username){
 
          }
 
          fputs(buff_ptr,fp2);
 
      }
 
    rename(fileRepl, fileOrig);
 
  }
 
  else{
 
	  fprintf(stderr, "distrenslave.conf doesn't exist!");
 
  }
 

	
 
  fclose(fp2);
 
  fclose(fp1);
 
  fprintf(stderr,"conf replacements likely worked");
 
  fprintf(stderr,"Wrote conf file...\n");
 
}
 

	
 

	
0 comments (0 inline, 0 general)