aboutsummaryrefslogtreecommitdiffstats
path: root/src/libconnect/libconnect.c
diff options
context:
space:
mode:
authorLibravatar SYN-cook <SYN-cook@users.noreply.github.com>2017-02-28 19:57:25 +0100
committerLibravatar GitHub <noreply@github.com>2017-02-28 19:57:25 +0100
commit0890a915daf92ef2e37bb28be3d887e699ec1de2 (patch)
tree785bfa9d2eded39c3df72f00071d1abedb5cec90 /src/libconnect/libconnect.c
parentremove redundancy (diff)
parentprofile merges (diff)
downloadfirejail-0890a915daf92ef2e37bb28be3d887e699ec1de2.tar.gz
firejail-0890a915daf92ef2e37bb28be3d887e699ec1de2.tar.zst
firejail-0890a915daf92ef2e37bb28be3d887e699ec1de2.zip
Merge pull request #2 from netblue30/master
merge upstream
Diffstat (limited to 'src/libconnect/libconnect.c')
-rw-r--r--src/libconnect/libconnect.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/libconnect/libconnect.c b/src/libconnect/libconnect.c
deleted file mode 100644
index 18c4d81f5..000000000
--- a/src/libconnect/libconnect.c
+++ /dev/null
@@ -1,66 +0,0 @@
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#define _GNU_SOURCE
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <dlfcn.h>
25#include <sys/types.h>
26#include <unistd.h>
27#include <sys/socket.h>
28#include <netinet/in.h>
29#include <arpa/inet.h>
30#include <sys/un.h>
31#include <sys/stat.h>
32#include <dirent.h>
33#include <errno.h>
34
35//#define DEBUG
36
37//static int check_sockaddr(int sockfd, const char *call, const struct sockaddr *addr, int rv) {
38static int check_sockaddr(const struct sockaddr *addr) {
39 if (addr->sa_family == AF_UNIX) {
40 struct sockaddr_un *a = (struct sockaddr_un *) addr;
41 if (a->sun_path[0] == '\0' && strstr(a->sun_path + 1, "X11-unix")) {
42// printf("@%s\n", a->sun_path + 1);
43 errno = ENOENT;
44 return -1;
45 }
46 }
47
48 return 0;
49}
50
51//
52// syscalls
53//
54
55// connect
56typedef int (*orig_connect_t)(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
57static orig_connect_t orig_connect = NULL;
58int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
59 if (!orig_connect)
60 orig_connect = (orig_connect_t)dlsym(RTLD_NEXT, "connect");
61
62 if (check_sockaddr(addr) == -1)
63 return -1;
64
65 return orig_connect(sockfd, addr, addrlen);
66}