-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.c
60 lines (49 loc) · 1.3 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(void)
{
puts("[*] Cleaning all servers");
setreuid(geteuid(), geteuid());
// Make sure shared libraries are linked
system("/sbin/ldconfig");
int pid1 = fork();
if(pid1 == 0) {
execl("/bin/kc", "/bin/kc", NULL);
}
else if (pid1 > 0) {
int status;
waitpid(pid1, &status, 0);
}
else {
printf("[!] Error while forking");
}
puts("[*] All servers cleaned");
puts("[*] Restart services");
// Javasript server
int pid2 = fork();
if(pid2 == 0) {
execl("/home/user1/servers/src/server.js", "/home/user1/servers/src/server.js", NULL);
}
else if (pid2 == -1) {
printf("[!] Error while forking");
}
// Go server
int pid3 = fork();
if(pid3 == 0) {
execl("/home/user1/servers/src/server.go", "/home/user1/servers/src/server.go", NULL);
}
else if (pid3 == -1) {
printf("[!] Error while forking");
}
// Python server
int pid4 = fork();
if(pid4 == 0) {
execl("/home/user1/servers/src/server.py", "/home/user1/servers/src/server.py", NULL);
}
else if (pid4 == -1) {
printf("[!] Error while forking");
}
puts("[*] Services restarted");
}