aboutsummaryrefslogtreecommitdiffstats
path: root/src/faudit/network.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-07-11 10:01:45 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-07-11 10:01:45 -0400
commit5bef777f30c7d5c2640486d33453b8648beb1eee (patch)
treef5cdf663f1a2ba44febaac9fb14588583fa825e8 /src/faudit/network.c
parentsnap platform (diff)
downloadfirejail-5bef777f30c7d5c2640486d33453b8648beb1eee.tar.gz
firejail-5bef777f30c7d5c2640486d33453b8648beb1eee.tar.zst
firejail-5bef777f30c7d5c2640486d33453b8648beb1eee.zip
audit work
Diffstat (limited to 'src/faudit/network.c')
-rw-r--r--src/faudit/network.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/faudit/network.c b/src/faudit/network.c
index 0e0ad1844..cf1eede69 100644
--- a/src/faudit/network.c
+++ b/src/faudit/network.c
@@ -23,7 +23,7 @@
23#include <linux/netlink.h> 23#include <linux/netlink.h>
24#include <linux/rtnetlink.h> 24#include <linux/rtnetlink.h>
25 25
26void check_ssh(void) { 26static void check_ssh(void) {
27 // open socket 27 // open socket
28 int sock = socket(AF_INET, SOCK_STREAM, 0); 28 int sock = socket(AF_INET, SOCK_STREAM, 0);
29 if (sock == -1) { 29 if (sock == -1) {
@@ -47,6 +47,30 @@ void check_ssh(void) {
47 close(sock); 47 close(sock);
48} 48}
49 49
50static void check_http(void) {
51 // open socket
52 int sock = socket(AF_INET, SOCK_STREAM, 0);
53 if (sock == -1) {
54 printf("GOOD: HTTP server not available on localhost.\n");
55 return;
56 }
57
58 // connect to localhost
59 struct sockaddr_in server;
60 server.sin_addr.s_addr = inet_addr("127.0.0.1");
61 server.sin_family = AF_INET;
62 server.sin_port = htons(80);
63
64 if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0)
65 printf("GOOD: HTTP server not available on localhost.\n");
66 else {
67 printf("MAYBE: an HTTP server is accessible on localhost. ");
68 printf("It could be a good idea to create a new network namespace using \"--net=none\" or \"--net=eth0\".\n");
69 }
70
71 close(sock);
72}
73
50void check_netlink(void) { 74void check_netlink(void) {
51 int sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0); 75 int sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0);
52 if (sock == -1) { 76 if (sock == -1) {
@@ -72,5 +96,6 @@ void check_netlink(void) {
72 96
73void network_test(void) { 97void network_test(void) {
74 check_ssh(); 98 check_ssh();
99 check_http();
75 check_netlink(); 100 check_netlink();
76} 101}