1010 *
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.170 2008/10/24 12:48:31 mha Exp $
13+ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.171 2008/10/27 20:04:45 mha Exp $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -637,8 +637,13 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
637637#ifdef USE_SSL
638638parsedline -> conntype = ctHostSSL ;
639639#else
640- /* We don't accept this keyword at all if no SSL support */
641- gotohba_syntax ;
640+ ereport (LOG ,
641+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
642+ errmsg ("hostssl not supported on this platform" ),
643+ errhint ("compile with --enable-ssl to use SSL connections" ),
644+ errcontext ("line %d of configuration file \"%s\"" ,
645+ line_num ,HbaFileName )));
646+ return false;
642647#endif
643648}
644649#ifdef USE_SSL
@@ -654,26 +659,55 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
654659}
655660}/* record type */
656661else
657- gotohba_syntax ;
662+ {
663+ ereport (LOG ,
664+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
665+ errmsg ("invalid connection type \"%s\"" ,
666+ token ),
667+ errcontext ("line %d of configuration file \"%s\"" ,
668+ line_num ,HbaFileName )));
669+ return false;
670+ }
658671
659672/* Get the database. */
660673line_item = lnext (line_item );
661674if (!line_item )
662- gotohba_syntax ;
675+ {
676+ ereport (LOG ,
677+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
678+ errmsg ("end-of-line before database specification" ),
679+ errcontext ("line %d of configuration file \"%s\"" ,
680+ line_num ,HbaFileName )));
681+ return false;
682+ }
663683parsedline -> database = pstrdup (lfirst (line_item ));
664684
665685/* Get the role. */
666686line_item = lnext (line_item );
667687if (!line_item )
668- gotohba_syntax ;
688+ {
689+ ereport (LOG ,
690+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
691+ errmsg ("end-of-line before role specification" ),
692+ errcontext ("line %d of configuration file \"%s\"" ,
693+ line_num ,HbaFileName )));
694+ return false;
695+ }
669696parsedline -> role = pstrdup (lfirst (line_item ));
670697
671698if (parsedline -> conntype != ctLocal )
672699{
673700/* Read the IP address field. (with or without CIDR netmask) */
674701line_item = lnext (line_item );
675702if (!line_item )
676- gotohba_syntax ;
703+ {
704+ ereport (LOG ,
705+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
706+ errmsg ("end-of-line before ip address specification" ),
707+ errcontext ("line %d of configuration file \"%s\"" ,
708+ line_num ,HbaFileName )));
709+ return false;
710+ }
677711token = pstrdup (lfirst (line_item ));
678712
679713/* Check if it has a CIDR suffix and if so isolate it */
@@ -718,14 +752,29 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
718752{
719753if (pg_sockaddr_cidr_mask (& parsedline -> mask ,cidr_slash + 1 ,
720754parsedline -> addr .ss_family )< 0 )
721- gotohba_syntax ;
755+ {
756+ ereport (LOG ,
757+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
758+ errmsg ("invalid CIDR mask in address \"%s\"" ,
759+ token ),
760+ errcontext ("line %d of configuration file \"%s\"" ,
761+ line_num ,HbaFileName )));
762+ return false;
763+ }
722764}
723765else
724766{
725767/* Read the mask field. */
726768line_item = lnext (line_item );
727769if (!line_item )
728- gotohba_syntax ;
770+ {
771+ ereport (LOG ,
772+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
773+ errmsg ("end-of-line before netmask specification" ),
774+ errcontext ("line %d of configuration file \"%s\"" ,
775+ line_num ,HbaFileName )));
776+ return false;
777+ }
729778token = lfirst (line_item );
730779
731780ret = pg_getaddrinfo_all (token ,NULL ,& hints ,& gai_result );
@@ -759,7 +808,14 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
759808/* Get the authentication method */
760809line_item = lnext (line_item );
761810if (!line_item )
762- gotohba_syntax ;
811+ {
812+ ereport (LOG ,
813+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
814+ errmsg ("end-of-line before authentication method" ),
815+ errcontext ("line %d of configuration file \"%s\"" ,
816+ line_num ,HbaFileName )));
817+ return false;
818+ }
763819token = lfirst (line_item );
764820
765821unsupauth = NULL ;
@@ -937,23 +993,6 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
937993}
938994
939995return true;
940-
941- hba_syntax :
942- if (line_item )
943- ereport (LOG ,
944- (errcode (ERRCODE_CONFIG_FILE_ERROR ),
945- errmsg ("invalid token \"%s\"" ,
946- (char * )lfirst (line_item )),
947- errcontext ("line %d of configuration file \"%s\"" ,
948- line_num ,HbaFileName )));
949- else
950- ereport (LOG ,
951- (errcode (ERRCODE_CONFIG_FILE_ERROR ),
952- errmsg ("missing field at end of line" ),
953- errcontext ("line %d of configuration file \"%s\"" ,
954- line_num ,HbaFileName )));
955-
956- return false;
957996}
958997
959998