diff --git a/src/client/distren.c b/src/client/distren.c --- a/src/client/distren.c +++ b/src/client/distren.c @@ -53,6 +53,8 @@ int main(int argc, char *argv[]) }; int i; + + i = 1; if(options_init(argc, argv, &cfg, cfg_opts, "client", &options)) { @@ -61,55 +63,56 @@ int main(int argc, char *argv[]) } -// Please find a better way of doing this :( you can't strcat multiple strings.. meh -// use something like sprintf -//char *username = cfg_getstr(cfg, "username"); -//char *hostname = cfg_getstr(cfg, "hostname"); -//strcat(username, "@"); -//strcat(username, hostname); + // Please find a better way of doing this :( you can't strcat multiple strings.. meh + // use something like sprintf + //char *username = cfg_getstr(cfg, "username"); + //char *hostname = cfg_getstr(cfg, "hostname"); + //strcat(username, "@"); + //strcat(username, hostname); -if( i == 1 ){ -// Create new account on the server if no username exists -// THIS no longer SEGFAULTS!! YAY - char buf[10]; - struct execio *testrem; - char *execargv[] = - { - "ssh", - "username", //cfg_getstr(cfg, "username") . "@" . cfg_getstr(cfg, "hostname"), - "-i guest.rsa", //yeaaaah enay better ideas? - "sh", - "-c", - "\"echo hello from ${HOSTNAME}\"", // "\"useradd -M -c" strcat( cfg_getstr(cfg, "name") cfg_getstr(cfg, "email")) "-d /home/distren --gid 537" cfg_getstr(cfg, "username") "\"", - (char *)NULL - }; + if( i == 1 ){ + // Create new account on the server if no username exists + // THIS no longer SEGFAULTS!! YAY + char buf[10]; + struct execio *testrem; + char *execargv[] = + { + "ssh", + "username", //cfg_getstr(cfg, "username") . "@" . cfg_getstr(cfg, "hostname"), + "-i guest.rsa", //yeaaaah enay better ideas? + "sh", + "-c", + "\"echo hello from ${HOSTNAME}\"", // "\"useradd -M -c" strcat( cfg_getstr(cfg, "name") cfg_getstr(cfg, "email")) "-d /home/distren --gid 537" cfg_getstr(cfg, "username") "\"", + (char *)NULL + }; - size_t readlen; - 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)) + size_t readlen; + 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); + } + execio_close(testrem); + } + + else { - 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); + printf("Well now, you must have registered!\n"); + /* put code here to ssh to zserver2 w/ execio as the user from the conf file */ } -} - -else -{ - printf("Well now, you must have registered!\n"); -/* put code here to ssh to zserver2 w/ execio as the user from the conf file */ -} - options_free(options); - return 0; + options_free(options); + return 0; };