From 952668828a2bd73557672e5bc0a2177d7df04c63 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 1 Jul 2019 16:36:15 +0200 Subject: asdf --- src/main.c | 14 ++++++++++---- src/main.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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[]); -- cgit v1.2.3