Remove the dependency on fdopendir, which does not exist everywhere.

git-svn-id: https://shellinabox.googlecode.com/svn/trunk@71 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac 2009-02-28 02:45:18 +00:00
parent 6c0a9cc80c
commit 11cda91356
4 changed files with 10 additions and 11 deletions

View file

@ -1,3 +1,8 @@
2009-02-27 Markus Gutschke <markus@shellinabox.com>
* Remove the dependency on fdopendir, which does not exist
everywhere.
2009-02-16 Markus Gutschke <markus@shellinabox.com>
* Include VCS revision number in user-visible version string.

2
aclocal.m4 vendored
View file

@ -21,7 +21,7 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
# serial 52 Debian 1.5.26-4 AC_PROG_LIBTOOL
# serial 52 Debian 1.5.26-1ubuntu1 AC_PROG_LIBTOOL
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)

View file

@ -95,7 +95,7 @@
#define STDC_HEADERS 1
/* Most recent revision number in the version control system */
#define VCS_REVISION "68"
#define VCS_REVISION "71"
/* Version number of package */
#define VERSION "2.4"

View file

@ -132,10 +132,6 @@ static int (*x_misc_conv)(int, const struct pam_message **,
#define misc_conv x_misc_conv
#endif
// Older versions of glibc might not support fdopendir(). That's OK, we can
// work around the lack of it, at a small performance loss.
extern DIR *fdopendir(int) __attribute__((weak));
static int launcher = -1;
static uid_t restricted;
@ -485,8 +481,8 @@ void closeAllFds(int *exceptFds, int num) {
// Close all file handles. If possible, scan through "/proc/self/fd" as
// that is faster than calling close() on all possible file handles.
int nullFd = open("/dev/null", O_RDWR);
int dirFd = !&fdopendir ? -1 : open("/proc/self/fd", O_RDONLY);
if (dirFd < 0) {
DIR *dir = opendir("/proc/self/fd");
if (dir == 0) {
for (int i = sysconf(_SC_OPEN_MAX); --i > 0; ) {
if (i != nullFd) {
for (int j = 0; j < num; j++) {
@ -505,14 +501,12 @@ void closeAllFds(int *exceptFds, int num) {
no_close_1:;
}
} else {
DIR *dir;
check(dir = fdopendir(dirFd));
struct dirent de, *res;
while (!readdir_r(dir, &de, &res) && res) {
if (res->d_name[0] < '0')
continue;
int fd = atoi(res->d_name);
if (fd != nullFd && fd != dirFd) {
if (fd != nullFd && fd != dirfd(dir)) {
for (int j = 0; j < num; j++) {
if (fd == exceptFds[j]) {
goto no_close_2;