aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c14
-rw-r--r--src/main.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index f5141e1..65d3a94 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,7 +66,7 @@ struct prog_params parse_args(int argc, char* argv[])
return ret;
}
-void handle_connection(int _socket, struct sockaddr_in _addr)
+void handle_connection(int _socket, struct sockaddr_in _addr, int argc, char* argv[])
{
pid_t pid = fork();
if( pid > 0 )
@@ -95,8 +95,14 @@ void handle_connection(int _socket, struct sockaddr_in _addr)
dup2(_socket, STDOUT_FILENO);
dup2(_socket, STDERR_FILENO);
- //RUUNNNN!
- execl("/usr/bin/whoami", "/usr/bin/whoami", NULL);
+ char* arv[argc + 1];
+
+ for(int i = 0; i < argc; i++)
+ arv[i] = argv[i];
+
+ arv[argc] = NULL;
+
+ execv(argv[0], arv);
PRINT_ERROR("EXEC failed");
@@ -206,6 +212,6 @@ void telnet_server(struct prog_params params)
{
client_socket = accept(server_socket, &client_address, &claddrsize);
DEBUG_PRINTF("Connection: %s\n", inet_ntoa(client_address.sin_addr));
- handle_connection(client_socket, client_address);
+ handle_connection(client_socket, client_address, params.run_argc, params.run_argv);
}
}
diff --git a/src/main.h b/src/main.h
index a22c8f2..ae8328e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -54,7 +54,7 @@ struct prog_params
struct prog_params parse_args(int argc, char* argv[]);
-void handle_connection(int _socket, struct sockaddr_in _addr);
+void handle_connection(int _socket, struct sockaddr_in _addr, int argc, char* argv[]);
int main(int argc, char* argv[]);