X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Flog.c;h=ddd71377e2f75bb335db55a2e37948af10b32e15;hb=d953610fa77ec9a08fad9c1a183181079a79674e;hp=f9b0722d8fc40c579efc505728df4da0ac90420e;hpb=92b0827a90559a266bd00662d842b643ac8bdc81;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/log.c b/src/src/log.c index f9b0722d8..ddd71377e 100644 --- a/src/src/log.c +++ b/src/src/log.c @@ -47,6 +47,8 @@ static BOOL path_inspected = FALSE; static int logging_mode = LOG_MODE_FILE; static uschar *file_path = US""; +static size_t pid_position[2]; + /* These should be kept in-step with the private delivery error number definitions in macros.h */ @@ -132,7 +134,7 @@ can get here if there is a failure to open the panic log.) Arguments: priority syslog priority - s the string to be written + s the string to be written, the string may be modified! Returns: nothing */ @@ -146,6 +148,8 @@ int linecount = 0; if (running_in_test_harness) return; if (!syslog_timestamp) s += log_timezone? 26 : 20; +if (!syslog_pid && LOGGING(pid)) + memmove(s + pid_position[0], s + pid_position[1], pid_position[1] - pid_position[0]); len = Ustrlen(s); @@ -663,6 +667,14 @@ while ((t = string_nextinlist(&tt, &sep, log_buffer, LOG_BUFFER_SIZE))) } +void +mainlog_close(void) +{ +if (mainlogfd < 0) return; +(void)close(mainlogfd); +mainlogfd = -1; +mainlog_inode = 0; +} /************************************************* * Write message to log file * @@ -692,7 +704,7 @@ If it is not, don't try to write to the log because permission will probably be denied. Avoid actually writing to the logs when exim is called with -bv or -bt to -test an address, but take other actions, such as panicing. +test an address, but take other actions, such as panicking. In Exim proper, the buffer for building the message is got at start-up, so that nothing gets done if it can't be got. However, some functions that are also @@ -897,7 +909,9 @@ while(*ptr) ptr++; if (LOGGING(pid)) { sprintf(CS ptr, "[%d] ", (int)getpid()); + if (!syslog_pid) pid_position[0] = ptr - log_buffer; /* remember begin … */ while (*ptr) ptr++; + if (!syslog_pid) pid_position[1] = ptr - log_buffer; /* … and end+1 of the PID */ } if (really_exim && message_id[0] != 0) @@ -971,14 +985,14 @@ been opened, but we don't want to keep on writing to it for too long after it has been renamed. Therefore, do a stat() and see if the inode has changed, and if so, re-open. */ -if ((flags & LOG_MAIN) != 0 && - (selector == 0 || (selector & log_selector[0]) != 0)) +if ( flags & LOG_MAIN + && (!selector || selector & log_selector[0])) { - if ((logging_mode & LOG_MODE_SYSLOG) != 0 && - (syslog_duplication || (flags & (LOG_REJECT|LOG_PANIC)) == 0)) + if ( logging_mode & LOG_MODE_SYSLOG + && (syslog_duplication || !(flags & (LOG_REJECT|LOG_PANIC)))) write_syslog(LOG_INFO, log_buffer); - if ((logging_mode & LOG_MODE_FILE) != 0) + if (logging_mode & LOG_MODE_FILE) { struct stat statbuf; @@ -1004,14 +1018,8 @@ if ((flags & LOG_MAIN) != 0 && happening. */ if (mainlogfd >= 0) - { if (Ustat(mainlog_name, &statbuf) < 0 || statbuf.st_ino != mainlog_inode) - { - (void)close(mainlogfd); - mainlogfd = -1; - mainlog_inode = 0; - } - } + mainlog_close(); /* If the log is closed, open it. Then write the line. */