summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-08-14 14:30:07 +0200
committerVolker Lendecke <vl@samba.org>2010-08-16 21:33:22 +0200
commit0827e52b4e82bf52f723c76a286cf6746054294a (patch)
treecf3f21dfce06119822d05076677a9c502f803e25
parent17150dfa9ae97ef5ac2c2c55a0b31b1fd4a3501d (diff)
downloadsamba-0827e52b4e82bf52f723c76a286cf6746054294a.tar.gz
samba-0827e52b4e82bf52f723c76a286cf6746054294a.tar.bz2
samba-0827e52b4e82bf52f723c76a286cf6746054294a.zip
s3: Simplify the logic of check_access by an early return
-rw-r--r--source3/lib/access.c66
1 files changed, 32 insertions, 34 deletions
diff --git a/source3/lib/access.c b/source3/lib/access.c
index a7d2262d6b..9808218412 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -375,42 +375,40 @@ bool check_access(int sock, const char **allow_list, const char **deny_list)
{
bool ret = false;
bool only_ip = false;
+ char addr[INET6_ADDRSTRLEN];
- if ((!deny_list || *deny_list==0) && (!allow_list || *allow_list==0))
- ret = true;
-
- if (!ret) {
- char addr[INET6_ADDRSTRLEN];
-
- /* Bypass name resolution calls if the lists
- * only contain IP addrs */
- if (only_ipaddrs_in_list(allow_list) &&
- only_ipaddrs_in_list(deny_list)) {
- only_ip = true;
- DEBUG (3, ("check_access: no hostnames "
- "in host allow/deny list.\n"));
- ret = allow_access(deny_list,
- allow_list,
- "",
- get_peer_addr(sock,addr,sizeof(addr)));
- } else {
- DEBUG (3, ("check_access: hostnames in "
- "host allow/deny list.\n"));
- ret = allow_access(deny_list,
- allow_list,
- get_peer_name(sock,true),
- get_peer_addr(sock,addr,sizeof(addr)));
- }
+ if ((!deny_list || *deny_list==0) && (!allow_list || *allow_list==0)) {
+ return true;
+ }
- if (ret) {
- DEBUG(2,("Allowed connection from %s (%s)\n",
- only_ip ? "" : get_peer_name(sock,true),
- get_peer_addr(sock,addr,sizeof(addr))));
- } else {
- DEBUG(0,("Denied connection from %s (%s)\n",
- only_ip ? "" : get_peer_name(sock,true),
- get_peer_addr(sock,addr,sizeof(addr))));
- }
+ /* Bypass name resolution calls if the lists
+ * only contain IP addrs */
+ if (only_ipaddrs_in_list(allow_list) &&
+ only_ipaddrs_in_list(deny_list)) {
+ only_ip = true;
+ DEBUG (3, ("check_access: no hostnames "
+ "in host allow/deny list.\n"));
+ ret = allow_access(deny_list,
+ allow_list,
+ "",
+ get_peer_addr(sock,addr,sizeof(addr)));
+ } else {
+ DEBUG (3, ("check_access: hostnames in "
+ "host allow/deny list.\n"));
+ ret = allow_access(deny_list,
+ allow_list,
+ get_peer_name(sock,true),
+ get_peer_addr(sock,addr,sizeof(addr)));
+ }
+
+ if (ret) {
+ DEBUG(2,("Allowed connection from %s (%s)\n",
+ only_ip ? "" : get_peer_name(sock,true),
+ get_peer_addr(sock,addr,sizeof(addr))));
+ } else {
+ DEBUG(0,("Denied connection from %s (%s)\n",
+ only_ip ? "" : get_peer_name(sock,true),
+ get_peer_addr(sock,addr,sizeof(addr))));
}
return(ret);