From 5612d1adcab33197a3dfe7896e0481f3c50a7f8f Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 12 May 2024 15:52:10 +0100 Subject: [PATCH] fix dumb bud --- src/djumbai_dequeue/djumbai_dequeue.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/djumbai_dequeue/djumbai_dequeue.c b/src/djumbai_dequeue/djumbai_dequeue.c index 4fd7aaa..1484cd0 100644 --- a/src/djumbai_dequeue/djumbai_dequeue.c +++ b/src/djumbai_dequeue/djumbai_dequeue.c @@ -1,3 +1,4 @@ +#include "../../libs/protocol/protocol.h" #include #include #include @@ -5,15 +6,15 @@ #include #include #include -#include "../../libs/protocol/protocol.h" int main() { // Change the root of the process so it doesn't have access to anything else. - + chdir("/opt/djumbai/"); if (chroot("/opt/djumbai/") != 0) { perror("chroot /opt/djumbai"); return 1; + } const char *message_queue_path = "fifos/message_queue"; if (access(message_queue_path, F_OK) != -1) { @@ -58,14 +59,14 @@ int main() { } } - unsigned char buffer[MESSAGE_SIZE]; - while(1){ - read(message_queue_fd,buffer,MESSAGE_SIZE); - write(send_fifo_fd,buffer,MESSAGE_SIZE); - memset(buffer, 0, MESSAGE_SIZE); - } - - close(message_queue_fd); - unlink(message_queue_path); - close(send_fifo_fd); + unsigned char buffer[MESSAGE_SIZE]; + while (1) { + read(message_queue_fd, buffer, MESSAGE_SIZE); + write(send_fifo_fd, buffer, MESSAGE_SIZE); + memset(buffer, 0, MESSAGE_SIZE); + } + + close(message_queue_fd); + unlink(message_queue_path); + close(send_fifo_fd); }