diff --git a/debugger/interface b/debugger/interface deleted file mode 100755 index 587dfef..0000000 Binary files a/debugger/interface and /dev/null differ diff --git a/debugger/interface.c b/debugger/interface.c index 61204f7..edf4f47 100644 --- a/debugger/interface.c +++ b/debugger/interface.c @@ -9,10 +9,10 @@ #include #define BUFFSIZE 8192 #define MaxPipeName 100 -#define logdir "/home/ruttan/classes/capstone/debugger/" -#define numDbgArgs 5 +#define logdir "/var/www/html/Web/debugger"#define numDbgArgs 5 #define ArgSize 30 - +#define prompt ">>>" +//#define prompt "(gdb)" pid_t child_pid; char buf[BUFFSIZE],work_file[MaxPipeName]; FILE * fdtoFILE; @@ -29,7 +29,7 @@ void catch_sigint(int sig_num) /* re-set the signal handler again to catch_int, for next time */ signal(SIGINT, catch_sigint); kill(child_pid,1); - fprintf(fdtoFILE,"got a sigint signal\n"); + fprintf(fdtoFILE,"Interface:got a sigint signal\n"); fflush(fdtoFILE); sleep(1); exit(1); @@ -80,11 +80,17 @@ pid_t launch_debugger(char * argv[],int pipefd[2]){ } void make_args(char * id,char * argv[]){ - argv[0]="/usr/bin/python3"; + + //pthon flags + argv[0]="/usr/bin/python"; argv[1]="-i"; - argv[2]="-m"; - argv[3]=work_file; - argv[4]=0; + argv[2]=0; //"-m"; + argv[3]=0; //work_file;argv[4]=0; + /* + //gdb flags + argv[0]="/usr/bin/gdb"; + argv[1]=0; + */ } int main (int argc, char ** argv) { @@ -105,6 +111,7 @@ int main (int argc, char ** argv) { perror("usage: debugger idcode"); exit(1); } + //create input pipe from webserver sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); unlink(fromServer); @@ -137,18 +144,27 @@ int main (int argc, char ** argv) { int i; char c; + int sid; + sid=setsid(); + if (sid < 0){ + fprintf(fdtoFILE,"failed to change sid\n"); + fflush(fdtoFILE); + } make_args(argv[1],nargv); child_pid=launch_debugger(nargv,pipefd); + fprintf(fdtoFILE,"session id=%d\n",sid); + fflush(fdtoFILE); fprintf(fdtoFILE,"child_pid=%d\n",child_pid); fflush(fdtoFILE); setpgid(0, 0); + fprintf(fdtoFILE,"---starting---\n"); fflush(fdtoFILE); while(1){ line[0]=0; - while (!strstr(line,">>>") && !strstr(line,"...")){ + while (!strstr(line,prompt) && !strstr(line,"...")){ if ((n=read(pipefd[0],line,BUFFSIZE))){ if (!n) { fprintf(fdtoFILE,"pipe fd[0] closed"); @@ -159,7 +175,7 @@ int main (int argc, char ** argv) { line[n]=0; //if n=BUFFSIZE... } - fprintf(fdtoFILE,"p-%s",line); + fprintf(fdtoFILE,"; p->%s",line); fflush(fdtoFILE); if (write(fdtoWeb,line,n) != n) { perror("fdtoWeb write error"); diff --git a/debugger/interface.c.BACKUP.772.c b/debugger/interface.c.BACKUP.772.c new file mode 100644 index 0000000..cdb9df7 --- /dev/null +++ b/debugger/interface.c.BACKUP.772.c @@ -0,0 +1,228 @@ +#include +#include /* for mkfifo */ +#include /* for open */ +#include /* for open */ +#include /* for open */ +#include /* for write */ +#include +#include +#include +#define BUFFSIZE 8192 +#define MaxPipeName 100 +<<<<<<< HEAD +#define logdir "/var/www/html/Web/debugger/" +======= +#define logdir "log/" +>>>>>>> master +#define numDbgArgs 5 +#define ArgSize 30 +#define prompt ">>>" +//#define prompt "(gdb)" +pid_t child_pid; +char buf[BUFFSIZE],work_file[MaxPipeName]; +FILE * fdtoFILE; + +void catch_sigpipe(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGPIPE, catch_sigpipe); + fprintf(fdtoFILE,"got a signal\n"); + fflush(fdtoFILE); +} +void catch_sigint(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGINT, catch_sigint); + kill(child_pid,1); + fprintf(fdtoFILE,"Interface:got a sigint signal\n"); + fflush(fdtoFILE); + sleep(1); + exit(1); +} + +pid_t launch_debugger(char * argv[],int pipefd[2]){ + int stdio[3]; + pid_t child_pid; + int pipefd0[2],pipefd1[2]; + pipe(pipefd0); + if(pipe(pipefd0) == -1) { + perror("Pipe 0 creation failed"); + exit(1); + } + pipe(pipefd1); + if(pipe(pipefd1) == -1) { + perror("Pipe 1 creation failed"); + exit(1); + } + //create function to setup pipes fork and exec + pipefd[0]=pipefd0[0]; + pipefd[1]=pipefd1[1]; + stdio[0]=dup(STDIN_FILENO); + stdio[1]=dup(STDOUT_FILENO); + stdio[2]=dup(STDERR_FILENO); + dup2(pipefd1[0],STDIN_FILENO); + dup2(pipefd0[1],STDOUT_FILENO); + dup2(pipefd0[1],STDERR_FILENO); + switch (child_pid=fork()){ + case -1: + perror("Could not fork debugger"); + exit(1); + break; + case 0: + if (execvp(argv[0],argv)==-1){ + perror("exec failed"); + exit(1); + } + default: + //after fork in parent. + dup2(stdio[0],STDIN_FILENO); + dup2(stdio[1],STDOUT_FILENO); + dup2(stdio[2],STDERR_FILENO); + close(pipefd1[0]); + close(pipefd0[1]); + } + return(child_pid); +} + +void make_args(char * id,char * argv[]){ + + //pthon flags + argv[0]="/usr/bin/python"; + argv[1]="-i"; + argv[2]=0; //"-m"; + argv[3]=0; //work_file;argv[4]=0; + /* + //gdb flags + argv[0]="/usr/bin/gdb"; + argv[1]=0; + */ +} + +int main (int argc, char ** argv) { + int n; + char * nargv[numDbgArgs]; + int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; + char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; + sprintf(buf,"%s%s%s",logdir,"LOG",argv[1]); + unlink(buf); + fdtoFILE=fopen(buf,"w"); + fprintf(fdtoFILE,"testing file output\n"); + sprintf(work_file,"%s%s%s",logdir,"FILE",argv[1]); + unlink(work_file); + + signal(SIGPIPE, catch_sigpipe); + signal(SIGINT, catch_sigint); + if ((argc < 2 )|| (argc >=3)){ + perror("usage: debugger idcode"); + exit(1); + } + + //create input pipe from webserver + sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); + unlink(fromServer); + + if (-1 == mkfifo(fromServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + + //create output pipe to webserver + sprintf(toServer,"%s%s%s",logdir,"IN",argv[1]); + unlink(toServer); + + if (-1 == mkfifo(toServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + //create pipes to debugger + + if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK) + perror("Pipe 1 creation failed"); + exit(1); + } + + int i; + char c; + int sid; + sid=setsid(); + if (sid < 0){ + fprintf(fdtoFILE,"failed to change sid\n"); + fflush(fdtoFILE); + } + make_args(argv[1],nargv); + child_pid=launch_debugger(nargv,pipefd); + fprintf(fdtoFILE,"session id=%d\n",sid); + fflush(fdtoFILE); + fprintf(fdtoFILE,"child_pid=%d\n",child_pid); + fflush(fdtoFILE); + + fprintf(fdtoFILE,"---starting---\n"); + fflush(fdtoFILE); + + + while(1){ + line[0]=0; + while (!strstr(line,prompt) && !strstr(line,"...")){ + if ((n=read(pipefd[0],line,BUFFSIZE))){ + if (!n) { + fprintf(fdtoFILE,"pipe fd[0] closed"); + fflush(fdtoFILE); + exit(1); + } + //line[n++]='@'; + line[n]=0; + //if n=BUFFSIZE... + } + fprintf(fdtoFILE,"; p->%s",line); + fflush(fdtoFILE); + if (write(fdtoWeb,line,n) != n) { + perror("fdtoWeb write error"); + fprintf(fdtoFILE,"fdtoWeb write error\n"); + fflush(fdtoFILE); + + } + + } + + if ((n=read(fdfrmWeb,line,BUFFSIZE))){ + line[n]=0; + fprintf(fdtoFILE,"%d-%s%s",n,"w-",line); + fflush(fdtoFILE); + if (write(pipefd[1],line,n) != n) { + perror("pipefd[1] write error"); + } + + } + else{ + printf("empty read\n"); + close(fdtoWeb); + close(fdfrmWeb); + n=0; + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + line[0]='\n'; + if (write(pipefd[1],line,1) != 1) { + perror("pipefd[1] write error"); + } + + } + + } + + exit(0); +} + + diff --git a/debugger/interface.c.BASE.772.c b/debugger/interface.c.BASE.772.c new file mode 100644 index 0000000..61204f7 --- /dev/null +++ b/debugger/interface.c.BASE.772.c @@ -0,0 +1,208 @@ +#include +#include /* for mkfifo */ +#include /* for open */ +#include /* for open */ +#include /* for open */ +#include /* for write */ +#include +#include +#include +#define BUFFSIZE 8192 +#define MaxPipeName 100 +#define logdir "/home/ruttan/classes/capstone/debugger/" +#define numDbgArgs 5 +#define ArgSize 30 + +pid_t child_pid; +char buf[BUFFSIZE],work_file[MaxPipeName]; +FILE * fdtoFILE; + +void catch_sigpipe(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGPIPE, catch_sigpipe); + fprintf(fdtoFILE,"got a signal\n"); + fflush(fdtoFILE); +} +void catch_sigint(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGINT, catch_sigint); + kill(child_pid,1); + fprintf(fdtoFILE,"got a sigint signal\n"); + fflush(fdtoFILE); + sleep(1); + exit(1); +} + +pid_t launch_debugger(char * argv[],int pipefd[2]){ + int stdio[3]; + pid_t child_pid; + int pipefd0[2],pipefd1[2]; + pipe(pipefd0); + if(pipe(pipefd0) == -1) { + perror("Pipe 0 creation failed"); + exit(1); + } + pipe(pipefd1); + if(pipe(pipefd1) == -1) { + perror("Pipe 1 creation failed"); + exit(1); + } + //create function to setup pipes fork and exec + pipefd[0]=pipefd0[0]; + pipefd[1]=pipefd1[1]; + stdio[0]=dup(STDIN_FILENO); + stdio[1]=dup(STDOUT_FILENO); + stdio[2]=dup(STDERR_FILENO); + dup2(pipefd1[0],STDIN_FILENO); + dup2(pipefd0[1],STDOUT_FILENO); + dup2(pipefd0[1],STDERR_FILENO); + switch (child_pid=fork()){ + case -1: + perror("Could not fork debugger"); + exit(1); + break; + case 0: + if (execvp(argv[0],argv)==-1){ + perror("exec failed"); + exit(1); + } + default: + //after fork in parent. + dup2(stdio[0],STDIN_FILENO); + dup2(stdio[1],STDOUT_FILENO); + dup2(stdio[2],STDERR_FILENO); + close(pipefd1[0]); + close(pipefd0[1]); + } + return(child_pid); +} + +void make_args(char * id,char * argv[]){ + argv[0]="/usr/bin/python3"; + argv[1]="-i"; + argv[2]="-m"; + argv[3]=work_file; + argv[4]=0; +} + +int main (int argc, char ** argv) { + int n; + char * nargv[numDbgArgs]; + int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; + char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; + sprintf(buf,"%s%s%s",logdir,"LOG",argv[1]); + unlink(buf); + fdtoFILE=fopen(buf,"w"); + fprintf(fdtoFILE,"testing file output\n"); + sprintf(work_file,"%s%s%s",logdir,"FILE",argv[1]); + unlink(work_file); + + signal(SIGPIPE, catch_sigpipe); + signal(SIGINT, catch_sigint); + if ((argc < 2 )|| (argc >=3)){ + perror("usage: debugger idcode"); + exit(1); + } + //create input pipe from webserver + sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); + unlink(fromServer); + + if (-1 == mkfifo(fromServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + + //create output pipe to webserver + sprintf(toServer,"%s%s%s",logdir,"IN",argv[1]); + unlink(toServer); + + if (-1 == mkfifo(toServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + //create pipes to debugger + + if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK) + perror("Pipe 1 creation failed"); + exit(1); + } + + int i; + char c; + make_args(argv[1],nargv); + child_pid=launch_debugger(nargv,pipefd); + fprintf(fdtoFILE,"child_pid=%d\n",child_pid); + fflush(fdtoFILE); + setpgid(0, 0); + fprintf(fdtoFILE,"---starting---\n"); + fflush(fdtoFILE); + + + while(1){ + line[0]=0; + while (!strstr(line,">>>") && !strstr(line,"...")){ + if ((n=read(pipefd[0],line,BUFFSIZE))){ + if (!n) { + fprintf(fdtoFILE,"pipe fd[0] closed"); + fflush(fdtoFILE); + exit(1); + } + //line[n++]='@'; + line[n]=0; + //if n=BUFFSIZE... + } + fprintf(fdtoFILE,"p-%s",line); + fflush(fdtoFILE); + if (write(fdtoWeb,line,n) != n) { + perror("fdtoWeb write error"); + fprintf(fdtoFILE,"fdtoWeb write error\n"); + fflush(fdtoFILE); + + } + + } + + if ((n=read(fdfrmWeb,line,BUFFSIZE))){ + line[n]=0; + fprintf(fdtoFILE,"%d-%s%s",n,"w-",line); + fflush(fdtoFILE); + if (write(pipefd[1],line,n) != n) { + perror("pipefd[1] write error"); + } + + } + else{ + printf("empty read\n"); + close(fdtoWeb); + close(fdfrmWeb); + n=0; + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + line[0]='\n'; + if (write(pipefd[1],line,1) != 1) { + perror("pipefd[1] write error"); + } + + } + + } + + exit(0); +} + + diff --git a/debugger/interface.c.LOCAL.772.c b/debugger/interface.c.LOCAL.772.c new file mode 100644 index 0000000..7cf3553 --- /dev/null +++ b/debugger/interface.c.LOCAL.772.c @@ -0,0 +1,224 @@ +#include +#include /* for mkfifo */ +#include /* for open */ +#include /* for open */ +#include /* for open */ +#include /* for write */ +#include +#include +#include +#define BUFFSIZE 8192 +#define MaxPipeName 100 +#define logdir "/var/www/html/Web/debugger/" +#define numDbgArgs 5 +#define ArgSize 30 +#define prompt ">>>" +//#define prompt "(gdb)" +pid_t child_pid; +char buf[BUFFSIZE],work_file[MaxPipeName]; +FILE * fdtoFILE; + +void catch_sigpipe(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGPIPE, catch_sigpipe); + fprintf(fdtoFILE,"got a signal\n"); + fflush(fdtoFILE); +} +void catch_sigint(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGINT, catch_sigint); + kill(child_pid,1); + fprintf(fdtoFILE,"Interface:got a sigint signal\n"); + fflush(fdtoFILE); + sleep(1); + exit(1); +} + +pid_t launch_debugger(char * argv[],int pipefd[2]){ + int stdio[3]; + pid_t child_pid; + int pipefd0[2],pipefd1[2]; + pipe(pipefd0); + if(pipe(pipefd0) == -1) { + perror("Pipe 0 creation failed"); + exit(1); + } + pipe(pipefd1); + if(pipe(pipefd1) == -1) { + perror("Pipe 1 creation failed"); + exit(1); + } + //create function to setup pipes fork and exec + pipefd[0]=pipefd0[0]; + pipefd[1]=pipefd1[1]; + stdio[0]=dup(STDIN_FILENO); + stdio[1]=dup(STDOUT_FILENO); + stdio[2]=dup(STDERR_FILENO); + dup2(pipefd1[0],STDIN_FILENO); + dup2(pipefd0[1],STDOUT_FILENO); + dup2(pipefd0[1],STDERR_FILENO); + switch (child_pid=fork()){ + case -1: + perror("Could not fork debugger"); + exit(1); + break; + case 0: + if (execvp(argv[0],argv)==-1){ + perror("exec failed"); + exit(1); + } + default: + //after fork in parent. + dup2(stdio[0],STDIN_FILENO); + dup2(stdio[1],STDOUT_FILENO); + dup2(stdio[2],STDERR_FILENO); + close(pipefd1[0]); + close(pipefd0[1]); + } + return(child_pid); +} + +void make_args(char * id,char * argv[]){ + + //pthon flags + argv[0]="/usr/bin/python"; + argv[1]="-i"; + argv[2]=0; //"-m"; + argv[3]=0; //work_file;argv[4]=0; + /* + //gdb flags + argv[0]="/usr/bin/gdb"; + argv[1]=0; + */ +} + +int main (int argc, char ** argv) { + int n; + char * nargv[numDbgArgs]; + int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; + char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; + sprintf(buf,"%s%s%s",logdir,"LOG",argv[1]); + unlink(buf); + fdtoFILE=fopen(buf,"w"); + fprintf(fdtoFILE,"testing file output\n"); + sprintf(work_file,"%s%s%s",logdir,"FILE",argv[1]); + unlink(work_file); + + signal(SIGPIPE, catch_sigpipe); + signal(SIGINT, catch_sigint); + if ((argc < 2 )|| (argc >=3)){ + perror("usage: debugger idcode"); + exit(1); + } + + //create input pipe from webserver + sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); + unlink(fromServer); + + if (-1 == mkfifo(fromServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + + //create output pipe to webserver + sprintf(toServer,"%s%s%s",logdir,"IN",argv[1]); + unlink(toServer); + + if (-1 == mkfifo(toServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + //create pipes to debugger + + if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK) + perror("Pipe 1 creation failed"); + exit(1); + } + + int i; + char c; + int sid; + sid=setsid(); + if (sid < 0){ + fprintf(fdtoFILE,"failed to change sid\n"); + fflush(fdtoFILE); + } + make_args(argv[1],nargv); + child_pid=launch_debugger(nargv,pipefd); + fprintf(fdtoFILE,"session id=%d\n",sid); + fflush(fdtoFILE); + fprintf(fdtoFILE,"child_pid=%d\n",child_pid); + fflush(fdtoFILE); + + fprintf(fdtoFILE,"---starting---\n"); + fflush(fdtoFILE); + + + while(1){ + line[0]=0; + while (!strstr(line,prompt) && !strstr(line,"...")){ + if ((n=read(pipefd[0],line,BUFFSIZE))){ + if (!n) { + fprintf(fdtoFILE,"pipe fd[0] closed"); + fflush(fdtoFILE); + exit(1); + } + //line[n++]='@'; + line[n]=0; + //if n=BUFFSIZE... + } + fprintf(fdtoFILE,"; p->%s",line); + fflush(fdtoFILE); + if (write(fdtoWeb,line,n) != n) { + perror("fdtoWeb write error"); + fprintf(fdtoFILE,"fdtoWeb write error\n"); + fflush(fdtoFILE); + + } + + } + + if ((n=read(fdfrmWeb,line,BUFFSIZE))){ + line[n]=0; + fprintf(fdtoFILE,"%d-%s%s",n,"w-",line); + fflush(fdtoFILE); + if (write(pipefd[1],line,n) != n) { + perror("pipefd[1] write error"); + } + + } + else{ + printf("empty read\n"); + close(fdtoWeb); + close(fdfrmWeb); + n=0; + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + line[0]='\n'; + if (write(pipefd[1],line,1) != 1) { + perror("pipefd[1] write error"); + } + + } + + } + + exit(0); +} + + diff --git a/debugger/interface.c.REMOTE.772.c b/debugger/interface.c.REMOTE.772.c new file mode 100644 index 0000000..cab0946 --- /dev/null +++ b/debugger/interface.c.REMOTE.772.c @@ -0,0 +1,208 @@ +#include +#include /* for mkfifo */ +#include /* for open */ +#include /* for open */ +#include /* for open */ +#include /* for write */ +#include +#include +#include +#define BUFFSIZE 8192 +#define MaxPipeName 100 +#define logdir "log/" +#define numDbgArgs 5 +#define ArgSize 30 + +pid_t child_pid; +char buf[BUFFSIZE],work_file[MaxPipeName]; +FILE * fdtoFILE; + +void catch_sigpipe(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGPIPE, catch_sigpipe); + fprintf(fdtoFILE,"got a signal\n"); + fflush(fdtoFILE); +} +void catch_sigint(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGINT, catch_sigint); + kill(child_pid,1); + fprintf(fdtoFILE,"got a sigint signal\n"); + fflush(fdtoFILE); + sleep(1); + exit(1); +} + +pid_t launch_debugger(char * argv[],int pipefd[2]){ + int stdio[3]; + pid_t child_pid; + int pipefd0[2],pipefd1[2]; + pipe(pipefd0); + if(pipe(pipefd0) == -1) { + perror("Pipe 0 creation failed"); + exit(1); + } + pipe(pipefd1); + if(pipe(pipefd1) == -1) { + perror("Pipe 1 creation failed"); + exit(1); + } + //create function to setup pipes fork and exec + pipefd[0]=pipefd0[0]; + pipefd[1]=pipefd1[1]; + stdio[0]=dup(STDIN_FILENO); + stdio[1]=dup(STDOUT_FILENO); + stdio[2]=dup(STDERR_FILENO); + dup2(pipefd1[0],STDIN_FILENO); + dup2(pipefd0[1],STDOUT_FILENO); + dup2(pipefd0[1],STDERR_FILENO); + switch (child_pid=fork()){ + case -1: + perror("Could not fork debugger"); + exit(1); + break; + case 0: + if (execvp(argv[0],argv)==-1){ + perror("exec failed"); + exit(1); + } + default: + //after fork in parent. + dup2(stdio[0],STDIN_FILENO); + dup2(stdio[1],STDOUT_FILENO); + dup2(stdio[2],STDERR_FILENO); + close(pipefd1[0]); + close(pipefd0[1]); + } + return(child_pid); +} + +void make_args(char * id,char * argv[]){ + argv[0]="/usr/bin/python3"; + argv[1]="-i"; + argv[2]="-m"; + argv[3]=work_file; + argv[4]=0; +} + +int main (int argc, char ** argv) { + int n; + char * nargv[numDbgArgs]; + int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; + char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; + sprintf(buf,"%s%s%s",logdir,"LOG",argv[1]); + unlink(buf); + fdtoFILE=fopen(buf,"w"); + fprintf(fdtoFILE,"testing file output\n"); + sprintf(work_file,"%s%s%s",logdir,"FILE",argv[1]); + unlink(work_file); + + signal(SIGPIPE, catch_sigpipe); + signal(SIGINT, catch_sigint); + if ((argc < 2 )|| (argc >=3)){ + perror("usage: debugger idcode"); + exit(1); + } + //create input pipe from webserver + sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); + unlink(fromServer); + + if (-1 == mkfifo(fromServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + + //create output pipe to webserver + sprintf(toServer,"%s%s%s",logdir,"IN",argv[1]); + unlink(toServer); + + if (-1 == mkfifo(toServer,S_IRWXU)) { + perror("Error, could not make fifo\n"); + } + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + //create pipes to debugger + + if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK) + perror("Pipe 1 creation failed"); + exit(1); + } + + int i; + char c; + make_args(argv[1],nargv); + child_pid=launch_debugger(nargv,pipefd); + fprintf(fdtoFILE,"child_pid=%d\n",child_pid); + fflush(fdtoFILE); + setpgid(0, 0); + fprintf(fdtoFILE,"---starting---\n"); + fflush(fdtoFILE); + + + while(1){ + line[0]=0; + while (!strstr(line,">>>") && !strstr(line,"...")){ + if ((n=read(pipefd[0],line,BUFFSIZE))){ + if (!n) { + fprintf(fdtoFILE,"pipe fd[0] closed"); + fflush(fdtoFILE); + exit(1); + } + //line[n++]='@'; + line[n]=0; + //if n=BUFFSIZE... + } + fprintf(fdtoFILE,"p-%s",line); + fflush(fdtoFILE); + if (write(fdtoWeb,line,n) != n) { + perror("fdtoWeb write error"); + fprintf(fdtoFILE,"fdtoWeb write error\n"); + fflush(fdtoFILE); + + } + + } + + if ((n=read(fdfrmWeb,line,BUFFSIZE))){ + line[n]=0; + fprintf(fdtoFILE,"%d-%s%s",n,"w-",line); + fflush(fdtoFILE); + if (write(pipefd[1],line,n) != n) { + perror("pipefd[1] write error"); + } + + } + else{ + printf("empty read\n"); + close(fdtoWeb); + close(fdfrmWeb); + n=0; + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + line[0]='\n'; + if (write(pipefd[1],line,1) != 1) { + perror("pipefd[1] write error"); + } + + } + + } + + exit(0); +} + + diff --git a/debugger/makefile b/debugger/makefile new file mode 100644 index 0000000..e0dc591 --- /dev/null +++ b/debugger/makefile @@ -0,0 +1,14 @@ +CC=gcc +OBJS=interface webserver2 pipetest + +all: $(OBJS) + +%: %.o + $(CC) $< -o $@ + +%.o: %.c + $(CC) -g $< -o % + +clean: + @rm -rf $(OBJS) + @rm -rf *.dSYM diff --git a/debugger/pipetest b/debugger/pipetest deleted file mode 100755 index 6850630..0000000 Binary files a/debugger/pipetest and /dev/null differ diff --git a/debugger/pipetest.c b/debugger/pipetest.c index e5ad7ec..7c1e2ac 100644 --- a/debugger/pipetest.c +++ b/debugger/pipetest.c @@ -10,7 +10,7 @@ #include #define BUFFSIZE 8192 #define MaxPipeName 50 -#define logdir "/tmp/debugger/" +#define logdir "log" #define numDbgArgs 5 #define ArgSize 30 @@ -28,163 +28,163 @@ void catch_sigpipe(int sig_num) } pid_t launch_debugger(char * argv[],int pipefd[2]){ - int stdio[3]; - pid_t child_pid; - int pipefd0[2],pipefd1[2]; - pipe(pipefd0); - if(pipe(pipefd0) == -1) { + int stdio[3]; + pid_t child_pid; + int pipefd0[2],pipefd1[2]; + pipe(pipefd0); + if(pipe(pipefd0) == -1) { perror("Pipe 0 creation failed"); exit(1); } - pipe(pipefd1); - if(pipe(pipefd1) == -1) { + pipe(pipefd1); + if(pipe(pipefd1) == -1) { perror("Pipe 1 creation failed"); exit(1); - } - //create function to setup pipes fork and exec - pipefd[0]=pipefd0[0]; - pipefd[1]=pipefd1[1]; - stdio[0]=dup(STDIN_FILENO); - stdio[1]=dup(STDOUT_FILENO); - stdio[2]=dup(STDERR_FILENO); - dup2(pipefd1[0],STDIN_FILENO); - dup2(pipefd0[1],STDOUT_FILENO); - dup2(pipefd0[1],STDERR_FILENO); - switch (child_pid=fork()){ - case -1: - perror("Could not fork debugger"); - exit(1); - break; - case 0: - if (execvp(argv[0],argv)==-1){ - perror("exec failed"); - exit(1); } - default: - //after fork in parent. - dup2(stdio[0],STDIN_FILENO); - dup2(stdio[1],STDOUT_FILENO); - dup2(stdio[2],STDERR_FILENO); - close(pipefd1[0]); - close(pipefd0[1]); - } - return(child_pid); + //create function to setup pipes fork and exec + pipefd[0]=pipefd0[0]; + pipefd[1]=pipefd1[1]; + stdio[0]=dup(STDIN_FILENO); + stdio[1]=dup(STDOUT_FILENO); + stdio[2]=dup(STDERR_FILENO); + dup2(pipefd1[0],STDIN_FILENO); + dup2(pipefd0[1],STDOUT_FILENO); + dup2(pipefd0[1],STDERR_FILENO); + switch (child_pid=fork()){ + case -1: + perror("Could not fork debugger"); + exit(1); + break; + case 0: + if (execvp(argv[0],argv)==-1){ + perror("exec failed"); + exit(1); + } + default: + //after fork in parent. + dup2(stdio[0],STDIN_FILENO); + dup2(stdio[1],STDOUT_FILENO); + dup2(stdio[2],STDERR_FILENO); + close(pipefd1[0]); + close(pipefd0[1]); + } + return(child_pid); } void make_args(char * id,char * argv[]){ - argv[0]="/usr/local/bin/python3"; - argv[1]="-m"; - argv[2]="pdb"; - argv[3]="/home/ruttan/Desktop/myfile.py"; - argv[4]=0; + argv[0]="/usr/local/bin/python3"; + argv[1]="-m"; + argv[2]="pdb"; + argv[3]="/home/ruttan/Desktop/myfile.py"; + argv[4]=0; } int main (int argc, char ** argv) { - int n; - char * nargv[numDbgArgs]; - int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; - char buf[BUFFSIZE],line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; - + int n; + char * nargv[numDbgArgs]; + int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; + char buf[BUFFSIZE],line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; + signal(SIGPIPE, catch_sigpipe); if ((argc < 2 )|| (argc >=3)){ - perror("usage: debugger idcode"); - exit(1); + perror("usage: debugger idcode"); + exit(1); } /* //create input pipe from webserver sprintf(fromServer,"%s%s%s",logdir,argv[1],"OUT"); unlink(fromServer); - + if (-1 == mkfifo(fromServer,S_IRWXU)) { - perror("Error, could not make fifo\n"); + perror("Error, could not make fifo\n"); } //create output pipe to webserver sprintf(toServer,"%s%s%s",logdir,argv[1],"IN"); unlink(toServer); - + if (-1 == mkfifo(toServer,S_IRWXU)) { - perror("Error, could not make fifo\n"); + perror("Error, could not make fifo\n"); } if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { - perror("cannot open fifo from server"); - exit(1); + perror("cannot open fifo from server"); + exit(1); } if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { - perror("cannot open fifo to server"); - exit(1); + perror("cannot open fifo to server"); + exit(1); } //create pipes to debugger - + if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK) - perror("Pipe 1 creation failed"); - exit(1); + perror("Pipe 1 creation failed"); + exit(1); } - - */ + +*/ int i; char c;make_args(argv[1],nargv); - child_pid=launch_debugger(nargv,pipefd); - printf("child_pid=%d\n",child_pid); - fflush(stdout); + child_pid=launch_debugger(nargv,pipefd); + printf("child_pid=%d\n",child_pid); + fflush(stdout); + - // while(1){ - /* - if ((n=read(fdfrmWeb,line,BUFFSIZE))){ - line[n]=0; - n=sprintf(buf,"%d-%s%s",n,"debugger:",line); - if (write(1,buf,n) != n) { - printf("cp: write error on file stdout\n"); - fflush(stdout); - exit(1); - } - if (write(fdtoWeb,buf,n) != n) { - perror("fdtoWeb write error"); - } - - } - else{ - printf("empty read\n"); - close(fdtoWeb); - close(fdfrmWeb); - n=0; - if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { - perror("cannot open fifo from server"); - exit(1); - } - if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { - perror("cannot open fifo to server"); - exit(1); - } - } - */ + /* + if ((n=read(fdfrmWeb,line,BUFFSIZE))){ + line[n]=0; + n=sprintf(buf,"%d-%s%s",n,"debugger:",line); + if (write(1,buf,n) != n) { + printf("cp: write error on file stdout\n"); + fflush(stdout); + exit(1); + } + if (write(fdtoWeb,buf,n) != n) { + perror("fdtoWeb write error"); + } + + } + else{ + printf("empty read\n"); + close(fdtoWeb); + close(fdfrmWeb); + n=0; + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); + exit(1); + } + } + */ printf("starting\n"); fflush(stdout); while (1){ - line[0]=0; - while (!strstr(line,"(Pdb)")){ - if ((n=read(pipefd[0],line,BUFFSIZE))>0){ - line[n]=0; - printf("%s",line); - } - else break; - } - if (n <= 0){ - printf("debugger read error:%d\n",errno); - printf("n=%d\n",n); - fflush(stdout); - exit(1); - } - i=0; - while ((c=getchar())!='\n'){ - line[i++]=c; - } - line[i]=c; - write(pipefd[1],line,i+1); + line[0]=0; + while (!strstr(line,"(Pdb)")){ + if ((n=read(pipefd[0],line,BUFFSIZE))>0){ + line[n]=0; + printf("%s",line); + } + else break; + } + if (n <= 0){ + printf("debugger read error:%d\n",errno); + printf("n=%d\n",n); + fflush(stdout); + exit(1); + } + i=0; + while ((c=getchar())!='\n'){ + line[i++]=c; + } + line[i]=c; + write(pipefd[1],line,i+1); } -exit(0); + exit(0); } diff --git a/debugger/webserver2 b/debugger/webserver2 deleted file mode 100755 index 99e17a9..0000000 Binary files a/debugger/webserver2 and /dev/null differ diff --git a/debugger/webserver2.c b/debugger/webserver2.c index d8d648f..613beb1 100644 --- a/debugger/webserver2.c +++ b/debugger/webserver2.c @@ -10,8 +10,13 @@ #include #define BUFFSIZE 8192 #define MaxPipeName 100 -#define logdir "/home/ruttan/classes/capstone/debugger/" +<<<<<<< HEAD +#define logdir "/var/www/html/Web/debugger/" #define interface "interface" +======= +#define logdir "log/" +#define interface "./interface" +>>>>>>> master #define numDbgArgs 5 pid_t child_pid; @@ -26,34 +31,34 @@ void catch_sigint(int sig_num) } void make_args(char * id,char * argv[]){ - char *prog; - prog=(char *)malloc(MaxPipeName); - sprintf(prog,"%s%s",logdir,interface); - argv[0]=prog; - argv[1]=id; - argv[2]=0; + char *prog = interface; + /*prog=(char *)malloc(MaxPipeName);*/ + /*sprintf(prog,"%s%s",logdir,interface);*/ + argv[0]=prog; + argv[1]=id; + argv[2]=0; } pid_t launch_interface(char * argv[]){ - int stdio[3]; - pid_t child_pidt; - usleep(10000); - switch (child_pidt=fork()){ - case -1: - perror("Could not fork debugger"); - exit(1); - break; - case 0: - if (execvp(argv[0],argv)==-1){ - perror("exec failed"); - printf("exec =%s",argv[0]); - fflush(stdout); - exit(1); + int stdio[3]; + pid_t child_pidt; + usleep(10000); + switch (child_pidt=fork()){ + case -1: + perror("Could not fork debugger"); + exit(1); + break; + case 0: + if (execvp(argv[0],argv)==-1){ + perror("exec failed"); + printf("exec =%s",argv[0]); + fflush(stdout); + exit(1); + } + //after fork in parent } - //after fork in parent - } - free(argv[0]); - return(child_pidt); + /*free(argv[0]);*/ + return(child_pidt); } main (int argc,char** argv ) { @@ -66,8 +71,8 @@ main (int argc,char** argv ) { struct stat stat_bufO, stat_bufI; char buf[BUFFSIZE],toDebugger[MaxPipeName],fromDebugger[MaxPipeName]; if ((argc < 2 )|| (argc >=3)){ - perror("usage: webserver idcode"); - exit(1); + perror("usage: webserver idcode"); + exit(1); } signal(SIGINT, catch_sigint); sprintf(toDebugger,"%s%s%s",logdir,"OUT",argv[1]); @@ -78,57 +83,58 @@ main (int argc,char** argv ) { errnoI=errno; if ((fileCheckO == -1) && (fileCheckI == -1)) { - if ((errnoO==2) && (errnoI==2)){ - printf("NEITHER files exists\n"); - fflush(stdout); - make_args(argv[1],nargv); - child_pid=launch_interface(nargv); - usleep(10000); - } - else{ - printf("errnoI=%s\n",strerror(errnoI)); - printf("errnoO=%s\n",strerror(errnoO)); - fflush(stdout); - exit(0); - } + if ((errnoO==2) && (errnoI==2)){ + printf("NEITHER files exists\n"); + fflush(stdout); + make_args(argv[1],nargv); + child_pid=launch_interface(nargv); + usleep(10000); + } + else{ + printf("errnoI=%s\n",strerror(errnoI)); + printf("errnoO=%s\n",strerror(errnoO)); + fflush(stdout); + exit(0); + } } else { - if ((errnoO == 0) && (errnoI == 0) && - S_ISFIFO(stat_bufO.st_mode) && S_ISFIFO(stat_bufI.st_mode)){ - printf("both files are FIFOs\n"); - fflush(stdout); - } - else{ - printf("files exist in impossible state--correcting\n"); - if (!fileCheckO) unlink(toDebugger); - if (!fileCheckI) unlink(fromDebugger); - fflush(stdout); - make_args(argv[1],nargv); - child_pid=launch_interface(nargv); - usleep(10000); - } + if ((errnoO == 0) && (errnoI == 0) && + S_ISFIFO(stat_bufO.st_mode) && S_ISFIFO(stat_bufI.st_mode)){ + printf("both files are FIFOs\n"); + fflush(stdout); + } + else{ + printf("files exist in impossible state--correcting\n"); + if (!fileCheckO) unlink(toDebugger); + if (!fileCheckI) unlink(fromDebugger); + fflush(stdout); + make_args(argv[1],nargv); + child_pid=launch_interface(nargv); + usleep(10000); + } } - - - //create output pipe to webserver + + + //create output pipe to webserver if ((fdtoDbg = open(toDebugger,O_WRONLY)) == -1) { - perror("cannot open fifo to debugger"); - exit(1); + perror("cannot open fifo to debugger"); + exit(1); } - //create input pipe from webserver - if ((fdfrmDbg = open(fromDebugger,O_RDONLY)) == -1) { - perror("cannot open fifo from debugger"); - exit(1); + //create input pipe from webserver + if ((fdfrmDbg = open(fromDebugger,O_RDONLY)) == -1) { + perror("cannot open fifo from debugger"); + exit(1); } - + while(1) { +<<<<<<< HEAD line[0]=0; while (!strstr(line,">>>")&& !strstr(line,"...") ){ if ((n=read(fdfrmDbg,line,BUFFSIZE))){ line[n]=0; - printf("%d-web:%s",n,line); + printf(":%d-web:%s",n,line); fflush(stdout); } else{ @@ -140,6 +146,8 @@ main (int argc,char** argv ) { i=0; while ((c=getchar())!='\n'){ line[i++]=c; + if (c == '#') + exit(0); } line[i]=c; if (strstr(line,"#123")){ @@ -148,15 +156,32 @@ main (int argc,char** argv ) { break; } write(fdtoDbg,line,i+1); +======= + line[0]=0; + while (!strstr(line,">>>")&& !strstr(line,"...") ){ + if ((n=read(fdfrmDbg,line,BUFFSIZE))){ + line[n]=0; + printf("%d-web:%s",n,line); + fflush(stdout); + } + else{ + printf("null read on fdfrmDbg\n"); + fflush(stdout); + exit(1); + } + } + i=0; + while ((c=getchar())!='\n'){ + line[i++]=c; + } + line[i]=c; + if (strstr(line,"#123")){ + printf("webserver2 exiting\n"); + fflush(stdout); + break; + } + write(fdtoDbg,line,i+1); +>>>>>>> master } exit(0); } - - - - - - - - - diff --git a/files/compiledDatabaseProgram1.py b/files/compiledDatabaseProgram1.py index 7f497a2..8e917c5 100644 --- a/files/compiledDatabaseProgram1.py +++ b/files/compiledDatabaseProgram1.py @@ -1 +1,9 @@ -//This Is Code \ No newline at end of file +#include + +using namespace std; + +int main() +{ + cout << "Hello World"; + return 0; +} \ No newline at end of file diff --git a/files/finalOutput b/files/finalOutput index 4b4478f..3710256 100755 Binary files a/files/finalOutput and b/files/finalOutput differ diff --git a/files/finalOutput.cpp b/files/finalOutput.cpp index e69de29..0b4bfa0 100644 --- a/files/finalOutput.cpp +++ b/files/finalOutput.cpp @@ -0,0 +1,20 @@ +<<<<<<< HEAD +======= + +#include +#include +#include +using namespace std; + +int recursive(int a){ + if (a == 1) + return a+3; + else + return a+recursive(a-1); +} + +main(){ + cout << recursive(6)<<'\n'; +} + +>>>>>>> master diff --git a/files/finalOutput.py b/files/finalOutput.py index db82bea..e69de29 100644 --- a/files/finalOutput.py +++ b/files/finalOutput.py @@ -1,10 +0,0 @@ - -a=1 -b=2 -if (a == 1): -print "0,2" -elif (b==1): -print "1,2" -else: -print "neither" - diff --git a/files/finalOutput.txt b/files/finalOutput.txt index f5a1540..a45fd52 100644 --- a/files/finalOutput.txt +++ b/files/finalOutput.txt @@ -1,4 +1 @@ - File "../files/finalOutput.py", line 5 - print "0,2" - ^ -IndentationError: expected an indented block +24 diff --git a/files/log/log_2013-10-28.txt b/files/log/log_2013-10-28.txt new file mode 100644 index 0000000..f922abc --- /dev/null +++ b/files/log/log_2013-10-28.txt @@ -0,0 +1 @@ +2013-10-28 11:44:46 - INFO --> In Practice page; NULL diff --git a/files/log/log_2013-11-04.txt b/files/log/log_2013-11-04.txt new file mode 100644 index 0000000..e93a473 --- /dev/null +++ b/files/log/log_2013-11-04.txt @@ -0,0 +1 @@ +2013-11-04 11:56:00 - INFO --> In Practice page; NULL diff --git a/files/log/log_2013-11-06.txt b/files/log/log_2013-11-06.txt new file mode 100644 index 0000000..e69de29 diff --git a/files/log526e7f39a6563/log_2013-10-28.txt b/files/log526e7f39a6563/log_2013-10-28.txt new file mode 100644 index 0000000..709e0d2 --- /dev/null +++ b/files/log526e7f39a6563/log_2013-10-28.txt @@ -0,0 +1,26 @@ +2013-10-28 11:14:09 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:14:43 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:19:18 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:20:03 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:20:51 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:22:12 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:23:47 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:24:13 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:24:22 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:27:48 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:28:20 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:29:04 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:29:07 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:30:47 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:31:22 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:33:10 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:33:13 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:34:22 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:34:58 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:35:51 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:36:44 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:37:13 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:38:43 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:40:27 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:42:57 - INFO --> In Practice page; '526e7f39a6563' +2013-10-28 11:43:50 - INFO --> In Practice page; '526e7f39a6563' diff --git a/files/log526e867478678/log_2013-10-28.txt b/files/log526e867478678/log_2013-10-28.txt new file mode 100644 index 0000000..4be6e82 --- /dev/null +++ b/files/log526e867478678/log_2013-10-28.txt @@ -0,0 +1,13 @@ +2013-10-28 11:44:54 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:45:14 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:46:20 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:46:35 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:49:28 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:49:39 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:50:22 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:53:58 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:54:02 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:55:17 - INFO --> In Practice page; '526e867478678' +2013-10-28 11:56:08 - INFO --> In Practice page; '526e867478678' +2013-10-28 12:00:28 - INFO --> In Practice page; '526e867478678' +2013-10-28 12:00:35 - INFO --> In Practice page; '526e867478678' diff --git a/files/log5277c8d86c2f7/log_2013-11-04.txt b/files/log5277c8d86c2f7/log_2013-11-04.txt new file mode 100644 index 0000000..00b915c --- /dev/null +++ b/files/log5277c8d86c2f7/log_2013-11-04.txt @@ -0,0 +1,17 @@ +2013-11-04 11:18:34 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:19:25 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:20:16 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:27:13 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:32:36 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:32:37 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:34:16 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:35:36 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:35:53 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:36:57 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:37:59 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:39:03 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:39:13 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:40:26 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:42:56 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:43:10 - INFO --> In Practice page; '5277c8d86c2f7' +2013-11-04 11:45:06 - INFO --> In Practice page; '5277c8d86c2f7' diff --git a/files/log5277d1a65e015/log_2013-11-04.txt b/files/log5277d1a65e015/log_2013-11-04.txt new file mode 100644 index 0000000..fd6fe5d --- /dev/null +++ b/files/log5277d1a65e015/log_2013-11-04.txt @@ -0,0 +1,7 @@ +2013-11-04 11:56:08 - INFO --> In Practice page; '5277d1a65e015' +2013-11-04 11:56:31 - INFO --> In Practice page; '5277d1a65e015' +2013-11-04 11:56:54 - INFO --> In Practice page; '5277d1a65e015' +2013-11-04 11:59:45 - INFO --> In Practice page; '5277d1a65e015' +2013-11-04 12:01:01 - INFO --> In Practice page; '5277d1a65e015' +2013-11-04 12:02:23 - INFO --> In Practice page; '5277d1a65e015' +2013-11-04 12:02:37 - INFO --> In Practice page; '5277d1a65e015' diff --git a/files/log527983f17717a/log_2013-11-05.txt b/files/log527983f17717a/log_2013-11-05.txt new file mode 100644 index 0000000..3208f45 --- /dev/null +++ b/files/log527983f17717a/log_2013-11-05.txt @@ -0,0 +1,30 @@ +2013-11-05 18:49:07 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:49:41 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:52:14 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:52:15 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:52:19 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:54:47 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:54:49 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:54:51 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:55:08 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:55:09 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:55:13 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:57:15 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:57:18 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:57:20 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:57:24 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:58:23 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:58:25 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:58:48 - INFO --> In Practice page; '527983f17717a' +2013-11-05 18:58:53 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:00:04 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:00:05 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:00:24 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:00:25 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:01:28 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:01:30 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:01:52 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:01:54 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:02:45 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:02:46 - INFO --> In Practice page; '527983f17717a' +2013-11-05 19:02:50 - INFO --> In Practice page; '527983f17717a' diff --git a/files/log527a6ac839e05/log_2013-11-06.txt b/files/log527a6ac839e05/log_2013-11-06.txt new file mode 100644 index 0000000..0e86b96 --- /dev/null +++ b/files/log527a6ac839e05/log_2013-11-06.txt @@ -0,0 +1,10 @@ +2013-11-06 11:14:06 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:17:26 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:18:01 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:18:23 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:19:00 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:20:31 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:20:47 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:22:40 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:23:14 - INFO --> In Practice page; '527a6ac839e05' +2013-11-06 11:23:21 - INFO --> In Practice page; '527a6ac839e05' diff --git a/files/log527a7687c7f8d/log_2013-11-06.txt b/files/log527a7687c7f8d/log_2013-11-06.txt new file mode 100644 index 0000000..e69de29 diff --git a/files/log527baacedc9ee/log_2013-11-07.txt b/files/log527baacedc9ee/log_2013-11-07.txt new file mode 100644 index 0000000..e69de29 diff --git a/index.php b/index.php index e859f62..e8b3dfc 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ - session_start(); //check for last activity, and kill session as needed if (isset($_SESSION['lastActivity'])) { @@ -16,7 +16,7 @@ } else { $_SESSION['lastActivity'] = time(); // update last activity time stamp } -?> + diff --git a/instructor/addCourse.php b/instructor/addCourse.php index ec78e61..bdab782 100644 --- a/instructor/addCourse.php +++ b/instructor/addCourse.php @@ -1,60 +1,77 @@ - - - -
- -

