Change base dir to /djumbai instead of /opt/djumbai

This commit is contained in:
Afonso Franco 2024-05-12 16:22:11 +01:00
parent 5c28fe0531
commit 21a222d855
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
6 changed files with 22 additions and 23 deletions

View file

@ -54,14 +54,14 @@ permissions:
-sudo chmod a+s $(BINDIR)/djumbai_send/djumbai_send -sudo chmod a+s $(BINDIR)/djumbai_send/djumbai_send
directories: directories:
-sudo mkdir -m 050 /opt/djumbai -sudo mkdir -m 050 /djumbai
-sudo mkdir -m 070 /opt/djumbai/fifos -sudo mkdir -m 070 /djumbai/fifos
-sudo mkdir -m 070 /opt/djumbai/user -sudo mkdir -m 070 /djumbai/user
-sudo mkdir -m 070 /opt/djumbai/group -sudo mkdir -m 070 /djumbai/group
-sudo chown nobody:djumbai /opt/djumbai -sudo chown nobody:djumbai /djumbai
-sudo chown nobody:djumbai /opt/djumbai/fifos -sudo chown nobody:djumbai /djumbai/fifos
-sudo chown nobody:djumbai /opt/djumbai/user -sudo chown nobody:djumbai /djumbai/user
-sudo chown nobody:djumbai /opt/djumbai/group -sudo chown nobody:djumbai /djumbai/group
setup: users permissions directories setup: users permissions directories

View file

@ -32,12 +32,12 @@ This structured breakdown elucidates the sequential steps involved in the Unix m
## Cenas concretas ## 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

View file

@ -42,7 +42,7 @@ int main() {
deserialize_message(buffer, MESSAGE_SIZE, &msg); deserialize_message(buffer, MESSAGE_SIZE, &msg);
if (msg.header.isgroup) { 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]; char directory[PATH_MAX];
snprintf(directory, sizeof(directory), directory_format, msg.header.receiver); snprintf(directory, sizeof(directory), directory_format, msg.header.receiver);
@ -58,7 +58,7 @@ int main() {
write_message_to_file(directory, timestamp_str, 0020, buffer); write_message_to_file(directory, timestamp_str, 0020, buffer);
} else { } 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]; char directory[PATH_MAX];
snprintf(directory, sizeof(directory), directory_format, msg.header.receiver, snprintf(directory, sizeof(directory), directory_format, msg.header.receiver,
msg.header.sender); msg.header.sender);

View file

@ -9,10 +9,9 @@
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("/djumbai");
chdir("/opt/djumbai"); if (chroot("/djumbai") != 0) {
if (chroot("/opt/djumbai") != 0) { perror("chroot /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";

View file

@ -2,7 +2,7 @@
int main() { int main() {
//Change the root of the djumbai_enqueue process so it doesn't have access to anything else. //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 = const char *message_queue_path =
"mailqueue"; "mailqueue";

View file

@ -10,9 +10,9 @@
#include <unistd.h> #include <unistd.h>
int main() { int main() {
chdir("/opt/djumbai/"); chdir("/djumbai/");
if (chroot("/opt/djumbai/") != 0) { if (chroot("/djumbai/") != 0) {
perror("chroot /opt/djumbai"); perror("chroot /djumbai");
return 1; return 1;
} }
const char *send_fifo_path = "fifos/send_fifo"; const char *send_fifo_path = "fifos/send_fifo";