]>
Commit | Line | Data |
---|---|---|
21a8c5bc | 1 | diff -urN apr-1.3.3.org/file_io/unix/filedup.c apr-1.3.3/file_io/unix/filedup.c |
1271fac8 | 2 | --- apr-1.3.3.org/file_io/unix/filedup.c 2007-05-15 04:37:16.000000000 +0200 |
21a8c5bc AM |
3 | +++ apr-1.3.3/file_io/unix/filedup.c 2009-02-23 08:15:10.023641368 +0100 |
4 | @@ -24,7 +24,7 @@ | |
1271fac8 AM |
5 | apr_file_t *old_file, apr_pool_t *p, |
6 | int which_dup) | |
7 | { | |
8 | - int rv; | |
21b1ab48 | 9 | + int rv, fdflags; |
1271fac8 AM |
10 | |
11 | if (which_dup == 2) { | |
12 | if ((*new_file) == NULL) { | |
21a8c5bc | 13 | @@ -32,6 +32,14 @@ |
1271fac8 AM |
14 | return APR_EINVAL; |
15 | } | |
1271fac8 AM |
16 | rv = dup2(old_file->filedes, (*new_file)->filedes); |
17 | + if (!(old_file->flags & APR_INHERIT)) { | |
21b1ab48 AM |
18 | + fdflags = fcntl((*new_file)->filedes, F_GETFD); |
19 | + if (fdflags == -1) | |
1271fac8 | 20 | + return errno; |
21b1ab48 AM |
21 | + fdflags |= FD_CLOEXEC; |
22 | + if (fcntl((*new_file)->filedes, F_SETFD, fdflags) == -1) | |
1271fac8 AM |
23 | + return errno; |
24 | + } | |
1271fac8 AM |
25 | } else { |
26 | rv = dup(old_file->filedes); | |
27 | } | |
21a8c5bc | 28 | diff -urN apr-1.3.3.org/file_io/unix/mktemp.c apr-1.3.3/file_io/unix/mktemp.c |
1271fac8 | 29 | --- apr-1.3.3.org/file_io/unix/mktemp.c 2007-06-01 19:58:04.000000000 +0200 |
21a8c5bc AM |
30 | +++ apr-1.3.3/file_io/unix/mktemp.c 2009-02-23 08:18:30.420011379 +0100 |
31 | @@ -203,6 +203,11 @@ | |
1271fac8 AM |
32 | (*fp)->fname = apr_pstrdup(p, template); |
33 | ||
34 | if (!(flags & APR_FILE_NOCLEANUP)) { | |
35 | + int fdflags = fcntl(fd, F_GETFD); | |
21a8c5bc AM |
36 | + if (fdflags != -1) { |
37 | + fdflags |= FD_CLOEXEC; | |
38 | + fcntl(fd, F_SETFD, fdflags); | |
39 | + } | |
1271fac8 AM |
40 | apr_pool_cleanup_register((*fp)->pool, (void *)(*fp), |
41 | apr_unix_file_cleanup, | |
21a8c5bc AM |
42 | apr_unix_child_file_cleanup); |
43 | diff -urN apr-1.3.3.org/file_io/unix/open.c apr-1.3.3/file_io/unix/open.c | |
1271fac8 | 44 | --- apr-1.3.3.org/file_io/unix/open.c 2007-05-15 04:37:16.000000000 +0200 |
21a8c5bc | 45 | +++ apr-1.3.3/file_io/unix/open.c 2009-02-23 08:13:44.356609676 +0100 |
1271fac8 AM |
46 | @@ -125,7 +125,15 @@ |
47 | oflags |= O_BINARY; | |
48 | } | |
49 | #endif | |
50 | - | |
51 | + | |
52 | +#ifdef O_CLOEXEC | |
53 | + /* Introduced in Linux 2.6.23. Silently ignored on earlier Linux kernels. | |
54 | + */ | |
55 | + if (!(flag & APR_FILE_NOCLEANUP)) { | |
56 | + oflags |= O_CLOEXEC; | |
57 | +} | |
58 | +#endif | |
59 | + | |
60 | #if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE) | |
61 | oflags |= O_LARGEFILE; | |
62 | #elif defined(O_LARGEFILE) | |
63 | @@ -153,6 +161,11 @@ | |
64 | if (fd < 0) { | |
65 | return errno; | |
66 | } | |
67 | + if (!(flag & APR_FILE_NOCLEANUP)) { | |
68 | + int fdflags = fcntl(fd, F_GETFD); | |
69 | + fdflags |= FD_CLOEXEC; | |
70 | + fcntl(fd, F_SETFD, fdflags); | |
71 | + } | |
72 | ||
73 | (*new) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t)); | |
74 | (*new)->pool = pool; | |
21a8c5bc | 75 | diff -urN apr-1.3.3.org/include/arch/unix/apr_arch_inherit.h apr-1.3.3/include/arch/unix/apr_arch_inherit.h |
1271fac8 | 76 | --- apr-1.3.3.org/include/arch/unix/apr_arch_inherit.h 2006-08-03 12:55:31.000000000 +0200 |
21a8c5bc AM |
77 | +++ apr-1.3.3/include/arch/unix/apr_arch_inherit.h 2009-02-23 08:17:48.033064583 +0100 |
78 | @@ -27,6 +27,12 @@ | |
1271fac8 AM |
79 | if (the##name->flag & APR_FILE_NOCLEANUP) \ |
80 | return APR_EINVAL; \ | |
81 | if (!(the##name->flag & APR_INHERIT)) { \ | |
21b1ab48 AM |
82 | + int fdflags = fcntl(the##name->name##des, F_GETFD); \ |
83 | + if (fdflags == -1) \ | |
1271fac8 | 84 | + return errno; \ |
21b1ab48 AM |
85 | + fdflags &= ~(FD_CLOEXEC); \ |
86 | + if (fcntl(the##name->name##des, F_SETFD, fdflags) == -1) \ | |
1271fac8 AM |
87 | + return errno; \ |
88 | the##name->flag |= APR_INHERIT; \ | |
21a8c5bc AM |
89 | apr_pool_child_cleanup_set(the##name->pool, \ |
90 | (void *)the##name, \ | |
91 | @@ -41,6 +47,12 @@ | |
1271fac8 AM |
92 | if (the##name->flag & APR_FILE_NOCLEANUP) \ |
93 | return APR_EINVAL; \ | |
94 | if (the##name->flag & APR_INHERIT) { \ | |
21b1ab48 AM |
95 | + int fdflags = fcntl(the##name->name##des, F_GETFD); \ |
96 | + if (fdflags == -1) \ | |
1271fac8 | 97 | + return errno; \ |
21b1ab48 AM |
98 | + fdflags |= FD_CLOEXEC; \ |
99 | + if (fcntl(the##name->name##des, F_SETFD, fdflags) == -1) \ | |
1271fac8 AM |
100 | + return errno; \ |
101 | the##name->flag &= ~APR_INHERIT; \ | |
21a8c5bc AM |
102 | apr_pool_child_cleanup_set(the##name->pool, \ |
103 | (void *)the##name, \ | |
104 | diff -urN apr-1.3.3.org/network_io/unix/sockets.c apr-1.3.3/network_io/unix/sockets.c | |
105 | --- apr-1.3.3.org/network_io/unix/sockets.c 2009-02-23 08:08:40.966440943 +0100 | |
106 | +++ apr-1.3.3/network_io/unix/sockets.c 2009-02-23 08:19:02.086419869 +0100 | |
107 | @@ -83,7 +83,7 @@ | |
11945e1a AM |
108 | apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, |
109 | int protocol, apr_pool_t *cont) | |
110 | { | |
111 | - int family = ofamily; | |
21b1ab48 | 112 | + int family = ofamily, fdflags; |
11945e1a AM |
113 | |
114 | if (family == APR_UNSPEC) { | |
115 | #if APR_HAVE_IPV6 | |
21a8c5bc | 116 | @@ -130,6 +130,13 @@ |
11945e1a | 117 | } |
1271fac8 | 118 | set_socket_vars(*new, family, type, protocol); |
11945e1a | 119 | |
21b1ab48 AM |
120 | + fdflags = fcntl((*new)->socketdes, F_GETFD); |
121 | + if (fdflags == -1) | |
11945e1a | 122 | + return errno; |
21b1ab48 AM |
123 | + fdflags |= FD_CLOEXEC; |
124 | + if (fcntl((*new)->socketdes, F_SETFD, fdflags) == -1) | |
11945e1a | 125 | + return errno; |
11945e1a AM |
126 | + |
127 | (*new)->timeout = -1; | |
128 | (*new)->inherit = 0; | |
129 | apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, | |
21a8c5bc | 130 | @@ -183,7 +183,7 @@ |
11945e1a AM |
131 | apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock, |
132 | apr_pool_t *connection_context) | |
133 | { | |
134 | - int s; | |
21b1ab48 | 135 | + int s, fdflags; |
11945e1a AM |
136 | apr_sockaddr_t sa; |
137 | ||
138 | sa.salen = sizeof(sa.sa); | |
21a8c5bc | 139 | @@ -255,6 +262,13 @@ |
11945e1a AM |
140 | (*new)->local_interface_unknown = 1; |
141 | } | |
142 | ||
21b1ab48 AM |
143 | + fdflags = fcntl((*new)->socketdes, F_GETFD); |
144 | + if (fdflags == -1) | |
11945e1a | 145 | + return errno; |
21b1ab48 AM |
146 | + fdflags |= FD_CLOEXEC; |
147 | + if (fcntl((*new)->socketdes, F_SETFD, fdflags) == -1) | |
11945e1a | 148 | + return errno; |
11945e1a AM |
149 | + |
150 | (*new)->inherit = 0; | |
151 | apr_pool_cleanup_register((*new)->pool, (void *)(*new), socket_cleanup, | |
152 | socket_cleanup); | |
21a8c5bc | 153 | diff -urN apr-1.3.3.org/poll/unix/epoll.c apr-1.3.3/poll/unix/epoll.c |
1271fac8 | 154 | --- apr-1.3.3.org/poll/unix/epoll.c 2008-04-13 13:37:52.000000000 +0200 |
21a8c5bc AM |
155 | +++ apr-1.3.3/poll/unix/epoll.c 2009-02-23 08:20:07.663209400 +0100 |
156 | @@ -91,7 +91,7 @@ | |
1271fac8 AM |
157 | apr_uint32_t flags) |
158 | { | |
11945e1a | 159 | apr_status_t rv; |
1271fac8 AM |
160 | - int fd; |
161 | + int fd, fdflags; | |
11945e1a | 162 | |
11945e1a | 163 | fd = epoll_create(size); |
11945e1a | 164 | if (fd < 0) { |
21a8c5bc | 165 | @@ -99,6 +99,12 @@ |
11945e1a | 166 | return errno; |
1271fac8 AM |
167 | } |
168 | ||
1271fac8 | 169 | + fdflags = fcntl(fd, F_GETFD); |
21a8c5bc AM |
170 | + if (fdflags != -1) { |
171 | + fdflags |= FD_CLOEXEC; | |
172 | + fcntl(fd, F_SETFD, fdflags); | |
173 | + } | |
1271fac8 AM |
174 | + |
175 | *pollset = apr_palloc(p, sizeof(**pollset)); | |
176 | #if APR_HAS_THREADS | |
177 | if ((flags & APR_POLLSET_THREADSAFE) && | |
21a8c5bc | 178 | @@ -315,14 +321,20 @@ |
1271fac8 AM |
179 | apr_pool_t *p, |
180 | apr_uint32_t flags) | |
11945e1a | 181 | { |
1271fac8 | 182 | - int fd; |
11945e1a | 183 | - |
1271fac8 | 184 | + int fd, fdflags; |
11945e1a | 185 | + |
11945e1a | 186 | fd = epoll_create(size); |
11945e1a AM |
187 | |
188 | if (fd < 0) { | |
1271fac8 | 189 | *pollcb = NULL; |
11945e1a | 190 | return apr_get_netos_error(); |
11945e1a | 191 | } |
1271fac8 | 192 | + |
1271fac8 | 193 | + fdflags = fcntl(fd, F_GETFD); |
21a8c5bc AM |
194 | + if (fdflags != -1) { |
195 | + fdflags |= FD_CLOEXEC; | |
196 | + fcntl(fd, F_SETFD, fdflags); | |
197 | + } | |
11945e1a | 198 | |
1271fac8 AM |
199 | *pollcb = apr_palloc(p, sizeof(**pollcb)); |
200 | (*pollcb)->nalloc = size; |