Accepting request 90996 from Base:System
- Avoid memory mapped /var/run/nscd/passwd at shutdown by simply unmapping this only used area if parent is systemd or SysVinit - Always close get(pw|gr)func with endpw() respectivly with endgr() to avoid memory mapped passwd/groups of cache files from nscd OBS-URL: https://build.opensuse.org/request/show/90996 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/bash?expand=0&rev=85
This commit is contained in:
commit
db1e08722c
125
bash-4.2-endpw.dif
Normal file
125
bash-4.2-endpw.dif
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
--- bashline.c
|
||||||
|
+++ bashline.c 2011-11-11 13:22:00.119146416 +0000
|
||||||
|
@@ -2148,10 +2148,10 @@ bash_groupname_completion_function (text
|
||||||
|
if (gnamelen == 0 || (STREQN (gname, grent->gr_name, gnamelen)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
+ endgrent ();
|
||||||
|
|
||||||
|
if (grent == 0)
|
||||||
|
{
|
||||||
|
- endgrent ();
|
||||||
|
return ((char *)NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
--- examples/loadables/finfo.c
|
||||||
|
+++ examples/loadables/finfo.c 2011-11-11 13:21:12.319218165 +0000
|
||||||
|
@@ -269,9 +269,11 @@ struct stat *st;
|
||||||
|
printmode((int) st->st_mode);
|
||||||
|
printf("Link count: %d\n", (int) st->st_nlink);
|
||||||
|
pw = getpwuid(st->st_uid);
|
||||||
|
+ endpwent();
|
||||||
|
owner = pw ? pw->pw_name : "unknown";
|
||||||
|
printf("Uid of owner: %d (%s)\n", (int) st->st_uid, owner);
|
||||||
|
gr = getgrgid(st->st_gid);
|
||||||
|
+ endgrent();
|
||||||
|
owner = gr ? gr->gr_name : "unknown";
|
||||||
|
printf("Gid of owner: %d (%s)\n", (int) st->st_gid, owner);
|
||||||
|
printf("Device type: %d\n", (int) st->st_rdev);
|
||||||
|
@@ -348,12 +350,14 @@ int flags;
|
||||||
|
printf("%o\n", getperm(st->st_mode) & pmask);
|
||||||
|
else if (flags & OPT_UID) {
|
||||||
|
pw = getpwuid(st->st_uid);
|
||||||
|
+ endpwent();
|
||||||
|
if (flags & OPT_ASCII)
|
||||||
|
printf("%s\n", pw ? pw->pw_name : "unknown");
|
||||||
|
else
|
||||||
|
printf("%d\n", st->st_uid);
|
||||||
|
} else if (flags & OPT_GID) {
|
||||||
|
gr = getgrgid(st->st_gid);
|
||||||
|
+ endgrent();
|
||||||
|
if (flags & OPT_ASCII)
|
||||||
|
printf("%s\n", gr ? gr->gr_name : "unknown");
|
||||||
|
else
|
||||||
|
--- examples/loadables/id.c
|
||||||
|
+++ examples/loadables/id.c 2011-11-11 13:19:36.515148229 +0000
|
||||||
|
@@ -42,6 +42,7 @@
|
||||||
|
|
||||||
|
#if !defined (HAVE_GETPW_DECLS)
|
||||||
|
extern struct passwd *getpwuid ();
|
||||||
|
+extern void endpwent ();
|
||||||
|
#endif
|
||||||
|
extern struct group *getgrgid ();
|
||||||
|
|
||||||
|
@@ -146,6 +147,7 @@ inituser (uname)
|
||||||
|
builtin_error ("%s: no such user", uname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
+ endpwent ();
|
||||||
|
ruid = euid = pwd->pw_uid;
|
||||||
|
rgid = egid = pwd->pw_gid;
|
||||||
|
}
|
||||||
|
@@ -173,6 +175,7 @@ id_pruser (uid)
|
||||||
|
pwd = getpwuid (uid);
|
||||||
|
if (pwd == NULL)
|
||||||
|
r = 1;
|
||||||
|
+ endpwent ();
|
||||||
|
}
|
||||||
|
if (pwd)
|
||||||
|
printf ("%s", pwd->pw_name);
|
||||||
|
@@ -197,6 +200,7 @@ id_prgrp (gid)
|
||||||
|
grp = getgrgid (gid);
|
||||||
|
if (grp == NULL)
|
||||||
|
r = 1;
|
||||||
|
+ endgrent ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grp)
|
||||||
|
@@ -307,6 +311,8 @@ id_prall (uname)
|
||||||
|
else
|
||||||
|
printf ("(%s)", grp->gr_name);
|
||||||
|
}
|
||||||
|
+ endpwent ();
|
||||||
|
+ endgrent ();
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
--- lib/tilde/shell.c
|
||||||
|
+++ lib/tilde/shell.c 2011-11-11 13:12:35.932960442 +0000
|
||||||
|
@@ -45,7 +45,12 @@
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
|
#if !defined (HAVE_GETPW_DECLS)
|
||||||
|
+# if defined (HAVE_GETPWUID)
|
||||||
|
extern struct passwd *getpwuid ();
|
||||||
|
+# endif
|
||||||
|
+# if defined (HAVE_GETPWENT)
|
||||||
|
+extern void endpwent ();
|
||||||
|
+# endif
|
||||||
|
#endif /* !HAVE_GETPW_DECLS */
|
||||||
|
|
||||||
|
char *
|
||||||
|
@@ -62,8 +67,13 @@ get_home_dir ()
|
||||||
|
struct passwd *entry;
|
||||||
|
|
||||||
|
home_dir = (char *)NULL;
|
||||||
|
+#if defined (HAVE_GETPWUID)
|
||||||
|
entry = getpwuid (getuid ());
|
||||||
|
if (entry)
|
||||||
|
home_dir = entry->pw_dir;
|
||||||
|
+#endif
|
||||||
|
+#if defined (HAVE_GETPWENT)
|
||||||
|
+ endpwent ();
|
||||||
|
+#endif
|
||||||
|
return (home_dir);
|
||||||
|
}
|
||||||
|
--- lib/tilde/tilde.c
|
||||||
|
+++ lib/tilde/tilde.c 2011-11-11 13:10:07.375646928 +0000
|
||||||
|
@@ -61,6 +61,7 @@ extern struct passwd *getpwuid PARAMS((u
|
||||||
|
# endif
|
||||||
|
# if defined (HAVE_GETPWNAM)
|
||||||
|
extern struct passwd *getpwnam PARAMS((const char *));
|
||||||
|
+extern void endpwent ();
|
||||||
|
# endif
|
||||||
|
#endif /* !HAVE_GETPW_DECLS */
|
||||||
|
|
49
bash-4.2-nscdunmap.dif
Normal file
49
bash-4.2-nscdunmap.dif
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
--- 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 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
bash.changes
12
bash.changes
@ -1,3 +1,15 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Nov 11 15:27:12 UTC 2011 - werner@suse.de
|
||||||
|
|
||||||
|
- Avoid memory mapped /var/run/nscd/passwd at shutdown by simply
|
||||||
|
unmapping this only used area if parent is systemd or SysVinit
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Nov 11 13:45:40 UTC 2011 - werner@suse.de
|
||||||
|
|
||||||
|
- Always close get(pw|gr)func with endpw() respectivly with endgr()
|
||||||
|
to avoid memory mapped passwd/groups of cache files from nscd
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Nov 2 08:23:24 UTC 2011 - werner@suse.de
|
Wed Nov 2 08:23:24 UTC 2011 - werner@suse.de
|
||||||
|
|
||||||
|
@ -59,12 +59,14 @@ Patch2: bash-4.0-security.patch
|
|||||||
Patch3: bash-4.2-2.4.4.patch
|
Patch3: bash-4.2-2.4.4.patch
|
||||||
Patch4: bash-3.0-evalexp.patch
|
Patch4: bash-3.0-evalexp.patch
|
||||||
Patch5: bash-3.0-warn-locale.patch
|
Patch5: bash-3.0-warn-locale.patch
|
||||||
|
Patch6: bash-4.2-endpw.dif
|
||||||
Patch7: bash-3.0-decl.patch
|
Patch7: bash-3.0-decl.patch
|
||||||
Patch8: bash-4.0-async-bnc523667.dif
|
Patch8: bash-4.0-async-bnc523667.dif
|
||||||
Patch9: bash-4.0-extended_quote.patch
|
Patch9: bash-4.0-extended_quote.patch
|
||||||
Patch10: bash-3.2-printf.patch
|
Patch10: bash-3.2-printf.patch
|
||||||
Patch11: bash-4.0-loadables.dif
|
Patch11: bash-4.0-loadables.dif
|
||||||
Patch12: bash-4.1-completion.dif
|
Patch12: bash-4.1-completion.dif
|
||||||
|
Patch13: bash-4.2-nscdunmap.dif
|
||||||
Patch14: bash-4.2-sigrestart.patch
|
Patch14: bash-4.2-sigrestart.patch
|
||||||
Patch15: bash-3.2-longjmp.dif
|
Patch15: bash-3.2-longjmp.dif
|
||||||
Patch16: bash-4.0-setlocale.dif
|
Patch16: bash-4.0-setlocale.dif
|
||||||
@ -74,6 +76,7 @@ Patch21: readline-4.3-input.dif
|
|||||||
Patch22: readline-6.1-wrap.patch
|
Patch22: readline-6.1-wrap.patch
|
||||||
Patch23: readline-5.2-conf.patch
|
Patch23: readline-5.2-conf.patch
|
||||||
Patch24: readline-6.2-metamode.patch
|
Patch24: readline-6.2-metamode.patch
|
||||||
|
Patch25: readline-6.2-endpw.dif
|
||||||
Patch30: readline-6.2-destdir.patch
|
Patch30: readline-6.2-destdir.patch
|
||||||
Patch40: bash-4.1-bash.bashrc.dif
|
Patch40: bash-4.1-bash.bashrc.dif
|
||||||
Patch46: man2html-no-timestamp.patch
|
Patch46: man2html-no-timestamp.patch
|
||||||
@ -270,12 +273,14 @@ unset p
|
|||||||
%patch3 -p0 -b .2.4.4
|
%patch3 -p0 -b .2.4.4
|
||||||
%patch4 -p0 -b .evalexp
|
%patch4 -p0 -b .evalexp
|
||||||
%patch5 -p0 -b .warnlc
|
%patch5 -p0 -b .warnlc
|
||||||
|
%patch6 -p0 -b .endpw
|
||||||
%patch7 -p0 -b .decl
|
%patch7 -p0 -b .decl
|
||||||
%patch8 -p0 -b .async
|
%patch8 -p0 -b .async
|
||||||
%patch9 -p0 -b .extended_quote
|
%patch9 -p0 -b .extended_quote
|
||||||
%patch10 -p0 -b .printf
|
%patch10 -p0 -b .printf
|
||||||
%patch11 -p0 -b .plugins
|
%patch11 -p0 -b .plugins
|
||||||
%patch12 -p0 -b .completion
|
%patch12 -p0 -b .completion
|
||||||
|
%patch13 -p0 -b .nscdunmap
|
||||||
%patch14 -p0 -b .sigrestart
|
%patch14 -p0 -b .sigrestart
|
||||||
%patch15 -p0 -b .longjmp
|
%patch15 -p0 -b .longjmp
|
||||||
%patch16 -p0 -b .setlocale
|
%patch16 -p0 -b .setlocale
|
||||||
@ -284,6 +289,7 @@ unset p
|
|||||||
%patch22 -p0 -b .wrap
|
%patch22 -p0 -b .wrap
|
||||||
%patch23 -p0 -b .conf
|
%patch23 -p0 -b .conf
|
||||||
%patch24 -p0 -b .metamode
|
%patch24 -p0 -b .metamode
|
||||||
|
%patch25 -p0 -b .endpw
|
||||||
%patch40 -p0 -b .bashrc
|
%patch40 -p0 -b .bashrc
|
||||||
%patch46 -p0 -b .notimestamp
|
%patch46 -p0 -b .notimestamp
|
||||||
%patch0 -p0 -b .0
|
%patch0 -p0 -b .0
|
||||||
@ -297,6 +303,7 @@ done
|
|||||||
%patch22 -p2 -b .wrap
|
%patch22 -p2 -b .wrap
|
||||||
%patch23 -p2 -b .conf
|
%patch23 -p2 -b .conf
|
||||||
%patch24 -p2 -b .metamode
|
%patch24 -p2 -b .metamode
|
||||||
|
%patch25 -p2 -b .endpw
|
||||||
%patch30 -p0 -b .destdir
|
%patch30 -p0 -b .destdir
|
||||||
%patch20 -p0 -b .0
|
%patch20 -p0 -b .0
|
||||||
|
|
||||||
|
65
readline-6.2-endpw.dif
Normal file
65
readline-6.2-endpw.dif
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
--- lib/readline/complete.c
|
||||||
|
+++ lib/readline/complete.c 2011-11-11 13:16:05.635147670 +0000
|
||||||
|
@@ -83,6 +83,7 @@ typedef int QSFUNC ();
|
||||||
|
defined. */
|
||||||
|
#if defined (HAVE_GETPWENT) && (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE))
|
||||||
|
extern struct passwd *getpwent PARAMS((void));
|
||||||
|
+extern void endpwent ();
|
||||||
|
#endif /* HAVE_GETPWENT && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */
|
||||||
|
|
||||||
|
/* If non-zero, then this is the address of a function to call when
|
||||||
|
@@ -2049,12 +2050,12 @@ rl_username_completion_function (text, s
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+#if defined (HAVE_GETPWENT)
|
||||||
|
+ endpwent ();
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
if (entry == 0)
|
||||||
|
{
|
||||||
|
-#if defined (HAVE_GETPWENT)
|
||||||
|
- endpwent ();
|
||||||
|
-#endif
|
||||||
|
return ((char *)NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
--- lib/readline/shell.c
|
||||||
|
+++ lib/readline/shell.c 2011-11-11 13:14:02.683147026 +0000
|
||||||
|
@@ -61,9 +61,14 @@
|
||||||
|
#include "rlshell.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
|
-#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
|
||||||
|
+#if !defined (HAVE_GETPW_DECLS)
|
||||||
|
+# if defined (HAVE_GETPWUID)
|
||||||
|
extern struct passwd *getpwuid PARAMS((uid_t));
|
||||||
|
-#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
|
||||||
|
+# endif
|
||||||
|
+# if defined (HAVE_GETPWENT)
|
||||||
|
+extern void endpwent ();
|
||||||
|
+# endif
|
||||||
|
+#endif /* !HAVE_GETPW_DECLS */
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
# define NULL 0
|
||||||
|
@@ -168,6 +173,9 @@ sh_get_home_dir ()
|
||||||
|
if (entry)
|
||||||
|
home_dir = entry->pw_dir;
|
||||||
|
#endif
|
||||||
|
+#if defined (HAVE_GETPWENT)
|
||||||
|
+ endpwent ();
|
||||||
|
+#endif
|
||||||
|
return (home_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
--- lib/readline/tilde.c
|
||||||
|
+++ lib/readline/tilde.c 2011-11-11 13:09:48.843646721 +0000
|
||||||
|
@@ -61,6 +61,7 @@ extern struct passwd *getpwuid PARAMS((u
|
||||||
|
# endif
|
||||||
|
# if defined (HAVE_GETPWNAM)
|
||||||
|
extern struct passwd *getpwnam PARAMS((const char *));
|
||||||
|
+extern void endpwent ();
|
||||||
|
# endif
|
||||||
|
#endif /* !HAVE_GETPW_DECLS */
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user