]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/ppp/0014-everywhere-use-SOCK_CLOEXEC-when-creating-socket.patch
ppp: update to 2.4.9
[ipfire-2.x.git] / src / patches / ppp / 0014-everywhere-use-SOCK_CLOEXEC-when-creating-socket.patch
CommitLineData
172c1f72
MT
1From 2a97ab28ee00586e5f06b3ef3a0e43ea0c7c6499 Mon Sep 17 00:00:00 2001
2From: Michal Sekletar <msekleta@redhat.com>
3Date: Mon, 7 Apr 2014 14:21:41 +0200
4Subject: [PATCH 14/25] everywhere: use SOCK_CLOEXEC when creating socket
5
6---
7 pppd/plugins/pppoatm/pppoatm.c | 2 +-
8 pppd/plugins/pppol2tp/openl2tp.c | 2 +-
9 pppd/plugins/pppol2tp/pppol2tp.c | 2 +-
0cd9215b
PM
10 pppd/plugins/pppoe/if.c | 2 +-
11 pppd/plugins/pppoe/plugin.c | 6 +++---
12 pppd/plugins/pppoe/pppoe-discovery.c | 2 +-
172c1f72
MT
13 pppd/sys-linux.c | 10 +++++-----
14 pppd/tty.c | 2 +-
15 8 files changed, 14 insertions(+), 14 deletions(-)
16
17diff --git a/pppd/plugins/pppoatm/pppoatm.c b/pppd/plugins/pppoatm/pppoatm.c
18index d693350..c31bb34 100644
19--- a/pppd/plugins/pppoatm/pppoatm.c
20+++ b/pppd/plugins/pppoatm/pppoatm.c
21@@ -135,7 +135,7 @@ static int connect_pppoatm(void)
22
23 if (!device_got_set)
24 no_device_given_pppoatm();
25- fd = socket(AF_ATMPVC, SOCK_DGRAM, 0);
26+ fd = socket(AF_ATMPVC, SOCK_DGRAM | SOCK_CLOEXEC, 0);
27 if (fd < 0)
28 fatal("failed to create socket: %m");
29 memset(&qos, 0, sizeof qos);
30diff --git a/pppd/plugins/pppol2tp/openl2tp.c b/pppd/plugins/pppol2tp/openl2tp.c
31index 9643b96..1099575 100644
32--- a/pppd/plugins/pppol2tp/openl2tp.c
33+++ b/pppd/plugins/pppol2tp/openl2tp.c
34@@ -83,7 +83,7 @@ static int openl2tp_client_create(void)
35 int result;
36
37 if (openl2tp_fd < 0) {
38- openl2tp_fd = socket(PF_UNIX, SOCK_DGRAM, 0);
39+ openl2tp_fd = socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
40 if (openl2tp_fd < 0) {
41 error("openl2tp connection create: %m");
42 return -ENOTCONN;
43diff --git a/pppd/plugins/pppol2tp/pppol2tp.c b/pppd/plugins/pppol2tp/pppol2tp.c
44index a7e3400..e64a778 100644
45--- a/pppd/plugins/pppol2tp/pppol2tp.c
46+++ b/pppd/plugins/pppol2tp/pppol2tp.c
47@@ -208,7 +208,7 @@ static void send_config_pppol2tp(int mtu,
48 struct ifreq ifr;
49 int fd;
50
51- fd = socket(AF_INET, SOCK_DGRAM, 0);
52+ fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
53 if (fd >= 0) {
54 memset (&ifr, '\0', sizeof (ifr));
55 strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
0cd9215b 56diff --git a/pppd/plugins/pppoe/if.c b/pppd/plugins/pppoe/if.c
172c1f72 57index 91e9a57..72aba41 100644
0cd9215b
PM
58--- a/pppd/plugins/pppoe/if.c
59+++ b/pppd/plugins/pppoe/if.c
172c1f72
MT
60@@ -116,7 +116,7 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr)
61 stype = SOCK_PACKET;
62 #endif
63
64- if ((fd = socket(domain, stype, htons(type))) < 0) {
65+ if ((fd = socket(domain, stype | SOCK_CLOEXEC, htons(type))) < 0) {
66 /* Give a more helpful message for the common error case */
67 if (errno == EPERM) {
68 fatal("Cannot create raw socket -- pppoe must be run as root.");
0cd9215b 69diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c
172c1f72 70index a8c2bb4..24bdf8f 100644
0cd9215b
PM
71--- a/pppd/plugins/pppoe/plugin.c
72+++ b/pppd/plugins/pppoe/plugin.c
172c1f72
MT
73@@ -137,7 +137,7 @@ PPPOEConnectDevice(void)
74 /* server equipment). */
75 /* Opening this socket just before waitForPADS in the discovery() */
76 /* function would be more appropriate, but it would mess-up the code */
77- conn->sessionSocket = socket(AF_PPPOX, SOCK_STREAM, PX_PROTO_OE);
78+ conn->sessionSocket = socket(AF_PPPOX, SOCK_STREAM | SOCK_CLOEXEC, PX_PROTO_OE);
79 if (conn->sessionSocket < 0) {
80 error("Failed to create PPPoE socket: %m");
81 return -1;
82@@ -148,7 +148,7 @@ PPPOEConnectDevice(void)
83 lcp_wantoptions[0].mru = conn->mru;
84
85 /* Update maximum MRU */
86- s = socket(AF_INET, SOCK_DGRAM, 0);
87+ s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
88 if (s < 0) {
89 error("Can't get MTU for %s: %m", conn->ifName);
90 goto errout;
91@@ -320,7 +320,7 @@ PPPoEDevnameHook(char *cmd, char **argv, int doit)
92 }
93
94 /* Open a socket */
95- if ((fd = socket(PF_PACKET, SOCK_RAW, 0)) < 0) {
96+ if ((fd = socket(PF_PACKET, SOCK_RAW | SOCK_CLOEXEC, 0)) < 0) {
97 r = 0;
98 }
99
0cd9215b 100diff --git a/pppd/plugins/pppoe/pppoe-discovery.c b/pppd/plugins/pppoe/pppoe-discovery.c
172c1f72 101index 3d3bf4e..c0d927d 100644
0cd9215b
PM
102--- a/pppd/plugins/pppoe/pppoe-discovery.c
103+++ b/pppd/plugins/pppoe/pppoe-discovery.c
172c1f72
MT
104@@ -121,7 +121,7 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr)
105 stype = SOCK_PACKET;
106 #endif
107
108- if ((fd = socket(domain, stype, htons(type))) < 0) {
109+ if ((fd = socket(domain, stype | SOCK_CLOEXEC, htons(type))) < 0) {
110 /* Give a more helpful message for the common error case */
111 if (errno == EPERM) {
112 rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
113diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
114index 00a2cf5..0690019 100644
115--- a/pppd/sys-linux.c
116+++ b/pppd/sys-linux.c
117@@ -308,12 +308,12 @@ static int modify_flags(int fd, int clear_bits, int set_bits)
118 void sys_init(void)
119 {
120 /* Get an internet socket for doing socket ioctls. */
121- sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
122+ sock_fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
123 if (sock_fd < 0)
124 fatal("Couldn't create IP socket: %m(%d)", errno);
125
126 #ifdef INET6
127- sock6_fd = socket(AF_INET6, SOCK_DGRAM, 0);
128+ sock6_fd = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
129 if (sock6_fd < 0)
130 sock6_fd = -errno; /* save errno for later */
131 #endif
132@@ -1857,7 +1857,7 @@ get_if_hwaddr(u_char *addr, char *name)
133 struct ifreq ifreq;
134 int ret, sock_fd;
135
136- sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
137+ sock_fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
138 if (sock_fd < 0)
139 return 0;
140 memset(&ifreq.ifr_hwaddr, 0, sizeof(struct sockaddr));
141@@ -2067,7 +2067,7 @@ int ppp_available(void)
142 /*
143 * Open a socket for doing the ioctl operations.
144 */
145- s = socket(AF_INET, SOCK_DGRAM, 0);
146+ s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
147 if (s < 0)
148 return 0;
149
172c1f72
MT
150diff --git a/pppd/tty.c b/pppd/tty.c
151index bc96695..8e76a5d 100644
152--- a/pppd/tty.c
153+++ b/pppd/tty.c
154@@ -896,7 +896,7 @@ open_socket(dest)
155 *sep = ':';
156
157 /* get a socket and connect it to the other end */
158- sock = socket(PF_INET, SOCK_STREAM, 0);
159+ sock = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
160 if (sock < 0) {
161 error("Can't create socket: %m");
162 return -1;
163--
1641.8.3.1
165