aboutsummaryrefslogtreecommitdiffstats
path: root/src/faudit
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-07-03 19:56:10 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-07-03 19:56:10 -0400
commit2913ccf84a11d9c1c19c1885738ae8e5eaeb53d1 (patch)
tree02e3de75ac33d1e59b58ae82442da421fcd2a34a /src/faudit
parentfaudit network (diff)
downloadfirejail-2913ccf84a11d9c1c19c1885738ae8e5eaeb53d1.tar.gz
firejail-2913ccf84a11d9c1c19c1885738ae8e5eaeb53d1.tar.zst
firejail-2913ccf84a11d9c1c19c1885738ae8e5eaeb53d1.zip
faudit network
Diffstat (limited to 'src/faudit')
-rw-r--r--src/faudit/network.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/faudit/network.c b/src/faudit/network.c
new file mode 100644
index 000000000..697b1d1fb
--- /dev/null
+++ b/src/faudit/network.c
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2014-2016 Firejail Authors
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20#include "faudit.h"
21#include <sys/socket.h>
22#include <arpa/inet.h>
23
24void check_ssh(void) {
25 printf("INFO: looking for ssh servers running on localhost\n");
26
27 // open socket
28 int sock = socket(AF_INET, SOCK_STREAM, 0);
29 if (sock == -1) {
30 printf("Error: cannot create an IPv4 socket\n");
31 return;
32 }
33
34 // connect to localhost
35 struct sockaddr_in server;
36 server.sin_addr.s_addr = inet_addr("127.0.0.1");
37 server.sin_family = AF_INET;
38 server.sin_port = htons(22);
39
40 if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0)
41 printf("GOOD: SSH server not available on localhost\n");
42 else {
43 printf("MAYBE: an SSH server is accessible on localhost\n");
44 printf("It could be a good idea to create a new network namespace using \"--net=none\" or \"--net=eth0\".\n");
45 }
46
47 close(sock);
48}
49
50void network_test(void) {
51 check_ssh();
52}