aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-07-01 16:36:15 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-07-01 16:36:15 +0200
commit952668828a2bd73557672e5bc0a2177d7df04c63 (patch)
tree22d4b5ad01a8a91849438601ac1c95a64bf4f713 /src
parente6629281ffd30e5660b7e29003c0f9b40c586bdc (diff)
downloadbbs-952668828a2bd73557672e5bc0a2177d7df04c63.tar.gz
asdf
Diffstat (limited to 'src')
-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[]);