aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-11-22 11:23:28 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2012-11-22 11:24:46 -0500
commit430b47f382609c567bd87ff28a81ea5055d173d5 (patch)
treea1d6fe39ad4b7970dbf9fcb69a3161ca9b7d5fa9
parentdda8b87b6a470249e9d4e3701849b7bd830bb96c (diff)
downloadpostgresql-430b47f382609c567bd87ff28a81ea5055d173d5.tar.gz
postgresql-430b47f382609c567bd87ff28a81ea5055d173d5.zip
Fix pg_resetxlog to use correct path to postmaster.pid.
Since we've already chdir'd into the data directory, the file should be referenced as just "postmaster.pid", without prefixing the directory path. This is harmless in the normal case where an absolute PGDATA path is used, but quite dangerous if a relative path is specified, since the program might then fail to notice an active postmaster. Reported by Hari Babu. This got broken in my commit eb5949d190e80360386113fde0f05854f0c9824d, so patch all active versions.
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index 5ecf5c49304..80e826897c7 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -95,7 +95,6 @@ main(int argc, char *argv[])
char *endptr3;
char *DataDir;
int fd;
- char path[MAXPGPATH];
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_resetxlog"));
@@ -270,13 +269,12 @@ main(int argc, char *argv[])
* Check for a postmaster lock file --- if there is one, refuse to
* proceed, on grounds we might be interfering with a live installation.
*/
- snprintf(path, MAXPGPATH, "%s/postmaster.pid", DataDir);
-
- if ((fd = open(path, O_RDONLY, 0)) < 0)
+ if ((fd = open("postmaster.pid", O_RDONLY, 0)) < 0)
{
if (errno != ENOENT)
{
- fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), progname, path, strerror(errno));
+ fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
+ progname, "postmaster.pid", strerror(errno));
exit(1);
}
}
@@ -284,7 +282,7 @@ main(int argc, char *argv[])
{
fprintf(stderr, _("%s: lock file \"%s\" exists\n"
"Is a server running? If not, delete the lock file and try again.\n"),
- progname, path);
+ progname, "postmaster.pid");
exit(1);
}