fix dumb bud
This commit is contained in:
parent
b29258a2e9
commit
5612d1adca
1 changed files with 13 additions and 12 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#include "../../libs/protocol/protocol.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -5,15 +6,15 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "../../libs/protocol/protocol.h"
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Change the root of the process so it doesn't have access to anything else.
|
// Change the root of the process so it doesn't have access to anything else.
|
||||||
|
|
||||||
chdir("/opt/djumbai/");
|
chdir("/opt/djumbai/");
|
||||||
if (chroot("/opt/djumbai/") != 0) {
|
if (chroot("/opt/djumbai/") != 0) {
|
||||||
perror("chroot /opt/djumbai");
|
perror("chroot /opt/djumbai");
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
const char *message_queue_path = "fifos/message_queue";
|
const char *message_queue_path = "fifos/message_queue";
|
||||||
|
|
||||||
if (access(message_queue_path, F_OK) != -1) {
|
if (access(message_queue_path, F_OK) != -1) {
|
||||||
|
@ -58,14 +59,14 @@ int main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char buffer[MESSAGE_SIZE];
|
unsigned char buffer[MESSAGE_SIZE];
|
||||||
while(1){
|
while (1) {
|
||||||
read(message_queue_fd,buffer,MESSAGE_SIZE);
|
read(message_queue_fd, buffer, MESSAGE_SIZE);
|
||||||
write(send_fifo_fd,buffer,MESSAGE_SIZE);
|
write(send_fifo_fd, buffer, MESSAGE_SIZE);
|
||||||
memset(buffer, 0, MESSAGE_SIZE);
|
memset(buffer, 0, MESSAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(message_queue_fd);
|
close(message_queue_fd);
|
||||||
unlink(message_queue_path);
|
unlink(message_queue_path);
|
||||||
close(send_fifo_fd);
|
close(send_fifo_fd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue