--- shell.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) --- shell.c +++ shell.c 2025-01-31 13:53:05.110369836 +0000 @@ -43,6 +43,8 @@ #endif #if defined (HAVE_UNISTD_H) +# include +# include # include #endif @@ -1873,6 +1875,28 @@ init_interactive_script (void) #endif } +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 (void) { @@ -1904,6 +1928,7 @@ get_current_user_info (void) #if defined (HAVE_GETPWENT) endpwent (); #endif + maybe_unmap_nscd (); } }