diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/qmail-start.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/qmail-start.c')
-rw-r--r-- | src/qmail-start.c | 150 |
1 files changed, 87 insertions, 63 deletions
diff --git a/src/qmail-start.c b/src/qmail-start.c index 7a7342c..4ad250e 100644 --- a/src/qmail-start.c +++ b/src/qmail-start.c @@ -1,17 +1,22 @@ -#include <unistd.h> #include <sys/stat.h> +#include <unistd.h> + +#include "exit.h" #include "fd.h" #include "prot.h" -#include "exit.h" + #include "auto_uids.h" -char *(qsargs[]) = { "qmail-send", 0 }; -char *(qcargs[]) = { "qmail-clean", 0 }; -char *(qlargs[]) = { "qmail-lspawn", "./Mailbox", 0 }; -char *(qrargs[]) = { "qmail-rspawn", 0 }; -char *(qtargs[]) = { "qmail-todo", 0}; +char *(qsargs[]) = {"qmail-send", 0}; +char *(qcargs[]) = {"qmail-clean", 0}; +char *(qlargs[]) = {"qmail-lspawn", "./Mailbox", 0}; +char *(qrargs[]) = {"qmail-rspawn", 0}; +char *(qtargs[]) = {"qmail-todo", 0}; -void die() { _exit(111); } +void die() +{ + _exit(111); +} int pi0[2]; int pi1[2]; @@ -25,34 +30,54 @@ int pi8[2]; int pi9[2]; int pi10[2]; -void closefds() -{ - close(2); close(3); close(4); close(5); close(6); - close(7); close(8); +void closefds() +{ + close(2); + close(3); + close(4); + close(5); + close(6); + close(7); + close(8); } -void closepipes() +void closepipes() { - close(pi1[0]); close(pi1[1]); close(pi2[0]); close(pi2[1]); - close(pi3[0]); close(pi3[1]); close(pi4[0]); close(pi4[1]); - close(pi5[0]); close(pi5[1]); close(pi6[0]); close(pi6[1]); - close(pi7[0]); close(pi7[1]); close(pi8[0]); close(pi8[1]); - close(pi9[0]); close(pi9[1]); close(pi10[0]); close(pi10[1]); + close(pi1[0]); + close(pi1[1]); + close(pi2[0]); + close(pi2[1]); + close(pi3[0]); + close(pi3[1]); + close(pi4[0]); + close(pi4[1]); + close(pi5[0]); + close(pi5[1]); + close(pi6[0]); + close(pi6[1]); + close(pi7[0]); + close(pi7[1]); + close(pi8[0]); + close(pi8[1]); + close(pi9[0]); + close(pi9[1]); + close(pi10[0]); + close(pi10[1]); } -int main(int argc,char **argv) +int main(int argc, char **argv) { if (chdir("/") == -1) die(); umask(077); if (prot_gid(auto_gidq) == -1) die(); - if (fd_copy(2,0) == -1) die(); - if (fd_copy(3,0) == -1) die(); - if (fd_copy(4,0) == -1) die(); - if (fd_copy(5,0) == -1) die(); - if (fd_copy(6,0) == -1) die(); - if (fd_copy(7,0) == -1) die(); - if (fd_copy(8,0) == -1) die(); + if (fd_copy(2, 0) == -1) die(); + if (fd_copy(3, 0) == -1) die(); + if (fd_copy(4, 0) == -1) die(); + if (fd_copy(5, 0) == -1) die(); + if (fd_copy(6, 0) == -1) die(); + if (fd_copy(7, 0) == -1) die(); + if (fd_copy(8, 0) == -1) die(); if (argv[1]) { qlargs[1] = argv[1]; @@ -62,21 +87,20 @@ int main(int argc,char **argv) if (argv[1]) { if (pipe(pi0) == -1) die(); switch (fork()) { - case -1: - die(); + case -1: die(); case 0: if (prot_gid(auto_gidn) == -1) die(); if (prot_uid(auto_uidl) == -1) die(); close(pi0[1]); - if (fd_move(0,pi0[0]) == -1) die(); + if (fd_move(0, pi0[0]) == -1) die(); closefds(); - execvp(argv[1],argv + 1); + execvp(argv[1], argv + 1); die(); } close(pi0[0]); - if (fd_move(1,pi0[1]) == -1) die(); + if (fd_move(1, pi0[1]) == -1) die(); } - + if (pipe(pi1) == -1) die(); if (pipe(pi2) == -1) die(); if (pipe(pi3) == -1) die(); @@ -87,39 +111,39 @@ int main(int argc,char **argv) if (pipe(pi8) == -1) die(); if (pipe(pi9) == -1) die(); if (pipe(pi10) == -1) die(); - + switch (fork()) { case -1: die(); case 0: - if (fd_copy(0,pi1[0]) == -1) die(); - if (fd_copy(1,pi2[1]) == -1) die(); + if (fd_copy(0, pi1[0]) == -1) die(); + if (fd_copy(1, pi2[1]) == -1) die(); closefds(); closepipes(); - execvp(*qlargs,qlargs); + execvp(*qlargs, qlargs); die(); } - + switch (fork()) { case -1: die(); case 0: if (prot_uid(auto_uidr) == -1) die(); - if (fd_copy(0,pi3[0]) == -1) die(); - if (fd_copy(1,pi4[1]) == -1) die(); + if (fd_copy(0, pi3[0]) == -1) die(); + if (fd_copy(1, pi4[1]) == -1) die(); closefds(); closepipes(); - execvp(*qrargs,qrargs); + execvp(*qrargs, qrargs); die(); } - + switch (fork()) { case -1: die(); case 0: if (prot_uid(auto_uidq) == -1) die(); - if (fd_copy(0,pi5[0]) == -1) die(); - if (fd_copy(1,pi6[1]) == -1) die(); + if (fd_copy(0, pi5[0]) == -1) die(); + if (fd_copy(1, pi6[1]) == -1) die(); closefds(); closepipes(); - execvp(*qcargs,qcargs); + execvp(*qcargs, qcargs); die(); } @@ -127,13 +151,13 @@ int main(int argc,char **argv) case -1: die(); case 0: if (prot_uid(auto_uids) == -1) die(); - if (fd_copy(0,pi7[0]) == -1) die(); - if (fd_copy(1,pi8[1]) == -1) die(); + if (fd_copy(0, pi7[0]) == -1) die(); + if (fd_copy(1, pi8[1]) == -1) die(); closefds(); - if (fd_copy(2,pi9[1]) == -1) die(); - if (fd_copy(3,pi10[0]) == -1) die(); + if (fd_copy(2, pi9[1]) == -1) die(); + if (fd_copy(3, pi10[0]) == -1) die(); closepipes(); - execvp(*qtargs,qtargs); + execvp(*qtargs, qtargs); die(); } @@ -141,25 +165,25 @@ int main(int argc,char **argv) case -1: die(); case 0: if (prot_uid(auto_uidq) == -1) die(); - if (fd_copy(0,pi9[0]) == -1) die(); - if (fd_copy(1,pi10[1]) == -1) die(); + if (fd_copy(0, pi9[0]) == -1) die(); + if (fd_copy(1, pi10[1]) == -1) die(); closefds(); closepipes(); - execvp(*qcargs,qcargs); + execvp(*qcargs, qcargs); die(); } - + if (prot_uid(auto_uids) == -1) die(); - if (fd_copy(0,1) == -1) die(); - if (fd_copy(1,pi1[1]) == -1) die(); - if (fd_copy(2,pi2[0]) == -1) die(); - if (fd_copy(3,pi3[1]) == -1) die(); - if (fd_copy(4,pi4[0]) == -1) die(); - if (fd_copy(5,pi5[1]) == -1) die(); - if (fd_copy(6,pi6[0]) == -1) die(); - if (fd_copy(7,pi7[1]) == -1) die(); - if (fd_copy(8,pi8[0]) == -1) die(); + if (fd_copy(0, 1) == -1) die(); + if (fd_copy(1, pi1[1]) == -1) die(); + if (fd_copy(2, pi2[0]) == -1) die(); + if (fd_copy(3, pi3[1]) == -1) die(); + if (fd_copy(4, pi4[0]) == -1) die(); + if (fd_copy(5, pi5[1]) == -1) die(); + if (fd_copy(6, pi6[0]) == -1) die(); + if (fd_copy(7, pi7[1]) == -1) die(); + if (fd_copy(8, pi8[0]) == -1) die(); closepipes(); - execvp(*qsargs,qsargs); + execvp(*qsargs, qsargs); die(); } |