Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteaa70a3

Browse files
committed
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 pathis relative to (initdb's CWD, or the data directory?). We could make anarbitrary decision, but it seems best to make the user be unambiguous.Per gripe from Devrim.
1 parentc4fdebd commiteaa70a3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.155 2008/02/29 23:31:20 adunstan Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.156 2008/06/02 03:48:00 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -3002,8 +3002,13 @@ main(int argc, char *argv[])
30023002
{
30033003
char*linkloc;
30043004

3005-
linkloc= (char*)pg_malloc(strlen(pg_data)+8+2);
3006-
sprintf(linkloc,"%s/pg_xlog",pg_data);
3005+
/* clean up xlog directory name, check it's absolute */
3006+
canonicalize_path(xlog_dir);
3007+
if (!is_absolute_path(xlog_dir))
3008+
{
3009+
fprintf(stderr,_("%s: xlog directory location must be an absolute path\n"),progname);
3010+
exit_nicely();
3011+
}
30073012

30083013
/* check if the specified xlog directory is empty */
30093014
switch (check_data_dir(xlog_dir))
@@ -3021,9 +3026,7 @@ main(int argc, char *argv[])
30213026
exit_nicely();
30223027
}
30233028
else
3024-
{
30253029
check_ok();
3026-
}
30273030

30283031
made_new_xlogdir= true;
30293032
break;
@@ -3053,7 +3056,7 @@ main(int argc, char *argv[])
30533056
_("If you want to store the transaction log there, either\n"
30543057
"remove or empty the directory \"%s\".\n"),
30553058
xlog_dir);
3056-
exit(1);/* no further message needed */
3059+
exit_nicely();
30573060

30583061
default:
30593062
/* Trouble accessing directory */
@@ -3062,6 +3065,10 @@ main(int argc, char *argv[])
30623065
exit_nicely();
30633066
}
30643067

3068+
/* form name of the place where the symlink must go */
3069+
linkloc= (char*)pg_malloc(strlen(pg_data)+8+1);
3070+
sprintf(linkloc,"%s/pg_xlog",pg_data);
3071+
30653072
#ifdefHAVE_SYMLINK
30663073
if (symlink(xlog_dir,linkloc)!=0)
30673074
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp