* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.214 2004/07/11 00:18:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.215 2004/07/11 21:34:00 momjian Exp $
*
*--------------------------------------------------------------------
*/
static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
static bool assign_log_stats(bool newval, bool doit, GucSource source);
static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);
+static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);
static void ReadConfigFile(char *filename, GucContext context);
"the specified file.")
},
&Dynamic_library_path,
- "$libdir", NULL, NULL
+ "$libdir", assign_canonical_path, NULL
},
{
GUC_LIST_INPUT | GUC_LIST_QUOTE
},
&preload_libraries_string,
- "", NULL, NULL
+ "", assign_canonical_path, NULL
},
{
NULL
},
&UnixSocketDir,
- "", NULL, NULL
+ "", assign_canonical_path, NULL
},
{
{
{"pgdata", PGC_POSTMASTER, 0, gettext_noop("Sets the location of the data directory"), NULL},
&guc_pgdata,
- NULL, NULL, NULL
+ NULL, assign_canonical_path, NULL
},
{
{"hba_conf", PGC_SIGHUP, 0, gettext_noop("Sets the location of the \"hba\" configuration file"), NULL},
&guc_hbafile,
- NULL, NULL, NULL
+ NULL, assign_canonical_path, NULL
},
{
{"ident_conf", PGC_SIGHUP, 0, gettext_noop("Sets the location of the \"ident\" configuration file"), NULL},
&guc_identfile,
- NULL, NULL, NULL
+ NULL, assign_canonical_path, NULL
},
{
{"external_pidfile", PGC_POSTMASTER, 0, gettext_noop("Writes the postmaster PID to the specified file"), NULL},
&external_pidfile,
- NULL, NULL, NULL
+ NULL, assign_canonical_path, NULL
},
/* End-of-list marker */
}
static const char *
-assign_client_min_messages(const char *newval,
- bool doit, GucSource source)
+assign_client_min_messages(const char *newval, bool doit, GucSource source)
{
return (assign_msglvl(&client_min_messages, newval, doit, source));
}
return true;
}
+static const char *
+assign_canonical_path(const char *newval, bool doit, GucSource source)
+{
+
+ if (doit)
+ {
+ /* We have to create a new pointer to force the change */
+ char *canon_val = guc_strdup(FATAL, newval);
+ canonicalize_path(canon_val);
+ return canon_val;
+ }
+ else
+ return newval;
+}
+
#include "guc-file.c"
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.22 2004/07/11 02:59:42 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.23 2004/07/11 21:34:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif
const static char *relative_path(const char *bin_path, const char *other_path);
+static void make_relative(const char *my_exec_path, const char *p, char *ret_path);
static void trim_directory(char *path);
static void trim_trailing_separator(char *path);
(p)++; \
}
-/* Macro creates a relative path */
-#define MAKE_RELATIVE \
-do { \
- StrNCpy(path, my_exec_path, MAXPGPATH); \
- trim_directory(path); \
- trim_directory(path); \
- snprintf(ret_path, MAXPGPATH, "%s/%s", path, p); \
-} while (0)
-
/*
* first_dir_separator
*/
void
get_share_path(const char *my_exec_path, char *ret_path)
{
- char path[MAXPGPATH];
const char *p;
if ((p = relative_path(PGBINDIR, PGSHAREDIR)))
- MAKE_RELATIVE;
+ make_relative(my_exec_path, p, ret_path);
else
StrNCpy(ret_path, PGSHAREDIR, MAXPGPATH);
+ canonicalize_path(ret_path);
}
void
get_etc_path(const char *my_exec_path, char *ret_path)
{
- char path[MAXPGPATH];
const char *p;
if ((p = relative_path(PGBINDIR, SYSCONFDIR)))
- MAKE_RELATIVE;
+ make_relative(my_exec_path, p, ret_path);
else
StrNCpy(ret_path, SYSCONFDIR, MAXPGPATH);
+ canonicalize_path(ret_path);
}
void
get_include_path(const char *my_exec_path, char *ret_path)
{
- char path[MAXPGPATH];
const char *p;
if ((p = relative_path(PGBINDIR, INCLUDEDIR)))
- MAKE_RELATIVE;
+ make_relative(my_exec_path, p, ret_path);
else
StrNCpy(ret_path, INCLUDEDIR, MAXPGPATH);
+ canonicalize_path(ret_path);
}
void
get_pkginclude_path(const char *my_exec_path, char *ret_path)
{
- char path[MAXPGPATH];
const char *p;
if ((p = relative_path(PGBINDIR, PKGINCLUDEDIR)))
- MAKE_RELATIVE;
+ make_relative(my_exec_path, p, ret_path);
else
StrNCpy(ret_path, PKGINCLUDEDIR, MAXPGPATH);
+ canonicalize_path(ret_path);
}
void
get_pkglib_path(const char *my_exec_path, char *ret_path)
{
- char path[MAXPGPATH];
const char *p;
if ((p = relative_path(PGBINDIR, PKGLIBDIR)))
- MAKE_RELATIVE;
+ make_relative(my_exec_path, p, ret_path);
else
StrNCpy(ret_path, PKGLIBDIR, MAXPGPATH);
+ canonicalize_path(ret_path);
}
void
get_locale_path(const char *my_exec_path, char *ret_path)
{
- char path[MAXPGPATH];
const char *p;
if ((p = relative_path(PGBINDIR, LOCALEDIR)))
- MAKE_RELATIVE;
+ make_relative(my_exec_path, p, ret_path);
else
StrNCpy(ret_path, LOCALEDIR, MAXPGPATH);
+ canonicalize_path(ret_path);
}
{
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
+ canonicalize_path(env_path);
putenv(strdup(env_path));
}
#endif
/* set for libpq to use */
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
+ canonicalize_path(env_path);
putenv(strdup(env_path));
}
}
+/*
+ * make_relative - adjust path to be relative to bin/
+ */
+static void
+make_relative(const char *my_exec_path, const char *p, char *ret_path)
+{
+ char path[MAXPGPATH];
+
+ StrNCpy(path, my_exec_path, MAXPGPATH);
+ trim_directory(path);
+ trim_directory(path);
+ snprintf(ret_path, MAXPGPATH, "%s/%s", path, p);
+}
+
/*
* relative_path
char *p = path + strlen(path);
#ifdef WIN32
- /* Skip over network and drive specifiers for win32 */
+ /*
+ * Skip over network and drive specifiers for win32.
+ * Set 'path' to point to the last character to keep.
+ */
if (strlen(path) >= 2)
{
if (IS_DIR_SEP(path[0]) && IS_DIR_SEP(path[1]))