On Thu, 2002-12-12 at 13:13, Rudy Lippan wrote:
> I know this is a broken install, but postmaster should not segfault when 
> it can't find a file.
> 
> postgres@war PGDATA $ ../pgsql7.3/bin/postmaster
> LOG:  load_hba: Unable to open authentication config file 
> "/usr/local/PGDATA/pgsql7.3/pg_hba.conf": No such file or directory
> Segmentation fault (core dumped)

Good catch. Here's a patch against CVS HEAD that fixes the problem.

The actual segfault was caused by a double pfree(), but ISTM that
failing to find pg_hba.conf should be a fatal error anyway, so I
increased the priority of the elog() from LOG to FATAL and refactored
the code a little bit.

Bruce: unless anyone has an objection, please apply.

Thanks for the report.

Cheers,

Neil
Index: src/backend/libpq/hba.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/libpq/hba.c,v
retrieving revision 1.90
diff -c -r1.90 hba.c
*** src/backend/libpq/hba.c	6 Dec 2002 04:37:02 -0000	1.90
--- src/backend/libpq/hba.c	12 Dec 2002 22:45:59 -0000
***************
*** 841,856 ****
  	file = AllocateFile(conf_file, "r");
  	if (file == NULL)
  	{
! 		/* The open of the config file failed.	*/
! 		elog(LOG, "load_hba: Unable to open authentication config file \"%s\": %m",
  			 conf_file);
- 		pfree(conf_file);
- 	}
- 	else
- 	{
- 		hba_lines = tokenize_file(file);
- 		FreeFile(file);
  	}
  	pfree(conf_file);
  }
  
--- 841,853 ----
  	file = AllocateFile(conf_file, "r");
  	if (file == NULL)
  	{
! 		elog(FATAL,
! 			 "load_hba: Unable to open authentication config file \"%s\": %m",
  			 conf_file);
  	}
+ 
+ 	hba_lines = tokenize_file(file);
+ 	FreeFile(file);
  	pfree(conf_file);
  }
  
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to