-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsys_actions.c
34 lines (31 loc) · 1.19 KB
/
sys_actions.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
#include <unistd.h>
#include <string.h>
#include <stdio.h>
/*
Note for these functions, the last arguement is a pointer to the environment. here I use NULL so that no environment is used.
*/
int main(int argc, char *argv[]){
char* command = argv[1];
setuid(0);
setgid(0);
if(strcmp(command, "smb_status") == 0){
execle("/usr/bin/systemctl","systemctl","status","smbd.service",(char*) NULL, (char*) NULL);
}else if(strcmp(command, "smb_restart") == 0){
execle("/usr/bin/systemctl","systemctl","restart","smbd.service",(char*) NULL, (char*) NULL);
}else if(strcmp(command, "nfs_status") == 0){
execle("/usr/bin/systemctl","systemctl","status","nfs-server.service",(char*) NULL, (char*) NULL);
//execle("/usr/bin/ping","/usr/bin/ping","-c","1","10.0.0.1",(char*) NULL);
}else if(strcmp(command, "nfs_restart") == 0){
execle("/usr/bin/systemctl","systemctl","restart","nfs-server.service",(char*) NULL, (char*) NULL);
}else if(strcmp(command, "shut") == 0){
execle("/usr/bin/shutdown","shutdown","now",(char*) NULL,(char*) NULL);
}else{
printf("Invalid command\n");
}
}
/*
gcc sys_actions.c -o sys_actions
doas chown root:root sys_actions
doas chmod u+s sys_actions
doas chmod o+x sys_actions
*/