Skip to content

Siddharth cgi#12

Open
siddharth1998 wants to merge 12 commits intomainfrom
siddharth_cgi
Open

Siddharth cgi#12
siddharth1998 wants to merge 12 commits intomainfrom
siddharth_cgi

Conversation

@siddharth1998
Copy link
Collaborator

Merging the CGI working code with main

cgi.c Outdated
Comment on lines +63 to +73
// 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) */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't need this code, please remove them.

Comment on lines +99 to +102
// 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this code if you don't want it

Comment on lines +118 to +123
// 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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this code if you don't want it

handler.c Outdated
Comment on lines +56 to +60
/** TODO: Get this shit removed. This is for testing purpose only */
// if (iterator == 1) {
// (void)fd;
// execute_file(token, fd, );
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, we are not using this any more

cgi.c Outdated
Comment on lines +25 to +30
// char tempArgs;
// strncpy(ex)
// char *args[]={"/bin/sh", "sh", "-c",executable_path,NULL};
// for(int i=0; i<2;i++){
// printf("%s",args[i]);
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this code if you don't want it

cgi.c Outdated
Comment on lines +19 to +21
int execute_file(const char *executable_path, int socket_fd, bool is_valid_request, RESPONSE *response, char *response_string)
{
(void)socket_fd;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle errors inside the entire CGI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants