Changeset - 94aafba083ee
[Not reviewed]
default
0 2 0
ethanzonca - 17 years ago 2009-03-15 19:38:50

Added system changelog and some user creation code
2 files changed with 26 insertions and 50 deletions:
0 comments (0 inline, 0 general)
src/client/distren.c
Show inline comments
 
@@ -27,87 +27,63 @@
 

	
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 

	
 
/* Mneh variable goodness */
 
int isusername;
 
char *host = "protofusion.org";
 
char *username = "guest";
 
char *nameemail;
 
/* */
 

	
 

	
 
	/* XML Testing, segfaults, so reverted to default. */
 
	/*
 
		xmlDocPtr doc;
 
		xmlNodePtr cur;
 

	
 
		doc = xmlParseFile(docname);
 

	
 
		if (doc == NULL ) {
 
			fprintf(stderr,"The document was not parsed correctly \n");
 
			return;
 
		}
 

	
 
		cur = xmlDocGetRootElement(doc);
 
/* put some code here to parse for a username, set username=0 if no username in the xml file or if no xml file exists. if no file, drop a warning */
 

	
 
		if (cur == NULL) {
 
			fprintf(stderr,"I cannot parse an empty document \n");
 
			xmlFreeDoc(doc);
 
			return;
 
		}
 

	
 
		if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
 
			fprintf(stderr,"The document you want me to parse is of the wrong type");
 
			xmlFreeDoc(doc);
 
			return;
 
		}
 

	
 
	*/
 

	
 

	
 
if(isusername = 0){
 

	
 
  char buf[10];
 
  struct execio *testrem;
 
  char *execargv[] =
 
    {
 
      "ssh",
 
      "protofusion.org",
 
      host,
 
      "sh",
 
      "-c",
 
      "\"echo hello from ${HOSTNAME}\"",
 
      "\"useradd -M -c",
 
      nameemail,
 
      "-d /home/distren --gid 537",
 
      username,
 
      "\"",
 
      (char *)NULL
 
    };
 

	
 
  size_t readlen;
 

	
 

	
 
  fprintf(stderr, "testing execio (It shouldn't work) :-)\n");
 
  fprintf(stderr, "execio madness is occuring!");
 
  fprintf(stderr, "execio_open returns %d\n", execio_open(&testrem, "ssh", execargv));
 

	
 
  buf[9] = '\0';
 
  while(!execio_read(testrem, buf, 9, &readlen))
 
    {
 
      if(readlen > 9)
 
	{
 
	  fprintf(stderr, "execio_read doesn't set readlen correctly or read() is messed up\n");
 
	  return 1;
 
	}
 
      buf[readlen] = '\0';
 
      fprintf(stderr, "read \"%s\"\n", buf);
 
    }
 

	
 
  return 0;
 
}
 

	
 
  return 0;
 
};
 

	
 
/* this function should probably not exist. asprintf should be used instead of sprintf */
 
size_t intstrlen(size_t theint)
 
else
 
{
 
  size_t len = 0; /* if the number is single digit, this will be incremented */
 
  do
 
    {
 
      theint /= 10;
 
      len ++;
 
    }
 
  while(theint > 0);
 

	
 
  return len;
 
/* put code here to ssh to zserver2 w/ execio as the user from the xml file */
 
}
 

	
 

	
 
};
 

	
 

	
 

	
 

	
 

	
src/common/execio.h
Show inline comments
 
@@ -43,13 +43,13 @@ struct execio
 
  pid_t child;
 
};
 

	
 
/*
 
  runs progname with the arguments in argv. argv must be null terminated!!!!!!!!!
 

	
 
  returns nonzsero return on error 
 
  returns nonzero return on error
 
*/
 
int execio_open(struct execio **rem, const char *progname, char *const argv[]);
 

	
 
/* 
 
   doesn't block, 
 
   returns 0 on success, 1 on failure
0 comments (0 inline, 0 general)