Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5549a2

Browse files
committed
Back out this patch because it is patched inside a later patch.---------------------------------------------------------------------------here is a patch that allows CIDR netmasks in pg_hba.conf. It allows twoaddress/mask forms:. address/maskbits, or. address netmask (as now)If the patch is accepted I will submit a documentation patch to coverit.This is submitted by agreement with Kurt Roeckx, who has worked on apatch that covers this and other IPv6 issues.
1 parent1cef8ea commite5549a2

File tree

3 files changed

+13
-91
lines changed

3 files changed

+13
-91
lines changed

‎src/backend/libpq/hba.c

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.101 2003/06/1202:12:58 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.102 2003/06/1207:00:57 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -588,7 +588,6 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
588588
elseif (strcmp(token,"host")==0||strcmp(token,"hostssl")==0)
589589
{
590590
SockAddrfile_ip_addr,mask;
591-
char*cidr_slash;
592591

593592
if (strcmp(token,"hostssl")==0)
594593
{
@@ -619,48 +618,26 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
619618
gotohba_syntax;
620619
user=lfirst(line);
621620

622-
/* Read the IP address field.(with or without CIDR netmask)*/
621+
/* Read the IP address field. */
623622
line=lnext(line);
624623
if (!line)
625624
gotohba_syntax;
626625
token=lfirst(line);
627626

628-
/* Check if it has a CIDR suffix and if so isolate it */
629-
cidr_slash=strchr(token,'/');
630-
if (cidr_slash)
631-
*cidr_slash='\0';
632-
633-
/* Get the IP address either way */
634627
if(SockAddr_pton(&file_ip_addr,token)<0)
635-
{
636-
if (cidr_slash)
637-
*cidr_slash='/';
638628
gotohba_syntax;
639-
}
640-
641-
/* Get the netmask */
642-
if (cidr_slash)
643-
{
644-
*cidr_slash='/';
645-
if (SockAddr_cidr_mask(&mask,++cidr_slash,file_ip_addr.sa.sa_family)<0)
646-
gotohba_syntax;
647-
}
648-
else
649-
{
650-
/* Read the mask field. */
651-
line=lnext(line);
652-
if (!line)
653-
gotohba_syntax;
654-
token=lfirst(line);
655629

656-
if(SockAddr_pton(&mask,token)<0)
657-
gotohba_syntax;
658-
659-
if(file_ip_addr.sa.sa_family!=mask.sa.sa_family)
660-
gotohba_syntax;
661-
}
630+
/* Read the mask field. */
631+
line=lnext(line);
632+
if (!line)
633+
gotohba_syntax;
634+
token=lfirst(line);
662635

636+
if(SockAddr_pton(&mask,token)<0)
637+
gotohba_syntax;
663638

639+
if(file_ip_addr.sa.sa_family!=mask.sa.sa_family)
640+
gotohba_syntax;
664641

665642
/* Read the rest of the line. */
666643
line=lnext(line);

‎src/backend/libpq/ip.c

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.10 2003/06/1202:12:58 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.11 2003/06/1207:00:57 momjian Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -251,59 +251,6 @@ SockAddr_pton(SockAddr *sa, const char *src)
251251
}
252252
}
253253

254-
/*
255-
* SockAddr_cidr_mask - make a network mask of the appropriate family
256-
* and required number of significant bits
257-
*/
258-
259-
int
260-
SockAddr_cidr_mask(SockAddr*mask,char*numbits,intfamily)
261-
{
262-
inti;
263-
longbits;
264-
char*endptr;
265-
266-
bits=strtol(numbits,&endptr,10);
267-
268-
if (*numbits=='\0'||*endptr!='\0')
269-
return-1;
270-
271-
272-
if ((bits<0)|| (family==AF_INET&&bits>32)
273-
#ifdefHAVE_IPV6
274-
|| (family==AF_INET6&&bits>128)
275-
#endif
276-
)
277-
return-1;
278-
279-
mask->sa.sa_family=family;
280-
281-
switch (family)
282-
{
283-
caseAF_INET:
284-
mask->in.sin_addr.s_addr=htonl((0xffffffffUL << (32-bits))&0xffffffffUL);
285-
break;
286-
#ifdefHAVE_IPV6
287-
caseAF_INET6:
288-
for (i=0;i<16;i++)
289-
{
290-
if (bits <=0)
291-
mask->in6.sin6_addr.s6_addr[i]=0;
292-
elseif (bits >=8)
293-
mask->in6.sin6_addr.s6_addr[i]=0xff;
294-
else
295-
mask->in6.sin6_addr.s6_addr[i]=(0xff << (8-bits))&0xff;
296-
bits-=8;
297-
298-
}
299-
break;
300-
#endif
301-
default:
302-
return-1;
303-
}
304-
return0;
305-
306-
}
307254

308255
/*
309256
*isAF_INETx - check to see if sa is AF_INET or AF_INET6

‎src/include/libpq/ip.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
8-
* $Id: ip.h,v 1.6 2003/06/1202:12:58 momjian Exp $
8+
* $Id: ip.h,v 1.7 2003/06/1207:00:57 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -25,8 +25,6 @@ extern char *SockAddr_ntop(const SockAddr *sa, char *dst, size_t cnt,
2525
intv4conv);
2626
externintSockAddr_pton(SockAddr*sa,constchar*src);
2727

28-
externintSockAddr_cidr_mask(SockAddr*mask,char*numbits,intfamily);
29-
3028
externintisAF_INETx(constintfamily);
3129
externintrangeSockAddr(constSockAddr*addr,constSockAddr*netaddr,
3230
constSockAddr*netmask);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp