From ecf015a4e78b96af913c1620d542c8e356f2a3d0 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 11 Jan 2010 23:09:47 +0000 Subject: Call openlog(3) early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Fixes FreeDesktop Bug #24589 Reported-by: Martin Mokrejš Reported-by: Denis Kirienko Patch-by: Oleg Zenin Signed-off-by: Dmitry V. Levin Signed-off-by: Alan Coopersmith --- dm.c | 13 +++++++++++++ greeter/greet.c | 3 --- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dm.c b/dm.c index abe4453..8186424 100644 --- a/dm.c +++ b/dm.c @@ -75,6 +75,16 @@ from The Open Group. # endif #endif +#if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG_H) +# define USE_SYSLOG +# include +# 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 -- cgit v1.2.3