explicit_config.patch.72b4

text/plain

Filename: explicit_config.patch.72b4
Type: text/plain
Part: 0
Message: Explicit config patch 7.2B4
diff -r -u postgresql-7.2b4/src/backend/libpq/hba.c postgresql-7.2b4_config/src/backend/libpq/hba.c
--- postgresql-7.2b4/src/backend/libpq/hba.c	Sun Nov 11 23:29:23 2001
+++ postgresql-7.2b4_config/src/backend/libpq/hba.c	Sun Dec 16 08:27:06 2001
@@ -31,6 +31,8 @@
 #include <unistd.h>
 
 #include "libpq/libpq.h"
+#include "utils/guc.h"
+
 #include "miscadmin.h"
 #include "nodes/pg_list.h"
 #include "storage/fd.h"
@@ -476,11 +478,20 @@
 	{
 		char	   *conf_file;	/* The name of the config file we have to
 								 * read */
-
-		/* put together the full pathname to the config file */
-		bufsize = (strlen(DataDir) + strlen(CONF_FILE) + 2) * sizeof(char);
-		conf_file = (char *) palloc(bufsize);
-		snprintf(conf_file, bufsize, "%s/%s", DataDir, CONF_FILE);
+		/* Explicit HBA in config file */
+		if(explicit_hbaconfig && strlen(explicit_hbaconfig))
+		{
+			bufsize = strlen(explicit_hbaconfig)+1;
+			conf_file = (char *) palloc(bufsize);
+			strcpy(conf_file, explicit_hbaconfig);
+		}
+		else
+		{
+			/* put together the full pathname to the config file */
+			bufsize = (strlen(DataDir) + strlen(CONF_FILE) + 2) * sizeof(char);
+			conf_file = (char *) palloc(bufsize);
+			snprintf(conf_file, bufsize, "%s/%s", DataDir, CONF_FILE);
+		}
 
 		file = AllocateFile(conf_file, "r");
 		if (file == NULL)
diff -r -u postgresql-7.2b4/src/backend/postmaster/postmaster.c postgresql-7.2b4_config/src/backend/postmaster/postmaster.c
--- postgresql-7.2b4/src/backend/postmaster/postmaster.c	Tue Dec  4 11:17:48 2001
+++ postgresql-7.2b4_config/src/backend/postmaster/postmaster.c	Sun Dec 16 09:14:30 2001
@@ -419,10 +419,13 @@
 	 * with the wrong argument. Death and destruction will occur.
 	 */
 	opterr = 1;
-	while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
+	while ((opt = getopt(argc, argv, "A:a:B:b:c:C:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
 	{
 		switch (opt)
 		{
+			case 'C':
+				explicit_pgconfig = optarg;
+				break;
 			case 'D':
 				potential_DataDir = optarg;
 				break;
@@ -444,10 +447,24 @@
 		ExitPostmaster(1);
 	}
 
-	checkDataDir(potential_DataDir);	/* issues error messages */
-	SetDataDir(potential_DataDir);
+	if(explicit_pgconfig)
+	{
+		/* Allow command line option to overide config file. */
+		ProcessConfigFile(PGC_POSTMASTER);
+
+		if(!potential_DataDir  && pgdatadir)
+			potential_DataDir = pgdatadir;
+
+		checkDataDir(potential_DataDir);
+		SetDataDir(potential_DataDir);
+	}
+	else
+	{
+		checkDataDir(potential_DataDir);	/* issues error messages */
+		SetDataDir(potential_DataDir);
 
-	ProcessConfigFile(PGC_POSTMASTER);
+		ProcessConfigFile(PGC_POSTMASTER);
+	}
 
 	IgnoreSystemIndexes(false);
 
@@ -457,7 +474,7 @@
 	optreset = 1;				/* some systems need this too */
 #endif
 
-	while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
+	while ((opt = getopt(argc, argv, "A:a:B:b:c:C:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
 	{
 		switch (opt)
 		{
@@ -477,6 +494,9 @@
 			case 'b':
 				/* Can no longer set the backend executable file to use. */
 				break;
+			case 'C': 
+				/* Can no longer set configuration file */
+				break;
 			case 'D':
 				/* already done above */
 				break;
Only in postgresql-7.2b4_config/src/backend/postmaster: postmaster.c.orig
diff -r -u postgresql-7.2b4/src/backend/utils/misc/guc-file.c postgresql-7.2b4_config/src/backend/utils/misc/guc-file.c
--- postgresql-7.2b4/src/backend/utils/misc/guc-file.c	Wed Dec 12 08:33:26 2001
+++ postgresql-7.2b4_config/src/backend/utils/misc/guc-file.c	Sun Dec 16 08:33:32 2001
@@ -1682,16 +1682,29 @@
 	Assert(DataDir);
 	elevel = (context == PGC_SIGHUP) ? DEBUG : ERROR;
 
-	/*
-	 * Open file
-	 */
-	filename = malloc(strlen(DataDir) + strlen(CONFIG_FILENAME) + 2);
+	/* Added for explicit config file */
+	if(!explicit_pgconfig)
+	{
+		/*
+		 * Use environmental config
+		 */
+		filename = malloc(strlen(DataDir) + strlen(CONFIG_FILENAME) + 2);
+		sprintf(filename, "%s/" CONFIG_FILENAME, DataDir);
+	}
+	else
+	{
+		/*
+		 * Use explicit file
+		 */
+		filename = strdup(explicit_pgconfig);
+	}
+
 	if (filename == NULL)
 	{
 		elog(elevel, "out of memory");
 		return;
 	}
-	sprintf(filename, "%s/" CONFIG_FILENAME, DataDir);
+
 
     fp = AllocateFile(filename, "r");
     if (!fp)
diff -r -u postgresql-7.2b4/src/backend/utils/misc/guc.c postgresql-7.2b4_config/src/backend/utils/misc/guc.c
--- postgresql-7.2b4/src/backend/utils/misc/guc.c	Tue Oct 30 00:38:56 2001
+++ postgresql-7.2b4_config/src/backend/utils/misc/guc.c	Sun Dec 16 08:34:17 2001
@@ -39,6 +39,10 @@
 #include "utils/datetime.h"
 #include "pgstat.h"
 
+/* Added for config file only startup MLW */
+char *explicit_pgconfig = NULL;
+char *explicit_hbaconfig = NULL;
+char *pgdatadir = NULL;
 
 /* XXX these should be in other modules' header files */
 extern bool Log_connections;
@@ -594,7 +598,14 @@
 		XLOG_sync_method_default, check_xlog_sync_method,
 		assign_xlog_sync_method
 	},
-
+	{
+		"hbaconfig", PGC_POSTMASTER, &explicit_hbaconfig,
+		"", NULL, NULL
+	},
+	{
+		"datadir", PGC_POSTMASTER, &pgdatadir,
+		"", NULL, NULL
+	},
 	{
 		NULL, 0, NULL, NULL, NULL, NULL
 	}
diff -r -u postgresql-7.2b4/src/backend/utils/misc/postgresql.conf.sample postgresql-7.2b4_config/src/backend/utils/misc/postgresql.conf.sample
--- postgresql-7.2b4/src/backend/utils/misc/postgresql.conf.sample	Sun Sep 30 14:57:45 2001
+++ postgresql-7.2b4_config/src/backend/utils/misc/postgresql.conf.sample	Sun Dec 16 08:34:38 2001
@@ -19,6 +19,15 @@
 
 #========================================================================
 
+#	Explicit configuration
+
+# Allows postgres to use an pg_hba.conf file
+# which is not in the database directory.
+# hbaconfig = '/etc/pghba.conf'
+
+# Allows Postgres to find its data directory
+# from this configuration file.
+# datadir = '/u01/postgres'
 
 #
 #	Connection Parameters
diff -r -u postgresql-7.2b4/src/include/utils/guc.h postgresql-7.2b4_config/src/include/utils/guc.h
--- postgresql-7.2b4/src/include/utils/guc.h	Mon Nov  5 12:46:36 2001
+++ postgresql-7.2b4_config/src/include/utils/guc.h	Sun Dec 16 08:27:06 2001
@@ -73,4 +73,9 @@
 extern bool SQL_inheritance;
 extern bool Australian_timezones;
 
+/* Added MLW */
+extern char *explicit_pgconfig;
+extern char *explicit_hbaconfig;
+extern char *pgdatadir;
+
 #endif   /* GUC_H */