]> granicus.if.org Git - sudo/commitdiff
Go back to using /proc/self/fd instead of /proc/$$/fd as only AIX
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 17 Dec 2013 14:38:20 +0000 (07:38 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 17 Dec 2013 14:38:20 +0000 (07:38 -0700)
lacks /proc/self and it has F_CLOSEM.

compat/closefrom.c

index cb7fa8a5d008b778294b6a2d2afe8695c0697da6..55a4d92c6c9b7720fe5ca8725896329fcb348a54 100644 (file)
@@ -31,7 +31,6 @@
 # endif
 #endif /* STDC_HEADERS */
 #include <fcntl.h>
-#include <limits.h>
 #ifdef HAVE_PSTAT_GETPROC
 # include <sys/param.h>
 # include <sys/pstat.h>
@@ -121,14 +120,14 @@ closefrom(int lowfd)
 void
 closefrom(int lowfd)
 {
-    char path[PATH_MAX];
+    const char *path;
     DIR *dirp;
 
-    /* Use /proc/$$/fd (or /dev/fd on FreeBSD) if it exists. */
+    /* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */
 # if defined(__FreeBSD__) || defined(__APPLE__)
-    snprintf(path, sizeof(path), "/dev/fd");
+    path = "/dev/fd";
 # else
-    snprintf(path, sizeof(path), "/proc/%u/fd", (unsigned int)getpid());
+    path = "/proc/self/fd";
 # endif
     if ((dirp = opendir(path)) != NULL) {
        struct dirent *dent;