Remove chroot from some processes

This commit is contained in:
Afonso Franco 2024-05-12 16:42:59 +01:00
parent 21a222d855
commit b6e33c1052
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
2 changed files with 3 additions and 11 deletions

View file

@ -8,13 +8,7 @@
#include <unistd.h> #include <unistd.h>
int main() { int main() {
// Change the root of the process so it doesn't have access to anything else. const char *message_queue_path = "/djumbai/fifos/message_queue";
chdir("/djumbai");
if (chroot("/djumbai") != 0) {
perror("chroot /djumbai");
return 1;
}
const char *message_queue_path = "fifos/message_queue";
if (access(message_queue_path, F_OK) != -1) { if (access(message_queue_path, F_OK) != -1) {
// FIFO exists, delete it // FIFO exists, delete it
@ -44,7 +38,7 @@ int main() {
} }
// Open the FIFO for writing // Open the FIFO for writing
const char *send_fifo_path = "fifos/send_fifo"; const char *send_fifo_path = "/djumbai/fifos/send_fifo";
int send_fifo_fd; int send_fifo_fd;
send_fifo_fd = open(send_fifo_path, O_WRONLY); send_fifo_fd = open(send_fifo_path, O_WRONLY);
if (send_fifo_fd == -1) { if (send_fifo_fd == -1) {

View file

@ -1,10 +1,8 @@
#include "djumbai_enqueue.h" #include "djumbai_enqueue.h"
int main() { int main() {
//Change the root of the djumbai_enqueue process so it doesn't have access to anything else.
chroot("/djumbai/queue/");
const char *message_queue_path = const char *message_queue_path =
"mailqueue"; "/djumbai/fifos/mailqueue";
// Open the FIFO for writing // Open the FIFO for writing
int queue_fd; int queue_fd;