mirror of
https://tildegit.org/solene/iblock.git
synced 2024-11-25 03:30:09 +01:00
Enable blocking as root, ipv4 only
This commit is contained in:
parent
a6e23e761b
commit
629d57262a
7
main.c
7
main.c
@ -12,10 +12,8 @@ int main(void){
|
|||||||
socklen_t slen = sizeof(sock);
|
socklen_t slen = sizeof(sock);
|
||||||
char host[1024] = "";
|
char host[1024] = "";
|
||||||
char port[1044] = "";
|
char port[1044] = "";
|
||||||
char cmd[1000] = "";
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
unveil("/usr/bin/doas", "rx");
|
|
||||||
unveil("/sbin/pfctl", "rx");
|
unveil("/sbin/pfctl", "rx");
|
||||||
pledge("exec inet dns stdio", NULL);
|
pledge("exec inet dns stdio", NULL);
|
||||||
|
|
||||||
@ -31,13 +29,10 @@ int main(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
syslog(LOG_DAEMON, "blocking %s", host);
|
syslog(LOG_DAEMON, "blocking %s", host);
|
||||||
snprintf(cmd, sizeof(cmd), "/sbin/pfctl -t blocked -T add %s", host);
|
|
||||||
|
|
||||||
syslog(LOG_DAEMON, "%s", cmd);
|
|
||||||
switch(sock. sa_family)
|
switch(sock. sa_family)
|
||||||
{
|
{
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
execlp(cmd, cmd, NULL);
|
execlp("/sbin/pfctl", "pfctl", "-t", "blocked", "-T", "add", host, NULL);
|
||||||
break;
|
break;
|
||||||
// case AF_INET6:
|
// case AF_INET6:
|
||||||
// printf("%s %s\n", host, cmd);
|
// printf("%s %s\n", host, cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user