From 4821cc5fe36201c550520b80dc661ec4f45cae8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20P=C3=B6nk=C3=A4nen?= Date: Thu, 17 Mar 2022 12:29:11 +0200 Subject: [PATCH] GUACAMOLE-1555: Call openlog() after client plugin unload. This fixes segfaults from guacd_log() in cases where the client plugin has called openlog() with a non-NULL ident string. --- src/guacd/proc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/guacd/proc.c b/src/guacd/proc.c index 9641ac05a..0d9c0c175 100644 --- a/src/guacd/proc.c +++ b/src/guacd/proc.c @@ -42,6 +42,7 @@ #include #include #include +#include /** * Parameters for the user thread. @@ -353,6 +354,12 @@ static void guacd_exec_proc(guacd_proc* proc, const char* protocol) { guacd_log(GUAC_LOG_DEBUG, "Requesting termination of client..."); result = guacd_timed_client_free(client, GUACD_CLIENT_FREE_TIMEOUT); + /* Reopen syslog now that client plugins have been unloaded. This fixes + guacd_log() segfaults in cases where the client plugins have called + openlog() causing syslog ident string to point to the plugin's + memory region. */ + openlog(GUACD_LOG_NAME, LOG_PID, LOG_DAEMON); + /* If client was unable to be freed, warn and forcibly kill */ if (result) { guacd_log(GUAC_LOG_WARNING, "Client did not terminate in a timely "