|
Lines 16-22
Link Here
|
| 16 |
|
16 |
|
| 17 |
#include "includes.h" |
17 |
#include "includes.h" |
| 18 |
|
18 |
|
| 19 |
#ifndef HAVE_CLOSEFROM |
19 |
#if !defined(HAVE_CLOSEFROM) || defined(BROKEN_LINUX_CLOSEFROM) |
| 20 |
|
20 |
|
| 21 |
#include <sys/types.h> |
21 |
#include <sys/types.h> |
| 22 |
#include <sys/param.h> |
22 |
#include <sys/param.h> |
|
Lines 91-96
closefrom(int lowfd)
Link Here
|
| 91 |
{ |
91 |
{ |
| 92 |
(void) fcntl(lowfd, F_CLOSEM, 0); |
92 |
(void) fcntl(lowfd, F_CLOSEM, 0); |
| 93 |
} |
93 |
} |
|
|
94 |
#elif defined(HAVE_CLOSEFROM) && defined(BROKEN_LINUX_CLOSEFROM) |
| 95 |
# undef closefrom |
| 96 |
#include <sys/utsname.h> |
| 97 |
void |
| 98 |
_compat_linux_closefrom(int lowfd) |
| 99 |
{ |
| 100 |
struct utsname un; |
| 101 |
char *p, *op = NULL, *maj, *min; |
| 102 |
int fallback = 0; |
| 103 |
|
| 104 |
/* If version is < 5.9 or int conversions fail, use fallback. */ |
| 105 |
if (uname(&un) != 0 || (op = p = strdup(un.release)) == NULL || |
| 106 |
(maj = strsep(&p, ".")) == NULL || (min = strsep(&p, ".")) == NULL |
| 107 |
|| atoi(maj) < 5 || atoi(min) < 9) |
| 108 |
fallback = 1; |
| 109 |
free(op); |
| 110 |
if (fallback) |
| 111 |
closefrom_fallback(lowfd); |
| 112 |
else |
| 113 |
closefrom(lowfd); |
| 114 |
} |
| 94 |
#elif defined(HAVE_LIBPROC_H) && defined(HAVE_PROC_PIDINFO) |
115 |
#elif defined(HAVE_LIBPROC_H) && defined(HAVE_PROC_PIDINFO) |
| 95 |
void |
116 |
void |
| 96 |
closefrom(int lowfd) |
117 |
closefrom(int lowfd) |