From 58b31be6270659d4405efecb9c3bcd42a62def89 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 22 May 2024 11:44:41 +0200 Subject: [PATCH] Fix late vncsession logging The syslog file descriptor will be closed when we are cleaning up in preparation for running the vncserver script, so we need to explicitly reopen things in case we need to log errors. At the same time, try to be polite and explicitly close the log when appropriate. --- unix/vncserver/vncsession.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/unix/vncserver/vncsession.c b/unix/vncserver/vncsession.c index f1018512..9022fe56 100644 --- a/unix/vncserver/vncsession.c +++ b/unix/vncserver/vncsession.c @@ -472,6 +472,10 @@ close_fds(void) _exit(EX_OSERR); } + // We'll close the file descriptor that the logging uses, so might + // as well do it cleanly + closelog(); + while ((entry = readdir(dir)) != NULL) { int fd; fd = atoi(entry->d_name); @@ -545,9 +549,12 @@ run_script(const char *username, const char *display, char **envp) child_argv[1] = display; child_argv[2] = NULL; + closelog(); + execvp(child_argv[0], (char*const*)child_argv); // execvp failed + openlog("vncsession", LOG_PID, LOG_AUTH); syslog(LOG_CRIT, "execvp: %s", strerror(errno)); _exit(EX_OSERR); -- 2.39.5