Conversation
cgi.c
Outdated
| // Duplicating the file descriptors onto the write-ends of the pipes | ||
| // if (dup2(socket_fd, STDOUT_FILENO) < 0) | ||
| // { | ||
| // perror("Could not duplicate STDOUT file descriptor to the pipe."); | ||
| // status = -1; | ||
| // break; | ||
| // } | ||
|
|
||
| /* We ignore possible error returns because the only specified error | ||
| is for a failed exec(), and because errors in these calls can't | ||
| affect the caller of command() (which is a separate process) */ |
There was a problem hiding this comment.
If you don't need this code, please remove them.
| // execve("/bin/ls", args, env); | ||
| // execl("/bin/sh", "sh", "-c", executable_path, (char *)NULL); | ||
| // printf("\n%d\n",errno); | ||
| // execve(executable_path,args,envp);//Working |
There was a problem hiding this comment.
remove this code if you don't want it
| // if (execve(executable_path,(char *const*)NULL,envp)==-1){ | ||
| // printf("Execve() Not able to run this"); | ||
|
|
||
| // } | ||
| // printf("\n%d\n",errno); | ||
| // fprintf(stderr, "Value of errno: %d\n", errno); |
There was a problem hiding this comment.
remove this code if you don't want it
handler.c
Outdated
| /** TODO: Get this shit removed. This is for testing purpose only */ | ||
| // if (iterator == 1) { | ||
| // (void)fd; | ||
| // execute_file(token, fd, ); | ||
| // } |
There was a problem hiding this comment.
Remove this, we are not using this any more
cgi.c
Outdated
| // char tempArgs; | ||
| // strncpy(ex) | ||
| // char *args[]={"/bin/sh", "sh", "-c",executable_path,NULL}; | ||
| // for(int i=0; i<2;i++){ | ||
| // printf("%s",args[i]); | ||
| // } |
There was a problem hiding this comment.
remove this code if you don't want it
cgi.c
Outdated
| int execute_file(const char *executable_path, int socket_fd, bool is_valid_request, RESPONSE *response, char *response_string) | ||
| { | ||
| (void)socket_fd; |
There was a problem hiding this comment.
Make your coding style like rest of the code base
generally for any chunk of code with if or while or any loop or any big function call
leave an empty line before it
printf("Hello World");
if (1 == 1) {
..something
}
also don't put the brackets in the next line, put them in the same line
ex : if (condition) {
..do like this
}
/** DONT DO LIKE THIS */
if ()
{
....code
}
| @@ -8,21 +8,32 @@ | |||
| #include <sys/wait.h> | |||
There was a problem hiding this comment.
Handle errors inside the entire CGI
Merging the CGI working code with main