diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2010-01-11 23:09:47 +0000 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2010-01-12 09:56:48 -0800 |
commit | ecf015a4e78b96af913c1620d542c8e356f2a3d0 (patch) | |
tree | 90b8da868e907ed07a7b25c2878d45a4c49b5832 | |
parent | 9142a99cedc99277319e56f132077c1263e1eea8 (diff) |
Call openlog(3) early
Before this change, openlog(3) used to be called by greeter which could
be built as a dynamically loadable plugin. In the latter case, the
ident string passed to openlog(3) resides in a dynamically mapped
memory region that is unmapped later when the plugin is unloaded.
This can cause fatal problems in some environments. For example, in
any GNU/Linux system with PAM support enabled an implicit syslog(3)
call made by a PAM module after plugin unload causes attempt to access
already unmapped memory, followed by instant crash.
It is a common practice to call openlog(3) before the first syslog(3)
call, including implicit calls that could be made e.g. by PAM.
Also, openlog(3) LOG_ODELAY flag is redundant.
Fixes ALT Linux Bug #22362 <https://bugzilla.altlinux.org/show_bug.cgi?id=22362>
Fixes FreeDesktop Bug #24589 <https://bugs.freedesktop.org/show_bug.cgi?id=24589>
Reported-by: Martin Mokrejš <mmokrejs@ribosome.natur.cuni.cz>
Reported-by: Denis Kirienko <dk@altlinux.org>
Patch-by: Oleg Zenin <tt@compas.ihep.su>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r-- | dm.c | 13 | ||||
-rw-r--r-- | greeter/greet.c | 3 |
2 files changed, 13 insertions, 3 deletions
@@ -75,6 +75,16 @@ from The Open Group. # endif #endif +#if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG_H) +# define USE_SYSLOG +# include <syslog.h> +# ifndef LOG_AUTHPRIV +# define LOG_AUTHPRIV LOG_AUTH +# endif +# ifndef LOG_PID +# define LOG_PID 0 +# endif +#endif #if defined(SVR4) && !defined(sun) extern FILE *fdopen(); @@ -749,6 +759,9 @@ StartDisplay (struct display *d) CleanUpChild (); (void) Signal (SIGPIPE, SIG_IGN); } +#ifdef USE_SYSLOG + openlog("xdm", LOG_PID, LOG_AUTHPRIV); +#endif LoadSessionResources (d); SetAuthorization (d); if (!WaitForServer (d)) diff --git a/greeter/greet.c b/greeter/greet.c index 17d21c8..61c7a52 100644 --- a/greeter/greet.c +++ b/greeter/greet.c @@ -489,9 +489,6 @@ greet_user_rtn GreetUser( LogError ("Cannot reopen display %s for greet window\n", d->name); exit (RESERVER_DISPLAY); } -#ifdef USE_SYSLOG - openlog("xdm", LOG_ODELAY|LOG_PID, LOG_AUTHPRIV); -#endif for (;;) { #ifdef USE_PAM |