File bash-4.2-nscdunmap.dif of Package bash

--- shell.c
+++ shell.c	2011-11-11 15:08:39.479158014 +0000
@@ -39,8 +39,8 @@
 #include <errno.h>
 #include "filecntl.h"
 #include <pwd.h>
-
 #if defined (HAVE_UNISTD_H)
+#  include <sys/types.h>
 #  include <unistd.h>
 #endif
 
@@ -1630,6 +1630,28 @@ init_interactive_script ()
   expand_aliases = interactive_shell = startup_state = 1;
 }
 
+static void
+maybe_unmap_nscd (void)
+{
+  unsigned long start, end, off;
+  char path[PATH_MAX];
+  FILE *maps;
+
+  if (getppid() != 1)
+    return;
+  if ((maps = fopen("/proc/self/maps", "r")) == NULL)
+    return;
+
+  while (fscanf(maps, "%lx-%lx %*s %lx %*x:%*x %*lu %s", &start, &end, &off, &path[0]) == 4)
+    {
+      if (strncmp(path, "/var/run/nscd/", 14) != 0)
+	continue;
+      munmap((void*)start, end - start);
+    }
+
+  fclose(maps);
+}
+
 void
 get_current_user_info ()
 {
@@ -1655,6 +1677,7 @@ get_current_user_info ()
 	  current_user.home_dir = savestring ("/");
 	}
       endpwent ();
+      maybe_unmap_nscd ();
     }
 }
 
openSUSE Build Service is sponsored by