X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/25ff04417e4b4fa0aeb44e0b1576a01021aa1650..b3bf9b9df95137a3a43248be9599d919b04877af:/access.c diff --git a/access.c b/access.c index f8dd593f..772ec27b 100644 --- a/access.c +++ b/access.c @@ -1,29 +1,25 @@ -/* - Copyright (C) Andrew Tridgell 1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - /* - hosts allow/deny code for rsync - - */ + * Routines to authenticate access to a daemon (hosts allow/deny). + * + * Copyright (C) 1998 Andrew Tridgell + * Copyright (C) 2004-2009 Wayne Davison + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, visit the http://fsf.org website. + */ #include "rsync.h" - static int match_hostname(char *host, char *tok) { if (!host || !*host) @@ -67,7 +63,7 @@ static int match_address(char *addr, char *tok) int gai; int ret = 0; int addrlen = 0; -#if HAVE_STRTOL +#ifdef HAVE_STRTOL long int bits; #else int bits; @@ -88,7 +84,7 @@ static int match_address(char *addr, char *tok) /* Fail quietly if tok is a hostname (not an address) */ if (strspn(tok, ".0123456789") != len -#if INET6 +#ifdef INET6 && strchr(tok, ':') == NULL #endif ) { @@ -133,7 +129,7 @@ static int match_address(char *addr, char *tok) break; -#if INET6 +#ifdef INET6 case PF_INET6: { struct sockaddr_in6 *sin6a, *sin6t; @@ -146,7 +142,7 @@ static int match_address(char *addr, char *tok) addrlen = 16; -#if HAVE_SOCKADDR_IN6_SCOPE_ID +#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID if (sin6t->sin6_scope_id && sin6a->sin6_scope_id != sin6t->sin6_scope_id) { ret = 0; @@ -166,13 +162,13 @@ static int match_address(char *addr, char *tok) bits = -1; if (p) { if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) { -#if HAVE_STRTOL +#ifdef HAVE_STRTOL char *ep = NULL; #else unsigned char *pp; #endif -#if HAVE_STRTOL +#ifdef HAVE_STRTOL bits = strtol(p, &ep, 10); if (!*p || *ep) { rprintf(FLOG, "malformed mask in %s\n", tok); @@ -208,7 +204,7 @@ static int match_address(char *addr, char *tok) ret = match_binary(a, t, mask, addrlen); -out: + out: freeaddrinfo(resa); freeaddrinfo(rest); return ret;