@@ -144,8 +144,6 @@ static List *tokenize_inc_file(List *tokens, const char *outer_filename,
144
144
const char * inc_filename , int elevel , char * * err_msg );
145
145
static bool parse_hba_auth_opt (char * name , char * val , HbaLine * hbaline ,
146
146
int elevel , char * * err_msg );
147
- static bool verify_option_list_length (List * options , const char * optionname ,
148
- List * comparelist , const char * comparename , int line_num );
149
147
static ArrayType * gethba_options (HbaLine * hba );
150
148
static void fill_hba_line (Tuplestorestate * tuple_store , TupleDesc tupdesc ,
151
149
int lineno , HbaLine * hba , const char * err_msg );
@@ -1607,21 +1605,23 @@ parse_hba_line(TokenizedLine *tok_line, int elevel)
1607
1605
1608
1606
if (list_length (parsedline -> radiusservers ) < 1 )
1609
1607
{
1610
- ereport (LOG ,
1608
+ ereport (elevel ,
1611
1609
(errcode (ERRCODE_CONFIG_FILE_ERROR ),
1612
1610
errmsg ("list of RADIUS servers cannot be empty" ),
1613
1611
errcontext ("line %d of configuration file \"%s\"" ,
1614
1612
line_num , HbaFileName )));
1613
+ * err_msg = "list of RADIUS servers cannot be empty" ;
1615
1614
return NULL ;
1616
1615
}
1617
1616
1618
1617
if (list_length (parsedline -> radiussecrets ) < 1 )
1619
1618
{
1620
- ereport (LOG ,
1619
+ ereport (elevel ,
1621
1620
(errcode (ERRCODE_CONFIG_FILE_ERROR ),
1622
1621
errmsg ("list of RADIUS secrets cannot be empty" ),
1623
1622
errcontext ("line %d of configuration file \"%s\"" ,
1624
1623
line_num , HbaFileName )));
1624
+ * err_msg = "list of RADIUS secrets cannot be empty" ;
1625
1625
return NULL ;
1626
1626
}
1627
1627
@@ -1630,24 +1630,53 @@ parse_hba_line(TokenizedLine *tok_line, int elevel)
1630
1630
* but that's already checked above), 1 (use the same value
1631
1631
* everywhere) or the same as the number of servers.
1632
1632
*/
1633
- if (!verify_option_list_length (parsedline -> radiussecrets ,
1634
- "RADIUS secrets" ,
1635
- parsedline -> radiusservers ,
1636
- "RADIUS servers" ,
1637
- line_num ))
1633
+ if (!(list_length (parsedline -> radiussecrets ) == 1 ||
1634
+ list_length (parsedline -> radiussecrets ) == list_length (parsedline -> radiusservers )))
1635
+ {
1636
+ ereport (elevel ,
1637
+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
1638
+ errmsg ("the number of RADIUS secrets (%d) must be 1 or the same as the number of RADIUS servers (%d)" ,
1639
+ list_length (parsedline -> radiussecrets ),
1640
+ list_length (parsedline -> radiusservers )),
1641
+ errcontext ("line %d of configuration file \"%s\"" ,
1642
+ line_num , HbaFileName )));
1643
+ * err_msg = psprintf ("the number of RADIUS secrets (%d) must be 1 or the same as the number of RADIUS servers (%d)" ,
1644
+ list_length (parsedline -> radiussecrets ),
1645
+ list_length (parsedline -> radiusservers ));
1638
1646
return NULL ;
1639
- if (!verify_option_list_length (parsedline -> radiusports ,
1640
- "RADIUS ports" ,
1641
- parsedline -> radiusservers ,
1642
- "RADIUS servers" ,
1643
- line_num ))
1647
+ }
1648
+ if (!(list_length (parsedline -> radiusports ) == 0 ||
1649
+ list_length (parsedline -> radiusports ) == 1 ||
1650
+ list_length (parsedline -> radiusports ) == list_length (parsedline -> radiusservers )))
1651
+ {
1652
+ ereport (elevel ,
1653
+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
1654
+ errmsg ("the number of RADIUS ports (%d) must be 1 or the same as the number of RADIUS servers (%d)" ,
1655
+ list_length (parsedline -> radiusports ),
1656
+ list_length (parsedline -> radiusservers )),
1657
+ errcontext ("line %d of configuration file \"%s\"" ,
1658
+ line_num , HbaFileName )));
1659
+ * err_msg = psprintf ("the number of RADIUS ports (%d) must be 1 or the same as the number of RADIUS servers (%d)" ,
1660
+ list_length (parsedline -> radiusports ),
1661
+ list_length (parsedline -> radiusservers ));
1644
1662
return NULL ;
1645
- if (!verify_option_list_length (parsedline -> radiusidentifiers ,
1646
- "RADIUS identifiers" ,
1647
- parsedline -> radiusservers ,
1648
- "RADIUS servers" ,
1649
- line_num ))
1663
+ }
1664
+ if (!(list_length (parsedline -> radiusidentifiers ) == 0 ||
1665
+ list_length (parsedline -> radiusidentifiers ) == 1 ||
1666
+ list_length (parsedline -> radiusidentifiers ) == list_length (parsedline -> radiusservers )))
1667
+ {
1668
+ ereport (elevel ,
1669
+ (errcode (ERRCODE_CONFIG_FILE_ERROR ),
1670
+ errmsg ("the number of RADIUS identifiers (%d) must be 1 or the same as the number of RADIUS servers (%d)" ,
1671
+ list_length (parsedline -> radiusidentifiers ),
1672
+ list_length (parsedline -> radiusservers )),
1673
+ errcontext ("line %d of configuration file \"%s\"" ,
1674
+ line_num , HbaFileName )));
1675
+ * err_msg = psprintf ("the number of RADIUS identifiers (%d) must be 1 or the same as the number of RADIUS servers (%d)" ,
1676
+ list_length (parsedline -> radiusidentifiers ),
1677
+ list_length (parsedline -> radiusservers ));
1650
1678
return NULL ;
1679
+ }
1651
1680
}
1652
1681
1653
1682
/*
@@ -1662,29 +1691,6 @@ parse_hba_line(TokenizedLine *tok_line, int elevel)
1662
1691
}
1663
1692
1664
1693
1665
- static bool
1666
- verify_option_list_length (List * options , const char * optionname ,
1667
- List * comparelist , const char * comparename ,
1668
- int line_num )
1669
- {
1670
- if (list_length (options ) == 0 ||
1671
- list_length (options ) == 1 ||
1672
- list_length (options ) == list_length (comparelist ))
1673
- return true;
1674
-
1675
- ereport (LOG ,
1676
- (errcode (ERRCODE_CONFIG_FILE_ERROR ),
1677
- errmsg ("the number of %s (%d) must be 1 or the same as the number of %s (%d)" ,
1678
- optionname ,
1679
- list_length (options ),
1680
- comparename ,
1681
- list_length (comparelist )
1682
- ),
1683
- errcontext ("line %d of configuration file \"%s\"" ,
1684
- line_num , HbaFileName )));
1685
- return false;
1686
- }
1687
-
1688
1694
/*
1689
1695
* Parse one name-value pair as an authentication option into the given
1690
1696
* HbaLine. Return true if we successfully parse the option, false if we
0 commit comments