Skip to content
Snippets Groups Projects
Commit bec35da8 authored by Marc G. Fournier's avatar Marc G. Fournier
Browse files

Add error check on getenv("DATADIR")

Add code to set DATADIR in postmaster.c if -D is used
parent a68a132a
No related branches found
No related tags found
No related merge requests found
...@@ -25,9 +25,13 @@ char* crypt_getpwdfilename() { ...@@ -25,9 +25,13 @@ char* crypt_getpwdfilename() {
static char* filename = NULL; static char* filename = NULL;
if (!filename) { if (!filename) {
char* env; char* env = NULL;
env = getenv("PGDATA"); env = getenv("PGDATA");
if(env == NULL) {
elog(FATAL, "crypt.c: PGDATA is not defined");
exit(-1);
}
filename = (char*)malloc(strlen(env) + strlen(CRYPT_PWD_FILE) + 2); filename = (char*)malloc(strlen(env) + strlen(CRYPT_PWD_FILE) + 2);
sprintf(filename, "%s/%s", env, CRYPT_PWD_FILE); sprintf(filename, "%s/%s", env, CRYPT_PWD_FILE);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.63 1997/12/04 00:27:17 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.64 1997/12/07 20:57:45 scrappy Exp $
* *
* NOTES * NOTES
* *
...@@ -332,6 +332,11 @@ PostmasterMain(int argc, char *argv[]) ...@@ -332,6 +332,11 @@ PostmasterMain(int argc, char *argv[])
case 'D': case 'D':
/* Set PGDATA from the command line. */ /* Set PGDATA from the command line. */
DataDir = optarg; DataDir = optarg;
{
char envEntry[2 * ARGV_SIZE];
sprintf(envEntry, "PGDATA=%s", DataDir);
putenv(envEntry);
}
break; break;
case 'd': case 'd':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment