Commit bfa53042 authored by Tom Lane's avatar Tom Lane

Remove ExpandDatabasePath(), which is unused and must have been so since

7.1, because the path interpretation it embodies has been wrong since 7.1.
parent 58ae3cf1
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/database.c,v 1.59 2003/11/29 19:52:03 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/database.c,v 1.60 2004/01/22 20:57:39 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,91 +28,6 @@ ...@@ -28,91 +28,6 @@
static bool PhonyHeapTupleSatisfiesNow(HeapTupleHeader tuple); static bool PhonyHeapTupleSatisfiesNow(HeapTupleHeader tuple);
/*
* ExpandDatabasePath resolves a proposed database path (obtained from
* pg_database.datpath) to a full absolute path for further consumption.
* NULL means an error, which the caller should process. One reason for
* such an error would be an absolute alternative path when no absolute
* paths are allowed.
*/
char *
ExpandDatabasePath(const char *dbpath)
{
char buf[MAXPGPATH];
const char *cp;
int len;
AssertArg(dbpath);
Assert(DataDir);
if (strlen(dbpath) >= MAXPGPATH)
return NULL; /* ain't gonna fit nohow */
/* leading path delimiter? then already absolute path */
if (is_absolute_path(dbpath))
{
#ifdef ALLOW_ABSOLUTE_DBPATHS
cp = last_path_separator(dbpath);
len = cp - dbpath;
strncpy(buf, dbpath, len);
snprintf(&buf[len], MAXPGPATH - len, "/base/%s", (cp + 1));
#else
return NULL;
#endif
}
/* path delimiter somewhere? then has leading environment variable */
else if ((cp = first_path_separator(dbpath)) != NULL)
{
const char *envvar;
len = cp - dbpath;
strncpy(buf, dbpath, len);
buf[len] = '\0';
envvar = getenv(buf);
if (envvar == NULL)
return NULL;
snprintf(buf, sizeof(buf), "%s/base/%s", envvar, (cp + 1));
}
else
{
/* no path delimiter? then add the default path prefix */
snprintf(buf, sizeof(buf), "%s/base/%s", DataDir, dbpath);
}
/*
* check for illegal characters in dbpath these should really throw an
* error, shouldn't they? or else all callers need to test for NULL
*/
for (cp = buf; *cp; cp++)
{
/*
* The following characters will not be allowed anywhere in the
* database path. (Do not include the slash or '.' here.)
*/
char illegal_dbpath_chars[] =
"\001\002\003\004\005\006\007\010"
"\011\012\013\014\015\016\017\020"
"\021\022\023\024\025\026\027\030"
"\031\032\033\034\035\036\037"
"'`";
const char *cx;
for (cx = illegal_dbpath_chars; *cx; cx++)
if (*cp == *cx)
return NULL;
/* don't allow access to parent dirs */
if (strncmp(cp, "/../", 4) == 0)
return NULL;
}
return pstrdup(buf);
} /* ExpandDatabasePath() */
/* -------------------------------- /* --------------------------------
* GetRawDatabaseInfo() -- Find the OID and path of the database. * GetRawDatabaseInfo() -- Find the OID and path of the database.
* *
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.144 2004/01/09 23:29:31 momjian Exp $ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.145 2004/01/22 20:57:39 tgl Exp $
* *
* NOTES * NOTES
* some of the information in this file should be moved to * some of the information in this file should be moved to
...@@ -231,7 +231,6 @@ extern char *DatabasePath; ...@@ -231,7 +231,6 @@ extern char *DatabasePath;
/* in utils/misc/database.c */ /* in utils/misc/database.c */
extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path); extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path);
extern char *ExpandDatabasePath(const char *path);
/* now in utils/init/miscinit.c */ /* now in utils/init/miscinit.c */
extern void SetDatabasePath(const char *path); extern void SetDatabasePath(const char *path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment