fix dumb mistake

This commit is contained in:
Afonso Franco 2024-05-12 16:05:31 +01:00
parent 5612d1adca
commit 5c28fe0531
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
2 changed files with 2 additions and 24 deletions

View file

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

View file

@ -10,23 +10,6 @@
#include <unistd.h>
int main() {
// Get the UID of the djumbaid user.
const char *djumbaid_username = "djumbaid";
struct passwd *pw = getpwnam(djumbaid_username);
if (pw == NULL) {
fprintf(stderr, "User %s not found\n", djumbaid_username);
exit(EXIT_FAILURE);
}
//Store previous UID
uid_t original_euid = geteuid();
// Set UID to djumbaid
if (seteuid(pw->pw_uid) == -1) {
perror("setuid");
exit(EXIT_FAILURE);
}
chdir("/opt/djumbai/");
if (chroot("/opt/djumbai/") != 0) {
perror("chroot /opt/djumbai");
@ -60,11 +43,6 @@ int main() {
return 1;
}
}
//Restore previous UID
if (seteuid(original_euid) == -1) {
perror("Restore original euid");
exit(EXIT_FAILURE);
}
while (1) {
// Read message from the send_fifo