summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-10-14 16:41:28 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-10-14 16:41:28 +0000
commita4baf229a4298bf478c23ca74685f8703dfd3517 (patch)
treee61c17853f3acbdb02c352af2158fe59ccf78c0c
parente257f28db012b0c5d2056fc0456f5c1e80e989b6 (diff)
Pass a strdup'd ident string to openlog(), to ensure that reallocation
of GUC memory doesn't cause us to start emitting a bogus ident string. Per report from Han Holl. Also some trivial code cleanup in write_syslog.
-rw-r--r--src/backend/utils/error/elog.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 94f7f90dc4b..c1b0fa1faca 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.125 2003/10/17 16:49:03 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.125.2.1 2005/10/14 16:41:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -923,7 +923,6 @@ write_syslog(int level, const char *line)
{
static bool openlog_done = false;
static unsigned long seq = 0;
- static int syslog_fac = LOG_LOCAL0;
int len = strlen(line);
@@ -932,6 +931,9 @@ write_syslog(int level, const char *line)
if (!openlog_done)
{
+ int syslog_fac = LOG_LOCAL0;
+ char *syslog_ident;
+
if (strcasecmp(Syslog_facility, "LOCAL0") == 0)
syslog_fac = LOG_LOCAL0;
if (strcasecmp(Syslog_facility, "LOCAL1") == 0)
@@ -948,7 +950,10 @@ write_syslog(int level, const char *line)
syslog_fac = LOG_LOCAL6;
if (strcasecmp(Syslog_facility, "LOCAL7") == 0)
syslog_fac = LOG_LOCAL7;
- openlog(Syslog_ident, LOG_PID | LOG_NDELAY, syslog_fac);
+ syslog_ident = strdup(Syslog_ident);
+ if (syslog_ident == NULL) /* out of memory already!? */
+ syslog_ident = "postgres";
+ openlog(syslog_ident, LOG_PID | LOG_NDELAY, syslog_fac);
openlog_done = true;
}