summaryrefslogtreecommitdiffhomepage
path: root/src/acl.c
AgeCommit message (Collapse)Author
2021-04-16make upstream site-spec ipv6 compatible, refactor acl coderofl0r
the acl.c code parsing a site-spec has been factored out into a new TU: hostspec. it was superior to the parsing code in upstream.c in that it properly deals with both ipv4 and ipv6. both upstream and acl now use the new code for parsing, and upstream also for checking for a match. acl.c still uses the old matching code as it has a lot of special case code for specifications containing a hostname, and in case such a spec is encountered, tries to do reverse name lookup to see if a numeric ip matches that spec. removing that code could break existing usecases, however since that was never implemented for upstream nobody will miss it there.
2020-09-30acl: fix regression using ipv6 with netmaskrofl0r
introduced in 0ad8904b40d699405f60655606db42475c011b67 closes #327
2020-09-16acl.c: detect invalid ipv6 stringrofl0r
2020-09-07make acl lookup 450x faster by using sblistrofl0r
tested with 32K acl rules, generated by for x in `seq 128` ; do for y in `seq 255` ; do \ echo "Deny 10.$x.$y.0/24" ; done ; done after loading the config (which is dogslow too), tinyproxy required 9.5 seconds for the acl check on every request. after switching the list implementation to sblist, a request with the full acl check now takes only 0.025 seconds. the time spent for loading the config file is identical for both list implementations, roughly 30 seconds. (in a previous test, 65K acl rules were generated, but every connection required almost 2 minutes to crunch through the list...)
2020-09-07acl: typedef access_list to acl_list_trofl0r
this allows to switch the underlying implementation easily.
2020-09-07check_acl: do full_inet_pton() only once per iprofl0r
if there's a long list of acl's, doing full_inet_pton() over and over with the same IP isn't really efficient.
2020-07-06fix check_acl compilation with --enable-debugxiejianjun
regression introduced in f6d4da5d81694721bf50b2275621e7ce84e6da30. this has been overlooked due to the assert macro being optimized out in non-debug builds.
2019-12-21do hostname resolution only when it is absolutely necessary for ACL checkrofl0r
tinyproxy used to do a full hostname resolution whenever a new client connection happened, which could cause very long delays (as reported in #198). there's only a single place/scenario that actually requires a hostname, and that is when an Allow/Deny rule exists for a hostname or domain, rather than a raw IP address. since it is very likely this feature is not very widely used, it makes absolute sense to only do the costly resolution when it is unavoidable.
2011-03-04[BB#90]: Fix bug in ACL netmask generationMukund Sivaraman
Thanks to John Horne who diagnosed this issue and found the problem.
2010-05-30Precompute network addresses for increased performanceMukund Sivaraman
2010-05-30Minor indent of codeMukund Sivaraman
2010-01-14check_numeric_acl() should return -1 when IPs don't match.David Shanks
Signed-off-by: Michael Adam <obnox@samba.org>
2009-12-07Add access_list to the config struct instead of a global variable in acl.c.Michael Adam
Change insert_acl, check_acl and flush_access_list to take a corresponding argument. Michael
2009-12-07acl: add function flush_access_list().Michael Adam
2009-11-17acl: split initialization of the access_list out into a functionMichael Adam
2009-11-10Fix a segfault in insert_acl and checks against string-type aclsMichael Adam
The "address" member of struct acl_s is a union of a char * and the numeric ip. So freeing the string after appending it to the vector list is bad in two respects: 1. If the acl type was numeric, then this could (and would) lead to a segfault due to the numeric IP data interpreted as pointer to the string to be freed. 2. If the acl type was string, then the acl inserted into the list contained a reference to this address string that was freed. So in the worst case dereferencing this freed string could segfault, or at least this could lead to unexpectedly failing acl checks. Michael
2009-10-10acl: Fix "comparison between signed and unsigned" warning on 32bitMichael Adam
This reads the mask bits as an unsigned int instead of as signend. This is also what mask bits really are - there is no negative mask. :-) Michael
2009-10-10Use size_t not ssize_t for len argument. This is always >= 0.Michael Adam
2009-10-09Use ssize_t for len argumentMukund Sivaraman
2009-09-28Include limits.h for LONG_MAX and LONG_MINMukund Sivaraman
Not including limits.h caused an issue when building on FreeBSD.
2009-09-21Remove trailing comma from acl_type enumMukund Sivaraman
2009-09-20Remove inline keyword from static functionsMukund Sivaraman
The compiler inlines static functions as necessary anyway. No more inline keywords exist in Tinyproxy source code. We want to avoid using this keyword anyway.
2009-09-15Indent code to Tinyproxy coding styleMukund Sivaraman
The modified files were indented with GNU indent using the following command: indent -npro -kr -i8 -ts8 -sob -l80 -ss -cs -cp1 -bs -nlps -nprs -pcs \ -saf -sai -saw -sc -cdw -ce -nut -il0 No other changes of any sort were made.
2009-08-07Rename tinyproxy.[ch] to main.[ch]Mukund Sivaraman
2009-08-04check_acl(): initialize "perm" to eliminate compiler warning.Michael Adam
Provides safe fallback for switch statement, just in case.. Michael
2009-08-04check_acl(): remove the fd argument - it is not used.Michael Adam
Host name and IP address are provided instead. Michael
2009-08-04check_acl(): fix function header comment.Michael Adam
Michael
2009-08-04check_acl(): add explicit cast to return value of vector_getentry()Michael Adam
to reduce compiler warnings. Michael
2009-08-04check_acl(): add cast to recuce compiler warning (unsigned / signed comparison)Michael Adam
vector_lenth() returns < 0 if the vectore is NULL but this has been checked before, so we can safely cast. Michael
2008-12-29Indenting changeMukund Sivaraman
2008-12-08Convert tabs to spacesMukund Sivaraman
2008-12-01Reformat code to GNU coding styleMukund Sivaraman
This is a commit which simply ran all C source code files through GNU indent. No other modifications were made.
2008-08-24pos can never be less than 0 as it's of type size_tMukund Sivaraman
Also fix the type which is passed in from various places.
2008-06-17Add strtol conversion error checkingRobert James Kaes
Moved the strtol() call into fill_netmask_array() and added additional error checking to ensure that the strtol() call succeeded. Error checking code taken from strtol() manpage. Signed-off-by: Robert James Kaes <rjk@wormbytes.ca>
2008-06-17Refactored netmask array fill with range checkRobert James Kaes
When building a numeric ACL with netmask, range check the supplied value. In addition, the code to walk the array has been extracted and "simplified". Signed-off-by: Robert James Kaes <rjk@wormbytes.ca>
2008-05-24Updated copyright, license notices in source codeMukund Sivaraman
The notices have been changed to a more GNU look. Documentation comments have been separated from the copyright header. I've tried to keep all copyright notices intact. Some author contact details have been updated.
2005-08-15* [Indent] Ran Source Through indentRobert James Kaes
I re-indented the source code using indent with the following options: indent -kr -bad -bap -nut -i8 -l80 -psl -sob -ss -ncs There are now _no_ tabs in the source files, and all indentation is eight spaces. Lines are 80 characters long, and the procedure type is on it's own line. Read the indent manual for more information about what each option means.
2005-07-12* Updated Copyright Email AddressesRobert James Kaes
Updated the copyright email addresses for Robert James Kaes. The users.sourceforge.net address should always exist.
2004-08-24Fixed up the acl_s structure so that it compiles correctly underRobert James Kaes
gcc 2.95.
2004-08-11Completely rewrote the ACL functionality. The new system is intendedRobert James Kaes
to handle IPv6 style addresses along with the existing IPv4 and string addresses. In addition, the hand-rolled "list" code has been replaced with a vector (code reuse.) Also, the code should be a little easier to understand (relatively speaking.) I do need to add some kind of testing framework (in general) to check that the new code does work with all the formats that will be thrown at it.
2004-02-13Removed unnecessary casts (mostly dealing with memory allocation.) IRobert James Kaes
should never have added them in the first place. They don't really buy anything, and they can hide bugs.
2003-07-31Added appropriate casts from (void*) so that the code will compileRobert James Kaes
cleanly with a C++ compiler. (Tested using GCC 3.3)
2002-06-05(acl_string_processing): Moved the string processing code out of check_acl() ↵Robert James Kaes
and into it's own function because it now does two (2) tests. If the ACL string is a complete host name, in other words doesn't start with a period, than a reverse DNS look-up is done on the host name and compared to the IP address of the client; otherwise, the normal text string comparison is done. (check_acl): Moved the string text out of the function and removed some logging code by jumping to the "Deny" code at the end of the function.
2002-05-23Changed the header includes around to reflect the new source layout.Robert James Kaes
2002-04-18Changed all calls to strdup to safestrdup. This should provide betterRobert James Kaes
memory usage tracking.
2002-04-17Changed the check_acl() function to require the peer IP address and stringRobert James Kaes
address from the calling function.
2002-04-09James Flemer cleaned up the make_netmask() function to remove the staticRobert James Kaes
table. Very nice.
2001-11-22Reformated text.Robert James Kaes
2001-11-03Tightened the string/numeric ACL checks.Robert James Kaes
2001-10-25Header reorganization. Basically all system headers are now included inRobert James Kaes
tinyproxy.h and all the other files include the tinyproxy.h header. This moves all the dependancy issues into one file.