summaryrefslogtreecommitdiff
path: root/source4/lib/socket
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/socket')
-rw-r--r--source4/lib/socket/access.c96
-rw-r--r--source4/lib/socket/connect.c2
-rw-r--r--source4/lib/socket/interface.c18
-rw-r--r--source4/lib/socket/socket.c6
-rw-r--r--source4/lib/socket/socket_ip.c10
-rw-r--r--source4/lib/socket/socket_unix.c6
6 files changed, 69 insertions, 69 deletions
diff --git a/source4/lib/socket/access.c b/source4/lib/socket/access.c
index 2d228c7474..42c42db365 100644
--- a/source4/lib/socket/access.c
+++ b/source4/lib/socket/access.c
@@ -39,7 +39,7 @@
#define ALLONES ((uint32_t)0xFFFFFFFF)
/* masked_match - match address against netnumber/netmask */
-static BOOL masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash, const char *s)
+static bool masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash, const char *s)
{
uint32_t net;
uint32_t mask;
@@ -47,7 +47,7 @@ static BOOL masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash
char *tok_cpy;
if ((addr = interpret_addr(s)) == INADDR_NONE)
- return False;
+ return false;
tok_cpy = talloc_strdup(mem_ctx, tok);
tok_cpy[PTR_DIFF(slash,tok)] = '\0';
@@ -64,14 +64,14 @@ static BOOL masked_match(TALLOC_CTX *mem_ctx, const char *tok, const char *slash
if (net == INADDR_NONE || mask == INADDR_NONE) {
DEBUG(0,("access: bad net/mask access control: %s\n", tok));
- return False;
+ return false;
}
return (addr & mask) == (net & mask);
}
/* string_match - match string against token */
-static BOOL string_match(TALLOC_CTX *mem_ctx, const char *tok,const char *s, char *invalid_char)
+static bool string_match(TALLOC_CTX *mem_ctx, const char *tok,const char *s, char *invalid_char)
{
size_t tok_len;
size_t str_len;
@@ -79,50 +79,50 @@ static BOOL string_match(TALLOC_CTX *mem_ctx, const char *tok,const char *s, cha
*invalid_char = '\0';
- /* Return True if a token has the magic value "ALL". Return
+ /* Return true if a token has the magic value "ALL". Return
* FAIL if the token is "FAIL". If the token starts with a "."
- * (domain name), return True if it matches the last fields of
+ * (domain name), return true if it matches the last fields of
* the string. If the token has the magic value "LOCAL",
- * return True if the string does not contain a "."
+ * return true if the string does not contain a "."
* character. If the token ends on a "." (network number),
- * return True if it matches the first fields of the
+ * return true if it matches the first fields of the
* string. If the token begins with a "@" (netgroup name),
- * return True if the string is a (host) member of the
- * netgroup. Return True if the token fully matches the
+ * return true if the string is a (host) member of the
+ * netgroup. Return true if the token fully matches the
* string. If the token is a netnumber/netmask pair, return
- * True if the address is a member of the specified subnet.
+ * true if the address is a member of the specified subnet.
*/
if (tok[0] == '.') { /* domain: match last fields */
if ((str_len = strlen(s)) > (tok_len = strlen(tok))
&& strcasecmp(tok, s + str_len - tok_len)==0) {
- return True;
+ return true;
}
} else if (tok[0] == '@') { /* netgroup: look it up */
DEBUG(0,("access: netgroup support is not available\n"));
- return False;
+ return false;
} else if (strcmp(tok, "ALL")==0) { /* all: match any */
- return True;
+ return true;
} else if (strcmp(tok, "FAIL")==0) { /* fail: match any */
return FAIL;
} else if (strcmp(tok, "LOCAL")==0) { /* local: no dots */
if (strchr(s, '.') == 0 && strcasecmp(s, "unknown") != 0) {
- return True;
+ return true;
}
} else if (strcasecmp(tok, s)==0) { /* match host name or address */
- return True;
+ return true;
} else if (tok[(tok_len = strlen(tok)) - 1] == '.') { /* network */
if (strncmp(tok, s, tok_len) == 0)
- return True;
+ return true;
} else if ((cut = strchr(tok, '/')) != 0) { /* netnumber/netmask */
if (isdigit((int)s[0]) && masked_match(mem_ctx, tok, cut, s))
- return True;
+ return true;
} else if (strchr(tok, '*') != 0) {
*invalid_char = '*';
} else if (strchr(tok, '?') != 0) {
*invalid_char = '?';
}
- return False;
+ return false;
}
struct client_addr {
@@ -131,9 +131,9 @@ struct client_addr {
};
/* client_match - match host name and address against token */
-static BOOL client_match(TALLOC_CTX *mem_ctx, const char *tok, struct client_addr *client)
+static bool client_match(TALLOC_CTX *mem_ctx, const char *tok, struct client_addr *client)
{
- BOOL match;
+ bool match;
char invalid_char = '\0';
/*
@@ -158,12 +158,12 @@ token '%s' in an allow/deny hosts line.\n", invalid_char, tok ));
}
/* list_match - match an item against a list of tokens with exceptions */
-static BOOL list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_addr *client)
+static bool list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_addr *client)
{
- BOOL match = False;
+ bool match = false;
if (!list)
- return False;
+ return false;
/*
* Process tokens one at a time. We have exhausted all possible matches
@@ -175,18 +175,18 @@ static BOOL list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_add
for (; *list ; list++) {
if (strcmp(*list, "EXCEPT")==0) /* EXCEPT: give up */
break;
- if ((match = client_match(mem_ctx, *list, client))) /* True or FAIL */
+ if ((match = client_match(mem_ctx, *list, client))) /* true or FAIL */
break;
}
- /* Process exceptions to True or FAIL matches. */
- if (match != False) {
+ /* Process exceptions to true or FAIL matches. */
+ if (match != false) {
while (*list && strcmp(*list, "EXCEPT")!=0)
list++;
for (; *list; list++) {
if (client_match(mem_ctx, *list, client)) /* Exception Found */
- return False;
+ return false;
}
}
@@ -194,7 +194,7 @@ static BOOL list_match(TALLOC_CTX *mem_ctx, const char **list, struct client_add
}
/* return true if access should be allowed */
-static BOOL allow_access_internal(TALLOC_CTX *mem_ctx,
+static bool allow_access_internal(TALLOC_CTX *mem_ctx,
const char **deny_list,const char **allow_list,
const char *cname, const char *caddr)
{
@@ -213,15 +213,15 @@ static BOOL allow_access_internal(TALLOC_CTX *mem_ctx,
list_match(mem_ctx, deny_list, &client) &&
(!allow_list ||
!list_match(mem_ctx, allow_list, &client))) {
- return False;
+ return false;
}
- return True;
+ return true;
}
/* if theres no deny list and no allow list then allow access */
if ((!deny_list || *deny_list == 0) &&
(!allow_list || *allow_list == 0)) {
- return True;
+ return true;
}
/* if there is an allow list but no deny list then allow only hosts
@@ -237,27 +237,27 @@ static BOOL allow_access_internal(TALLOC_CTX *mem_ctx,
/* if there are both types of list then allow all hosts on the
allow list */
if (list_match(mem_ctx, allow_list, &client))
- return True;
+ return true;
/* if there are both types of list and it's not on the allow then
allow it if its not on the deny */
if (list_match(mem_ctx, deny_list, &client))
- return False;
+ return false;
- return True;
+ return true;
}
/* return true if access should be allowed */
-BOOL allow_access(TALLOC_CTX *mem_ctx,
+bool allow_access(TALLOC_CTX *mem_ctx,
const char **deny_list, const char **allow_list,
const char *cname, const char *caddr)
{
- BOOL ret;
+ bool ret;
char *nc_cname = talloc_strdup(mem_ctx, cname);
char *nc_caddr = talloc_strdup(mem_ctx, caddr);
if (!nc_cname || !nc_caddr) {
- return False;
+ return false;
}
ret = allow_access_internal(mem_ctx, deny_list, allow_list, nc_cname, nc_caddr);
@@ -271,12 +271,12 @@ BOOL allow_access(TALLOC_CTX *mem_ctx,
/* return true if the char* contains ip addrs only. Used to avoid
gethostbyaddr() calls */
-static BOOL only_ipaddrs_in_list(const char** list)
+static bool only_ipaddrs_in_list(const char** list)
{
- BOOL only_ip = True;
+ bool only_ip = true;
if (!list)
- return True;
+ return true;
for (; *list ; list++) {
/* factor out the special strings */
@@ -293,7 +293,7 @@ static BOOL only_ipaddrs_in_list(const char** list)
* have a '/' in them
*/
if ((strchr(*list, '/')) == NULL) {
- only_ip = False;
+ only_ip = false;
DEBUG(3,("only_ipaddrs_in_list: list has non-ip address (%s)\n", *list));
break;
}
@@ -304,30 +304,30 @@ static BOOL only_ipaddrs_in_list(const char** list)
}
/* return true if access should be allowed to a service for a socket */
-BOOL socket_check_access(struct socket_context *sock,
+bool socket_check_access(struct socket_context *sock,
const char *service_name,
const char **allow_list, const char **deny_list)
{
- BOOL ret;
+ bool ret;
const char *name="";
struct socket_address *addr;
TALLOC_CTX *mem_ctx;
if ((!deny_list || *deny_list==0) &&
(!allow_list || *allow_list==0)) {
- return True;
+ return true;
}
mem_ctx = talloc_init("socket_check_access");
if (!mem_ctx) {
- return False;
+ return false;
}
addr = socket_get_peer_addr(sock, mem_ctx);
if (!addr) {
DEBUG(0,("socket_check_access: Denied connection from unknown host: could not get peer address from kernel\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
/* bypass gethostbyaddr() calls if the lists only contain IP addrs */
@@ -342,7 +342,7 @@ BOOL socket_check_access(struct socket_context *sock,
if (!addr) {
DEBUG(0,("socket_check_access: Denied connection from unknown host\n"));
talloc_free(mem_ctx);
- return False;
+ return false;
}
ret = allow_access(mem_ctx, deny_list, allow_list, name, addr->addr);
diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c
index eca2067df1..4a30fa3b92 100644
--- a/source4/lib/socket/connect.c
+++ b/source4/lib/socket/connect.c
@@ -120,7 +120,7 @@ struct composite_context *socket_connect_send(struct socket_context *sock,
state->flags = flags;
- set_blocking(socket_get_fd(sock), False);
+ set_blocking(socket_get_fd(sock), false);
if (server_address->addr && strcmp(sock->backend_name, "ipv4") == 0) {
struct nbt_name name;
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index a30e4b8af7..9ca4450581 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -54,7 +54,7 @@ static struct ipv4_addr tov4(struct in_addr in)
/****************************************************************************
Try and find an interface that matches an ip. If we cannot, return NULL
**************************************************************************/
-static struct interface *iface_find(struct in_addr ip, BOOL CheckMask)
+static struct interface *iface_find(struct in_addr ip, bool CheckMask)
{
struct interface *i;
if (is_zero_ip(tov4(ip))) return local_interfaces;
@@ -321,7 +321,7 @@ const char *iface_best_ip(const char *dest)
load_interfaces();
ip.s_addr = interpret_addr(dest);
- iface = iface_find(ip, True);
+ iface = iface_find(ip, true);
if (iface) {
return iface->ip_s;
}
@@ -329,25 +329,25 @@ const char *iface_best_ip(const char *dest)
}
/**
- return True if an IP is one one of our local networks
+ return true if an IP is one one of our local networks
*/
-BOOL iface_is_local(const char *dest)
+bool iface_is_local(const char *dest)
{
struct in_addr ip;
load_interfaces();
ip.s_addr = interpret_addr(dest);
- if (iface_find(ip, True)) {
- return True;
+ if (iface_find(ip, true)) {
+ return true;
}
- return False;
+ return false;
}
/**
- return True if a IP matches a IP/netmask pair
+ return true if a IP matches a IP/netmask pair
*/
-BOOL iface_same_net(const char *ip1, const char *ip2, const char *netmask)
+bool iface_same_net(const char *ip1, const char *ip2, const char *netmask)
{
return same_net(interpret_addr2(ip1),
interpret_addr2(ip2),
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c
index 6da35f3af8..92f0a44005 100644
--- a/source4/lib/socket/socket.c
+++ b/source4/lib/socket/socket.c
@@ -77,7 +77,7 @@ _PUBLIC_ NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socke
/* we don't do a connect() on dgram sockets, so need to set
non-blocking at socket create time */
if (!(flags & SOCKET_FLAG_BLOCK) && type == SOCKET_TYPE_DGRAM) {
- set_blocking(socket_get_fd(*new_sock), False);
+ set_blocking(socket_get_fd(*new_sock), false);
}
talloc_set_destructor(*new_sock, socket_destructor);
@@ -502,12 +502,12 @@ _PUBLIC_ void set_socket_options(int fd, const char *options)
int ret=0,i;
int value = 1;
char *p;
- BOOL got_value = False;
+ bool got_value = false;
if ((p = strchr(tok,'='))) {
*p = 0;
value = atoi(p+1);
- got_value = True;
+ got_value = true;
}
for (i=0;socket_options[i].name;i++)
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index 8d561be55f..3ab6f07b22 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -72,7 +72,7 @@ static NTSTATUS ip_connect_complete(struct socket_context *sock, uint32_t flags)
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
@@ -190,7 +190,7 @@ static NTSTATUS ipv4_listen(struct socket_context *sock,
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
@@ -217,7 +217,7 @@ static NTSTATUS ipv4_accept(struct socket_context *sock, struct socket_context *
}
if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
+ int ret = set_blocking(new_fd, false);
if (ret == -1) {
close(new_fd);
return map_nt_error_from_unix(errno);
@@ -673,7 +673,7 @@ static NTSTATUS ipv6_listen(struct socket_context *sock,
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
@@ -700,7 +700,7 @@ static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_conte
}
if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
+ int ret = set_blocking(new_fd, false);
if (ret == -1) {
close(new_fd);
return map_nt_error_from_unix(errno);
diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c
index 7686fea1d8..cac4b8e913 100644
--- a/source4/lib/socket/socket_unix.c
+++ b/source4/lib/socket/socket_unix.c
@@ -82,7 +82,7 @@ static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t f
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
@@ -161,7 +161,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock,
}
if (!(flags & SOCKET_FLAG_BLOCK)) {
- ret = set_blocking(sock->fd, False);
+ ret = set_blocking(sock->fd, false);
if (ret == -1) {
return unixdom_error(errno);
}
@@ -190,7 +190,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
}
if (!(sock->flags & SOCKET_FLAG_BLOCK)) {
- int ret = set_blocking(new_fd, False);
+ int ret = set_blocking(new_fd, false);
if (ret == -1) {
close(new_fd);
return map_nt_error_from_unix(errno);