View | Details | Raw Unified | Return to bug 3349 | Differences between
and this patch

Collapse All | Expand All

(-)a/openbsd-compat/bsd-closefrom.c (-1 / +22 lines)
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)
(-)a/openbsd-compat/openbsd-compat.h (+4 lines)
Lines 63-68 int bindresvport_sa(int sd, struct sockaddr *sa); Link Here
63
63
64
#ifndef HAVE_CLOSEFROM
64
#ifndef HAVE_CLOSEFROM
65
void closefrom(int);
65
void closefrom(int);
66
#elif defined(__linux__) && defined(__GLIBC__)
67
# define BROKEN_LINUX_CLOSEFROM
68
# define closefrom(x)	_compat_linux_closefrom(x)
69
void _compat_linux_closefrom(int);
66
#endif
70
#endif
67
71
68
#ifndef HAVE_GETLINE
72
#ifndef HAVE_GETLINE

Return to bug 3349