Add a Course(s):


- -
-
    -
  • - -
    - -
    - -
  • - -
    - -
    -
  • - + + if (isset($_REQUEST['insert_classes'])) + { + $className = $_REQUEST['ClassName']; + $classCRN = $_REQUEST['ClassCRN']; + //$classInstructorID = $_REQUEST['ClassInstructorID']; + $classStartDate= $_REQUEST['ClassStartDate']; + $classEndDate = $_REQUEST['ClassEndDate']; + //$IsFinished = $_REQUEST['isFinished']; + + $classes="INSERT INTO classes (idClass, ClassCRN, ClassName, ClassInstructorID, ClassStartDate, ClassEndDate, isFinished) + VALUES('', '$classCRN','$className', '1', '$classStartDate', '$classEndDate', '')"; -
  • - -
    - -
    + //$lol = $mysqli->query($classes) ; + //var_dump($lol); + + } +?> -
  • - -
  • - -
    - -
    + + + + + + Add Course + + + + + + + + + +

    Add a Course:


    + + Course Name + + + +
    +
    + + CRN + + +
    +
    + + Class Start Date + + +
    +
    + + Class End Date + + +
    +
    + + + + + +
  • + + - - -
    -
  • - - -
  • -
    -
- -
diff --git a/instructor/closeCourse.php b/instructor/closeCourse.php index 76913f0..c85cd31 100644 --- a/instructor/closeCourse.php +++ b/instructor/closeCourse.php @@ -12,7 +12,7 @@ $sql = "UPDATE Classes SET isFinished = 1 WHERE idClass =" . $close_id ; $result = $mysqli->query($sql); -// if successful redirect to delete_multiple.php + if($result){ echo "Course is closed!!"; } @@ -41,15 +41,14 @@ fetch_array()){ - ?> - - - - - + + + + + \ No newline at end of file +?> + \ No newline at end of file diff --git a/instructor/courseAdded.php b/instructor/courseAdded.php deleted file mode 100644 index a1a6643..0000000 --- a/instructor/courseAdded.php +++ /dev/null @@ -1,44 +0,0 @@ -query($classes); -?> - - - - diff --git a/instructor/create_assignment.php b/instructor/create_assignment.php index 854031e..c6510d2 100644 --- a/instructor/create_assignment.php +++ b/instructor/create_assignment.php @@ -64,6 +64,7 @@ Max Attempts + + fetch_row()) + { + $assignmentName = $row[0]; + $assignmentId = $row[1]; + ?> + ; + + + + + + + + + + + + + + + + +<<<<<<< HEAD +>>>>>>> origin/tshanks +======= +>>>>>>> d35f812a44c80f5cd92957a0cf033f2f258bb0c7 diff --git a/instructor/unitTest.php b/instructor/unitTest.php new file mode 100644 index 0000000..1eeb465 --- /dev/null +++ b/instructor/unitTest.php @@ -0,0 +1,153 @@ + + + + +query($aQuery); + +?> + + + + + + + + + + + +
+ + + +

+

Unit Test Page

+ +

+ +

Choose Assignment:

+
+ + + required> +
+ + +
+ +

Unit Test:

+ Name: +

+ + Enter Code: +
+ + + +
+ + + Hidden: + + + + query($uQuery); + + + //Writes the UnitTest to a textfile + $fh = fopen($textFileName, 'w'); + //Adds filename to beginning of doc. + //fwrite($fh, $textFileName . PHP_EOL); + fwrite($fh, $unitCode); + fclose($fh); + + ?> + + +
+ \ No newline at end of file diff --git a/interface.c b/interface.c index fc499e3..9ca59ae 100644 --- a/interface.c +++ b/interface.c @@ -9,7 +9,7 @@ #include #define BUFFSIZE 8192 #define MaxPipeName 100 -#define logdir "/home/ruttan/classes/capstone/debugger/" +#define logdir "/var/www/html/Web/debugger" #define numDbgArgs 5 #define ArgSize 30 @@ -93,10 +93,11 @@ int main (int argc, char ** argv) { int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; sprintf(buf,"%s%s%s",logdir,"FILE",argv[1]); +printf("starting interface\n"); fflush(stdout); unlink(buf); fdtoFILE=fopen(buf,"w"); fprintf(fdtoFILE,"testing file output\n"); - +printf("starting interface\n"); signal(SIGPIPE, catch_sigpipe); signal(SIGINT, catch_sigint); if ((argc < 2 )|| (argc >=3)){ @@ -106,7 +107,7 @@ int main (int argc, char ** argv) { //create input pipe from webserver sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); unlink(fromServer); - +printf("making fifo");fflush(stdout); if (-1 == mkfifo(fromServer,S_IRWXU)) { perror("Error, could not make fifo\n"); } @@ -127,7 +128,7 @@ int main (int argc, char ** argv) { exit(1); } //create pipes to debugger - +printf("creating pipes\n"); fflush(stdout); if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK) perror("Pipe 1 creation failed"); exit(1); @@ -136,6 +137,7 @@ int main (int argc, char ** argv) { int i; char c; make_args(argv[1],nargv); +printf("launch debugger\n");fflush(stdout); child_pid=launch_debugger(nargv,pipefd); fprintf(fdtoFILE,"child_pid=%d\n",child_pid); fflush(fdtoFILE); @@ -143,7 +145,7 @@ int main (int argc, char ** argv) { fprintf(fdtoFILE,"---starting---\n"); fflush(fdtoFILE); - +printf("starting main loop\n");fflush(stdout); while(1){ line[0]=0; while (!strstr(line,">>>") && !strstr(line,"...")){ diff --git a/debugger/pipetest.c~ b/interfaceg.c similarity index 52% rename from debugger/pipetest.c~ rename to interfaceg.c index 33eeb29..6b8a263 100644 --- a/debugger/pipetest.c~ +++ b/interfaceg.c @@ -8,19 +8,32 @@ #include #include #define BUFFSIZE 8192 -#define MaxPipeName 50 -#define logdir "/tmp/debugger/" +#define MaxPipeName 100 +#define logdir "/home/ruttan/classes/capstone/debugger/" #define numDbgArgs 5 #define ArgSize 30 +#define prompt "(gdb)" pid_t child_pid; +char buf[BUFFSIZE]; +FILE * fdtoFILE; void catch_sigpipe(int sig_num) { /* re-set the signal handler again to catch_int, for next time */ signal(SIGPIPE, catch_sigpipe); - printf("got a signal\n"); - fflush(stdout); + fprintf(fdtoFILE,"got a signal\n"); + fflush(fdtoFILE); +} +void catch_sigint(int sig_num) +{ + /* re-set the signal handler again to catch_int, for next time */ + signal(SIGINT, catch_sigint); + kill(child_pid,1); + fprintf(fdtoFILE,"got a sigint signal\n"); + fflush(fdtoFILE); + sleep(1); + exit(1); } pid_t launch_debugger(char * argv[],int pipefd[2]){ @@ -68,10 +81,10 @@ pid_t launch_debugger(char * argv[],int pipefd[2]){ } void make_args(char * id,char * argv[]){ - argv[0]="/usr/local/bin/python3"; - argv[1]="-i"; - argv[2]="-c"; - argv[3]="\"print('Starting')\""; + argv[0]="/usr/bin/gdb"; + argv[1]=0; //"-i"; + argv[2]=0; //"-c"; + argv[3]=0;//"\"print 'Starting'\""; argv[4]=0; } @@ -79,16 +92,20 @@ int main (int argc, char ** argv) { int n; char * nargv[numDbgArgs]; int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2]; - char buf[BUFFSIZE],line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; - + char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName]; + sprintf(buf,"%s%s%s",logdir,"FILE",argv[1]); + unlink(buf); + fdtoFILE=fopen(buf,"w"); + fprintf(fdtoFILE,"testing file output\n"); + signal(SIGPIPE, catch_sigpipe); + signal(SIGINT, catch_sigint); if ((argc < 2 )|| (argc >=3)){ perror("usage: debugger idcode"); exit(1); } - /* //create input pipe from webserver - sprintf(fromServer,"%s%s%s",logdir,argv[1],"OUT"); + sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]); unlink(fromServer); if (-1 == mkfifo(fromServer,S_IRWXU)) { @@ -96,7 +113,7 @@ int main (int argc, char ** argv) { } //create output pipe to webserver - sprintf(toServer,"%s%s%s",logdir,argv[1],"IN"); + sprintf(toServer,"%s%s%s",logdir,"IN",argv[1]); unlink(toServer); if (-1 == mkfifo(toServer,S_IRWXU)) { @@ -117,63 +134,74 @@ int main (int argc, char ** argv) { exit(1); } - */ int i; - char c;make_args(argv[1],nargv); + char c; + make_args(argv[1],nargv); child_pid=launch_debugger(nargv,pipefd); - printf("child_pid=%d\n",child_pid); - fflush(stdout); + fprintf(fdtoFILE,"child_pid=%d\n",child_pid); + fflush(fdtoFILE); + setpgid(0, 0); + fprintf(fdtoFILE,"---starting---\n"); + fflush(fdtoFILE); + - + while(1){ + line[0]=0; + while (!strstr(line,prompt)){ + if ((n=read(pipefd[0],line,BUFFSIZE))){ + if (!n) { + fprintf(fdtoFILE,"pipe fd[0] closed"); + fflush(fdtoFILE); + exit(1); + } + //line[n++]='@'; + line[n]=0; + //if n=BUFFSIZE... + } + fprintf(fdtoFILE,"p-%s",line); + fflush(fdtoFILE); + if (write(fdtoWeb,line,n) != n) { + perror("fdtoWeb write error"); + fprintf(fdtoFILE,"fdtoWeb write error\n"); + fflush(fdtoFILE); + + } + + } + + if ((n=read(fdfrmWeb,line,BUFFSIZE))){ + line[n]=0; + fprintf(fdtoFILE,"%d-%s%s",n,"w-",line); + fflush(fdtoFILE); + if (write(pipefd[1],line,n) != n) { + perror("pipefd[1] write error"); + } - // while(1){ - /* - if ((n=read(fdfrmWeb,line,BUFFSIZE))){ - line[n]=0; - n=sprintf(buf,"%d-%s%s",n,"debugger:",line); - if (write(1,buf,n) != n) { - printf("cp: write error on file stdout\n"); - fflush(stdout); + } + else{ + printf("empty read\n"); + close(fdtoWeb); + close(fdfrmWeb); + n=0; + if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { + perror("cannot open fifo from server"); + exit(1); + } + + if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { + perror("cannot open fifo to server"); exit(1); + } + line[0]='\n'; + if (write(pipefd[1],line,1) != 1) { + perror("pipefd[1] write error"); + } + } - if (write(fdtoWeb,buf,n) != n) { - perror("fdtoWeb write error"); - } } - else{ - printf("empty read\n"); - close(fdtoWeb); - close(fdfrmWeb); - n=0; - if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) { - perror("cannot open fifo from server"); - exit(1); - } - if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) { - perror("cannot open fifo to server"); - exit(1); - } - } - */ - printf("starting\n"); - fflush(stdout); - while (1){ - line[0]=0; - while (!strstr(line,">>>")){ - if ((n=read(pipefd[0],line,BUFFSIZE))){ - line[n]=0; - } - printf("p-%s",line); - } - i=0; - while ((c=getchar())!='\n'){ - line[i++]=c; - } - line[i]=c; - write(pipefd[1],line,i+1); - } -exit(0); + + exit(0); } diff --git a/js/createCourse.js b/js/createCourse.js new file mode 100644 index 0000000..5744a91 --- /dev/null +++ b/js/createCourse.js @@ -0,0 +1,34 @@ + +function checkstuff() +{ + var x = document.forms["addCourse"]["ClassName"].value; + if (x == null || x == "") + { + alert("Please enter a course name."); + document.forms["addCourse"]["ClassName"].focus(); + return; + } + var x = document.forms["addCourse"]["ClassCRN"].value; + if (x == null || x == "") + { + alert("Please enter the CRN."); + document.forms["addCourse"]["ClassCRN"].focus(); + return; + } + var x = document.forms["addCourse"]["ClassStartDate"].value; + if (x == null || x == "") + { + alert("Please enter a start date."); + document.forms["addCourse"]["ClassStartDate"].focus(); + return; + } + var x = document.forms["addCourse"]["ClassEndDate"].value; + if (x == null || x == "") + { + alert("Please enter the end date."); + document.forms["addCourse"]["ClassEndDate"].focus(); + return; + } + + document.forms["addCourse"].submit(); +} \ No newline at end of file diff --git a/login.php b/login.php index e2872ca..a649300 100644 --- a/login.php +++ b/login.php @@ -28,7 +28,7 @@ } $email = $_POST["username"]; -$passwordHash = md5($_POST["password"]); +$passwordHash = $_POST["password"]; $query = "SELECT idMember, FirstName, LastName, IsInstructor, MemberBanner FROM Member WHERE MemberEmail='$email' AND MemberPassword='$passwordHash'"; $result = $mysqli->query($query); @@ -46,12 +46,12 @@ $_SESSION['memberbanner'] = $memberData['MemberBanner']; $_SESSION['idmember'] = $memberData['idMember']; $_SESSION['isinstructor'] = $memberData['IsInstructor']; - $_SESSION['uniqueID']=uniqid (); + $_SESSION['uniqueID']=uniqid (); /* $log = KLogger::instance(dirname(__FILE__) . '/files/log'.$_SESSION['uniqueID'], KLogger::INFO); $log->logInfo('dirname(__FILE__)=',dirname(__FILE__) ); //redirect to instructor interface (active courses) - */ + */ if ($_SESSION['isinstructor'] == 1) { header("Location:instructor/acourses.php"); } diff --git a/shared_php/databaseConnect.php b/shared_php/databaseConnect.php index 35b7a56..0f858d4 100644 --- a/shared_php/databaseConnect.php +++ b/shared_php/databaseConnect.php @@ -1,24 +1,24 @@ connect_errno) - { - printf("Connect failed: %s\n", $mysqli->connect_error); - exit(); - } + if ($mysqli->connect_errno) + { + printf("Connect failed: %s\n", $mysqli->connect_error); + exit(); + } -?> +?> \ No newline at end of file diff --git a/shared_php/header.php b/shared_php/header.php index b02232a..0345fb0 100644 --- a/shared_php/header.php +++ b/shared_php/header.php @@ -115,7 +115,11 @@ - + +