aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-06-02 03:48:00 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-06-02 03:48:00 +0000
commiteaa70a3891a39634e425e23aa7a4b5969333c8dc (patch)
tree54a3d6a6950ba61487689fc166ac46724e106cda /src
parentc4fdebd926bc75b1d4d260a84a974f6693115fe4 (diff)
downloadpostgresql-eaa70a3891a39634e425e23aa7a4b5969333c8dc.tar.gz
postgresql-eaa70a3891a39634e425e23aa7a4b5969333c8dc.zip
Fix initdb to reject a relative path for -X (--xlogdir) argument. This
doesn't work, and the real reason why not is it's unclear where the path is relative to (initdb's CWD, or the data directory?). We could make an arbitrary decision, but it seems best to make the user be unambiguous. Per gripe from Devrim.
Diffstat (limited to 'src')
-rw-r--r--src/bin/initdb/initdb.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 193318d5f9b..7e29f9ddd5d 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.155 2008/02/29 23:31:20 adunstan Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.156 2008/06/02 03:48:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3002,8 +3002,13 @@ main(int argc, char *argv[])
{
char *linkloc;
- linkloc = (char *) pg_malloc(strlen(pg_data) + 8 + 2);
- sprintf(linkloc, "%s/pg_xlog", pg_data);
+ /* clean up xlog directory name, check it's absolute */
+ canonicalize_path(xlog_dir);
+ if (!is_absolute_path(xlog_dir))
+ {
+ fprintf(stderr, _("%s: xlog directory location must be an absolute path\n"), progname);
+ exit_nicely();
+ }
/* check if the specified xlog directory is empty */
switch (check_data_dir(xlog_dir))
@@ -3021,9 +3026,7 @@ main(int argc, char *argv[])
exit_nicely();
}
else
- {
check_ok();
- }
made_new_xlogdir = true;
break;
@@ -3053,7 +3056,7 @@ main(int argc, char *argv[])
_("If you want to store the transaction log there, either\n"
"remove or empty the directory \"%s\".\n"),
xlog_dir);
- exit(1); /* no further message needed */
+ exit_nicely();
default:
/* Trouble accessing directory */
@@ -3062,6 +3065,10 @@ main(int argc, char *argv[])
exit_nicely();
}
+ /* form name of the place where the symlink must go */
+ linkloc = (char *) pg_malloc(strlen(pg_data) + 8 + 1);
+ sprintf(linkloc, "%s/pg_xlog", pg_data);
+
#ifdef HAVE_SYMLINK
if (symlink(xlog_dir, linkloc) != 0)
{