diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index 1d806a2732be35a5406a23224147ea643776dccb..37844a03a94d670cdc53e448c8fe33e531b8fc03 100644 --- a/src/backend/utils/misc/database.c +++ b/src/backend/utils/misc/database.c @@ -8,7 +8,7 @@ * * * 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 @@ 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. * diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 22b42042ad71904110dcf2e1af21cb9bca35c82e..67be1137fc99db375b5ed10eb7ba9de6031f6db6 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * 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 * some of the information in this file should be moved to @@ -231,7 +231,6 @@ extern char *DatabasePath; /* in utils/misc/database.c */ extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path); -extern char *ExpandDatabasePath(const char *path); /* now in utils/init/miscinit.c */ extern void SetDatabasePath(const char *path);