From 11cda913568bc5cc4ce0adecc3743d80d3ed9061 Mon Sep 17 00:00:00 2001 From: zodiac Date: Sat, 28 Feb 2009 02:45:18 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ aclocal.m4 | 2 +- config.h | 2 +- shellinabox/launcher.c | 12 +++--------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67d9d71..3481d81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-02-27 Markus Gutschke + + * Remove the dependency on fdopendir, which does not exist + everywhere. + 2009-02-16 Markus Gutschke * Include VCS revision number in user-visible version string. diff --git a/aclocal.m4 b/aclocal.m4 index c8d28b8..1d4ddbf 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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) diff --git a/config.h b/config.h index 4c2d0a5..b919999 100644 --- a/config.h +++ b/config.h @@ -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" diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index d07fd1a..c48ed3c 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -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;