Changeset - d3ee86d58ec1
[Not reviewed]
default
0 1 0
ethanzonca@localhost.localdomain - 16 years ago 2009-07-01 12:19:40
ethanzonca@localhost.localdomain
added some registration stuff
1 file changed with 76 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include <stdio.h>
 
#include "execio.h"
 
#include "options.h"
 
#include <confuse.h>
 

	
 
#define max 100
 
 // maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory...
 
@@ -59,6 +60,73 @@ struct {
 
int main(int argc, char *argv[])
 
{
 

	
 

	
 

	
 

	
 
// We need the conf parser code from options.c here!!!
 

	
 

	
 
char *username = "unregistered";
 
int registered;
 
if(username == "unregistered") {
 
  registered = 0;
 
}
 

	
 

	
 

	
 

	
 

	
 
// Registration on server. Needs attention. (e.g., people could make tons of accounts with the key we give them...
 
if(registered==0) {
 
char newusername[100];
 

	
 
  fprintf(stderr, "Please enter your desired username: ");
 
  fgets(newusername,100,stdin);
 
  fprintf(stderr, "\nChecking availibility of username: %s\n\n",newusername);
 
  // Mostly kinda copied from old code, but I understand it a tad better now :)
 
  // Logs into sandboxed user on zserver2 and registers a user
 
  char buf[10];
 
  struct execio *testrem;
 
  char *execargv[] =
 
    {
 
  "ssh",
 
  "distren_setup@protofusion.org",
 
  "-i",
 
  "setup.rsa",
 
  "-p",
 
  "23",
 
  "sh",
 
  "-c",
 
  "sudo /usr/sbin/useradd",
 
  "-M",
 
  "-c",
 
  "email",
 
  "-d",
 
  "/home/distren",
 
  "--gid 537",
 
  newusername,
 
  (char *)NULL
 
  };
 
  size_t readlen;
 
  fprintf(stderr, "execio_open:", execio_open(&testrem, "ssh", execargv));
 
  buf[9] = '\0'; // null-terminating the array...
 
  while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff?
 
    {
 
      if(readlen > 9) {
 
	fprintf(stderr, "Something is terribly wrong!\n");
 
      }
 
    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);
 
  
 
 }
 
else{
 
  // Login with credentials
 
}
 

	
 

	
 

	
 
/*
 
 frame[frame] Assignments:
 
  "0" - cancelled
 
@@ -97,30 +165,14 @@ void queue(int type, char *name, char *s
 
jobnum++;
 
}
 

	
 
// Mostly kinda copied from old code, but I understand it a tad better now :)
 
char buf[10];
 
struct execio *testrem;
 
char *execargv[] =
 
  {
 
"ssh",
 
"ethanzonca@protofusion.org",
 
"sh",
 
"-c",
 
"\"echo hello from ${HOSTNAME}\"",
 
(char *)NULL
 
 };
 
size_t readlen;
 
fprintf(stderr, "execio_open:", execio_open(&testrem, "ssh", execargv));
 
buf[9] = '\0'; // null-terminating the array...
 
while(!execio_read(testrem, buf, 9, &readlen)) // What's with the readlen stuff?
 
  {
 
    if(readlen > 9) {
 
      fprintf(stderr, "Something is terribly wrong!\n");
 
    }
 
   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);
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
///////////////////////// SLAVE ///////////////////////////////
 

	
0 comments (0 inline, 0 general)