From 0d87fb91c4385679a104eb9f6110acf10157c0cb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Mar 2002 01:56:31 +0000 Subject: Allow hosts allow/deny to use xx.xx.xx.xx/yy syntax. Jeremy. (This used to be commit ea60c50109462b35825be1dd3cc6b28f739a1b59) --- source3/lib/access.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/lib/access.c') diff --git a/source3/lib/access.c b/source3/lib/access.c index c7ca164c39..f12ee92799 100644 --- a/source3/lib/access.c +++ b/source3/lib/access.c @@ -12,6 +12,8 @@ #define FAIL (-1) +#define ALLONES ((uint32)0xFFFFFFFF) + /* masked_match - match address against netnumber/netmask */ static int masked_match(char *tok, char *slash, char *s) { @@ -24,8 +26,14 @@ static int masked_match(char *tok, char *slash, char *s) *slash = 0; net = interpret_addr(tok); *slash = '/'; - if (net == INADDR_NONE || - (mask = interpret_addr(slash + 1)) == INADDR_NONE) { + + if (strlen(slash + 1) > 2) { + mask = interpret_addr(slash + 1); + } else { + mask = (uint32)((ALLONES >> atoi(slash + 1)) ^ ALLONES); + } + + if (net == INADDR_NONE || mask == INADDR_NONE) { DEBUG(0,("access: bad net/mask access control: %s\n", tok)); return (False); } -- cgit