Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/access.c

    r597 r740  
    1212
    1313#include "includes.h"
     14#include "memcache.h"
     15#include "interfaces.h"
    1416
    1517#define NAME_INDEX 0
     
    6769        }
    6870
    69         return same_net((struct sockaddr *)&ss_host, (struct sockaddr *)&ss_tok, (struct sockaddr *)&ss_mask);
     71        return same_net((struct sockaddr *)(void *)&ss_host,
     72                        (struct sockaddr *)(void *)&ss_tok,
     73                        (struct sockaddr *)(void *)&ss_mask);
    7074}
    7175
     
    330334        ret = allow_access_internal(deny_list, allow_list, nc_cname, nc_caddr);
    331335
     336        DEBUG(ret ? 3 : 0,
     337              ("%s connection from %s (%s)\n",
     338               ret ? "Allowed" : "Denied", nc_cname, nc_caddr));
     339
    332340        SAFE_FREE(nc_cname);
    333341        SAFE_FREE(nc_caddr);
    334342        return ret;
    335343}
    336 
    337 /* return true if the char* contains ip addrs only.  Used to avoid
    338 name lookup calls */
    339 
    340 static bool only_ipaddrs_in_list(const char **list)
    341 {
    342         bool only_ip = true;
    343 
    344         if (!list) {
    345                 return true;
    346         }
    347 
    348         for (; *list ; list++) {
    349                 /* factor out the special strings */
    350                 if (strequal(*list, "ALL") || strequal(*list, "FAIL") ||
    351                     strequal(*list, "EXCEPT")) {
    352                         continue;
    353                 }
    354 
    355                 if (!is_ipaddress(*list)) {
    356                         /*
    357                          * If we failed, make sure that it was not because
    358                          * the token was a network/netmask pair. Only
    359                          * network/netmask pairs have a '/' in them.
    360                          */
    361                         if ((strchr_m(*list, '/')) == NULL) {
    362                                 only_ip = false;
    363                                 DEBUG(3,("only_ipaddrs_in_list: list has "
    364                                         "non-ip address (%s)\n",
    365                                         *list));
    366                                 break;
    367                         }
    368                 }
    369         }
    370 
    371         return only_ip;
    372 }
    373 
    374 /* return true if access should be allowed to a service for a socket */
    375 bool check_access(int sock, const char **allow_list, const char **deny_list)
    376 {
    377         bool ret = false;
    378         bool only_ip = false;
    379 
    380         if ((!deny_list || *deny_list==0) && (!allow_list || *allow_list==0))
    381                 ret = true;
    382 
    383         if (!ret) {
    384                 char addr[INET6_ADDRSTRLEN];
    385 
    386                 /* Bypass name resolution calls if the lists
    387                  * only contain IP addrs */
    388                 if (only_ipaddrs_in_list(allow_list) &&
    389                                 only_ipaddrs_in_list(deny_list)) {
    390                         only_ip = true;
    391                         DEBUG (3, ("check_access: no hostnames "
    392                                 "in host allow/deny list.\n"));
    393                         ret = allow_access(deny_list,
    394                                         allow_list,
    395                                         "",
    396                                         get_peer_addr(sock,addr,sizeof(addr)));
    397                 } else {
    398                         DEBUG (3, ("check_access: hostnames in "
    399                                 "host allow/deny list.\n"));
    400                         ret = allow_access(deny_list,
    401                                         allow_list,
    402                                         get_peer_name(sock,true),
    403                                         get_peer_addr(sock,addr,sizeof(addr)));
    404                 }
    405 
    406                 if (ret) {
    407                         DEBUG(2,("Allowed connection from %s (%s)\n",
    408                                  only_ip ? "" : get_peer_name(sock,true),
    409                                  get_peer_addr(sock,addr,sizeof(addr))));
    410                 } else {
    411                         DEBUG(0,("Denied connection from %s (%s)\n",
    412                                  only_ip ? "" : get_peer_name(sock,true),
    413                                  get_peer_addr(sock,addr,sizeof(addr))));
    414                 }
    415         }
    416 
    417         return(ret);
    418 }
Note: See TracChangeset for help on using the changeset viewer.