From 21a222d855a8963dbb11c68637f25992875c89cd Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 12 May 2024 16:22:11 +0100 Subject: [PATCH] Change base dir to /djumbai instead of /opt/djumbai --- Makefile | 16 ++++++++-------- README.md | 10 +++++----- .../djumbai_client_receive.c | 4 ++-- src/djumbai_dequeue/djumbai_dequeue.c | 7 +++---- src/djumbai_enqueue/djumbai_enqueue.c | 2 +- src/djumbai_send/djumbai_send.c | 6 +++--- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 5ea594f..8a799ee 100644 --- a/Makefile +++ b/Makefile @@ -54,14 +54,14 @@ permissions: -sudo chmod a+s $(BINDIR)/djumbai_send/djumbai_send directories: - -sudo mkdir -m 050 /opt/djumbai - -sudo mkdir -m 070 /opt/djumbai/fifos - -sudo mkdir -m 070 /opt/djumbai/user - -sudo mkdir -m 070 /opt/djumbai/group - -sudo chown nobody:djumbai /opt/djumbai - -sudo chown nobody:djumbai /opt/djumbai/fifos - -sudo chown nobody:djumbai /opt/djumbai/user - -sudo chown nobody:djumbai /opt/djumbai/group + -sudo mkdir -m 050 /djumbai + -sudo mkdir -m 070 /djumbai/fifos + -sudo mkdir -m 070 /djumbai/user + -sudo mkdir -m 070 /djumbai/group + -sudo chown nobody:djumbai /djumbai + -sudo chown nobody:djumbai /djumbai/fifos + -sudo chown nobody:djumbai /djumbai/user + -sudo chown nobody:djumbai /djumbai/group setup: users permissions directories diff --git a/README.md b/README.md index a472198..e4269c7 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,12 @@ This structured breakdown elucidates the sequential steps involved in the Unix m ## Cenas concretas -Mail queue - FIFO em /opt/djumbai/fifos/message_queue e so pode ser acedida por users do grupo djumbai_queue, que contem djumbai_enqueue e djumbai_dequeue +Mail queue - FIFO em /djumbai/fifos/message_queue e so pode ser acedida por users do grupo djumbai_queue, que contem djumbai_enqueue e djumbai_dequeue -Send FIFO - FIFO em /opt/djumbai/fifos/send_fifo e so pode ser acedida por users do grupo djumbai_send, que contem djumbai_dequeue e djumbai_send +Send FIFO - FIFO em /djumbai/fifos/send_fifo e so pode ser acedida por users do grupo djumbai_send, que contem djumbai_dequeue e djumbai_send -Mailbox pessoal _ Diretoria em /opt/djumbai/user/$uid/mailbox, que so pode ser acedida pelo user com UID $uid +Mailbox pessoal _ Diretoria em /djumbai/user/$uid/mailbox, que so pode ser acedida pelo user com UID $uid -SentBox pessoal - Diretoria em /opt/djumbai/user/$uid/sentbox, que so pode ser acedida pelo user com UID $uid +SentBox pessoal - Diretoria em /djumbai/user/$uid/sentbox, que so pode ser acedida pelo user com UID $uid -Mailbox grupo - Diretoria em /opt/djumbai/group/$gid/mailbox, que so pode ser acedida pelo grupo com GID $gid +Mailbox grupo - Diretoria em /djumbai/group/$gid/mailbox, que so pode ser acedida pelo grupo com GID $gid diff --git a/src/djumbai_client_receive/djumbai_client_receive.c b/src/djumbai_client_receive/djumbai_client_receive.c index 818fe01..10febb8 100644 --- a/src/djumbai_client_receive/djumbai_client_receive.c +++ b/src/djumbai_client_receive/djumbai_client_receive.c @@ -42,7 +42,7 @@ int main() { deserialize_message(buffer, MESSAGE_SIZE, &msg); if (msg.header.isgroup) { - const char *directory_format = "/opt/djumbai/group/%d/message_box"; + const char *directory_format = "/djumbai/group/%d/message_box"; char directory[PATH_MAX]; snprintf(directory, sizeof(directory), directory_format, msg.header.receiver); @@ -58,7 +58,7 @@ int main() { write_message_to_file(directory, timestamp_str, 0020, buffer); } else { - const char *directory_format = "/opt/djumbai/user/%d/message_box/%d"; + const char *directory_format = "/djumbai/user/%d/message_box/%d"; char directory[PATH_MAX]; snprintf(directory, sizeof(directory), directory_format, msg.header.receiver, msg.header.sender); diff --git a/src/djumbai_dequeue/djumbai_dequeue.c b/src/djumbai_dequeue/djumbai_dequeue.c index fef724a..2aea823 100644 --- a/src/djumbai_dequeue/djumbai_dequeue.c +++ b/src/djumbai_dequeue/djumbai_dequeue.c @@ -9,10 +9,9 @@ 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"); + chdir("/djumbai"); + if (chroot("/djumbai") != 0) { + perror("chroot /djumbai"); return 1; } const char *message_queue_path = "fifos/message_queue"; diff --git a/src/djumbai_enqueue/djumbai_enqueue.c b/src/djumbai_enqueue/djumbai_enqueue.c index 61c5bf0..53bd94f 100644 --- a/src/djumbai_enqueue/djumbai_enqueue.c +++ b/src/djumbai_enqueue/djumbai_enqueue.c @@ -2,7 +2,7 @@ int main() { //Change the root of the djumbai_enqueue process so it doesn't have access to anything else. - chroot("/opt/djumbai/queue/"); + chroot("/djumbai/queue/"); const char *message_queue_path = "mailqueue"; diff --git a/src/djumbai_send/djumbai_send.c b/src/djumbai_send/djumbai_send.c index 9e1258c..303b55d 100644 --- a/src/djumbai_send/djumbai_send.c +++ b/src/djumbai_send/djumbai_send.c @@ -10,9 +10,9 @@ #include int main() { - chdir("/opt/djumbai/"); - if (chroot("/opt/djumbai/") != 0) { - perror("chroot /opt/djumbai"); + chdir("/djumbai/"); + if (chroot("/djumbai/") != 0) { + perror("chroot /djumbai"); return 1; } const char *send_fifo_path = "fifos/send_fifo";