mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
Merge branch 'master' of git://git.samba.org/samba
This commit is contained in:
commit
215b84903e
@ -69,7 +69,7 @@ static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize)
|
||||
TALLOC_CTX **tmp, *top, *parent;
|
||||
|
||||
if (talloc_stack_arraysize < talloc_stacksize + 1) {
|
||||
tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *,
|
||||
tmp = talloc_realloc(NULL, talloc_stack, TALLOC_CTX *,
|
||||
talloc_stacksize + 1);
|
||||
if (tmp == NULL) {
|
||||
goto fail;
|
||||
|
@ -541,12 +541,14 @@ _PUBLIC_ struct in_addr interpret_addr2(const char *str);
|
||||
/**
|
||||
Check if an IP is the 0.0.0.0.
|
||||
**/
|
||||
_PUBLIC_ bool is_zero_ip(struct in_addr ip);
|
||||
_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip);
|
||||
|
||||
/**
|
||||
Are two IPs on the same subnet?
|
||||
**/
|
||||
_PUBLIC_ bool same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
|
||||
_PUBLIC_ bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
|
||||
|
||||
_PUBLIC_ bool is_ipaddress_v4(const char *str);
|
||||
|
||||
/**
|
||||
Check if a process exists. Does this work on all unixes?
|
||||
|
@ -3,7 +3,7 @@
|
||||
Samba utility functions
|
||||
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Copyright (C) Jeremy Allison 2001-2002
|
||||
Copyright (C) Jeremy Allison 2001-2007
|
||||
Copyright (C) Simo Sorce 2001
|
||||
Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
|
||||
Copyright (C) James J Myers 2003
|
||||
@ -26,50 +26,105 @@
|
||||
#include "system/network.h"
|
||||
#include "system/locale.h"
|
||||
#include "system/filesys.h"
|
||||
#undef strcasecmp
|
||||
|
||||
/**
|
||||
Interpret an internet address or name into an IP address in 4 byte form.
|
||||
**/
|
||||
_PUBLIC_ uint32_t interpret_addr(const char *str)
|
||||
* Wrap getaddrinfo...
|
||||
*/
|
||||
bool interpret_string_addr_internal(struct addrinfo **ppres,
|
||||
const char *str, int flags)
|
||||
{
|
||||
struct hostent *hp;
|
||||
uint32_t res;
|
||||
int ret;
|
||||
struct addrinfo hints;
|
||||
|
||||
if (str == NULL || *str == 0 ||
|
||||
strcmp(str,"0.0.0.0") == 0) {
|
||||
memset(&hints, '\0', sizeof(hints));
|
||||
/* By default make sure it supports TCP. */
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = flags;
|
||||
|
||||
/* Linux man page on getaddinfo() says port will be
|
||||
uninitialized when service string in NULL */
|
||||
|
||||
ret = getaddrinfo(str, NULL,
|
||||
&hints,
|
||||
ppres);
|
||||
|
||||
if (ret) {
|
||||
DEBUG(3,("interpret_string_addr_internal: getaddrinfo failed "
|
||||
"for name %s [%s]\n",
|
||||
str,
|
||||
gai_strerror(ret) ));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpret an internet address or name into an IP address in 4 byte form.
|
||||
* RETURNS IN NETWORK BYTE ORDER (big endian).
|
||||
*/
|
||||
|
||||
uint32_t interpret_addr(const char *str)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
/* If it's in the form of an IP address then
|
||||
* get the lib to interpret it */
|
||||
if (is_ipaddress_v4(str)) {
|
||||
struct in_addr dest;
|
||||
|
||||
if (inet_pton(AF_INET, str, &dest) <= 0) {
|
||||
/* Error - this shouldn't happen ! */
|
||||
DEBUG(0,("interpret_addr: inet_pton failed "
|
||||
"host %s\n",
|
||||
str));
|
||||
return 0;
|
||||
}
|
||||
ret = dest.s_addr; /* NETWORK BYTE ORDER ! */
|
||||
} else {
|
||||
/* Otherwise assume it's a network name of some sort and use
|
||||
getadddrinfo. */
|
||||
struct addrinfo *res = NULL;
|
||||
struct addrinfo *res_list = NULL;
|
||||
if (!interpret_string_addr_internal(&res_list,
|
||||
str,
|
||||
AI_ADDRCONFIG)) {
|
||||
DEBUG(3,("interpret_addr: Unknown host. %s\n",str));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the first IPv4 address. */
|
||||
for (res = res_list; res; res = res->ai_next) {
|
||||
if (res->ai_family != AF_INET) {
|
||||
continue;
|
||||
}
|
||||
if (res->ai_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(res == NULL) {
|
||||
DEBUG(3,("interpret_addr: host address is "
|
||||
"invalid for host %s\n",str));
|
||||
if (res_list) {
|
||||
freeaddrinfo(res_list);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
memcpy((char *)&ret,
|
||||
&((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr,
|
||||
sizeof(ret));
|
||||
if (res_list) {
|
||||
freeaddrinfo(res_list);
|
||||
}
|
||||
}
|
||||
|
||||
/* This is so bogus - all callers need fixing... JRA. */
|
||||
if (ret == (uint32_t)-1) {
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(str,"255.255.255.255") == 0) {
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
/* recognise 'localhost' as a special name. This fixes problems with
|
||||
some hosts that don't have localhost in /etc/hosts */
|
||||
if (strcasecmp(str,"localhost") == 0) {
|
||||
str = "127.0.0.1";
|
||||
}
|
||||
|
||||
/* if it's in the form of an IP address then get the lib to interpret it */
|
||||
if (is_ipaddress(str)) {
|
||||
res = inet_addr(str);
|
||||
} else {
|
||||
/* otherwise assume it's a network name of some sort and use
|
||||
sys_gethostbyname */
|
||||
if ((hp = sys_gethostbyname(str)) == 0) {
|
||||
DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(hp->h_addr == NULL) {
|
||||
DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
|
||||
return 0;
|
||||
}
|
||||
memcpy((char *)&res,(char *)hp->h_addr, 4);
|
||||
}
|
||||
|
||||
if (res == (uint32_t)-1)
|
||||
return(0);
|
||||
|
||||
return(res);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +142,7 @@ _PUBLIC_ struct in_addr interpret_addr2(const char *str)
|
||||
Check if an IP is the 0.0.0.0.
|
||||
**/
|
||||
|
||||
_PUBLIC_ bool is_zero_ip(struct in_addr ip)
|
||||
_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip)
|
||||
{
|
||||
return ip.s_addr == 0;
|
||||
}
|
||||
@ -96,7 +151,7 @@ _PUBLIC_ bool is_zero_ip(struct in_addr ip)
|
||||
Are two IPs on the same subnet?
|
||||
**/
|
||||
|
||||
_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask)
|
||||
_PUBLIC_ bool same_net_v4(struct in_addr ip1, struct in_addr ip2, struct in_addr mask)
|
||||
{
|
||||
uint32_t net1,net2,nmask;
|
||||
|
||||
@ -108,24 +163,248 @@ _PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr ma
|
||||
}
|
||||
|
||||
/**
|
||||
Return true if a string could be a pure IP address.
|
||||
**/
|
||||
* Return true if a string could be an IPv4 address.
|
||||
*/
|
||||
|
||||
_PUBLIC_ bool is_ipaddress(const char *str)
|
||||
bool is_ipaddress_v4(const char *str)
|
||||
{
|
||||
bool pure_address = true;
|
||||
int i;
|
||||
int ret = -1;
|
||||
struct in_addr dest;
|
||||
|
||||
if (str == NULL) return false;
|
||||
|
||||
for (i=0; pure_address && str[i]; i++)
|
||||
if (!(isdigit((int)str[i]) || str[i] == '.'))
|
||||
pure_address = false;
|
||||
|
||||
/* Check that a pure number is not misinterpreted as an IP */
|
||||
pure_address = pure_address && (strchr(str, '.') != NULL);
|
||||
|
||||
return pure_address;
|
||||
ret = inet_pton(AF_INET, str, &dest);
|
||||
if (ret > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if a string could be an IPv4 or IPv6 address.
|
||||
*/
|
||||
|
||||
bool is_ipaddress(const char *str)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
int ret = -1;
|
||||
|
||||
if (strchr_m(str, ':')) {
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
struct in6_addr dest6;
|
||||
const char *sp = str;
|
||||
char *p = strchr_m(str, '%');
|
||||
|
||||
/*
|
||||
* Cope with link-local.
|
||||
* This is IP:v6:addr%ifname.
|
||||
*/
|
||||
|
||||
if (p && (p > str) && (if_nametoindex(p+1) != 0)) {
|
||||
strlcpy(addr, str,
|
||||
MIN(PTR_DIFF(p,str)+1,
|
||||
sizeof(addr)));
|
||||
sp = addr;
|
||||
}
|
||||
ret = inet_pton(AF_INET6, sp, &dest6);
|
||||
if (ret > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return is_ipaddress_v4(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a sockaddr a broadcast address ?
|
||||
*/
|
||||
|
||||
bool is_broadcast_addr(const struct sockaddr *pss)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (pss->sa_family == AF_INET6) {
|
||||
const struct in6_addr *sin6 =
|
||||
&((const struct sockaddr_in6 *)pss)->sin6_addr;
|
||||
return IN6_IS_ADDR_MULTICAST(sin6);
|
||||
}
|
||||
#endif
|
||||
if (pss->sa_family == AF_INET) {
|
||||
uint32_t addr =
|
||||
ntohl(((const struct sockaddr_in *)pss)->sin_addr.s_addr);
|
||||
return addr == INADDR_BROADCAST;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an IPv7 is 127.0.0.1
|
||||
*/
|
||||
bool is_loopback_ip_v4(struct in_addr ip)
|
||||
{
|
||||
struct in_addr a;
|
||||
a.s_addr = htonl(INADDR_LOOPBACK);
|
||||
return(ip.s_addr == a.s_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a struct sockaddr is the loopback address.
|
||||
*/
|
||||
bool is_loopback_addr(const struct sockaddr *pss)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (pss->sa_family == AF_INET6) {
|
||||
const struct in6_addr *pin6 =
|
||||
&((const struct sockaddr_in6 *)pss)->sin6_addr;
|
||||
return IN6_IS_ADDR_LOOPBACK(pin6);
|
||||
}
|
||||
#endif
|
||||
if (pss->sa_family == AF_INET) {
|
||||
const struct in_addr *pin = &((const struct sockaddr_in *)pss)->sin_addr;
|
||||
return is_loopback_ip_v4(*pin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a struct sockaddr has an unspecified address.
|
||||
*/
|
||||
bool is_zero_addr(const struct sockaddr *pss)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (pss->sa_family == AF_INET6) {
|
||||
const struct in6_addr *pin6 =
|
||||
&((const struct sockaddr_in6 *)pss)->sin6_addr;
|
||||
return IN6_IS_ADDR_UNSPECIFIED(pin6);
|
||||
}
|
||||
#endif
|
||||
if (pss->sa_family == AF_INET) {
|
||||
const struct in_addr *pin = &((const struct sockaddr_in *)pss)->sin_addr;
|
||||
return is_zero_ip_v4(*pin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an IP to 0.0.0.0.
|
||||
*/
|
||||
void zero_ip_v4(struct in_addr *ip)
|
||||
{
|
||||
memset(ip, '\0', sizeof(struct in_addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an IPv4 struct in_addr to a struct sockaddr_storage.
|
||||
*/
|
||||
void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
|
||||
struct in_addr ip)
|
||||
{
|
||||
struct sockaddr_in *sa = (struct sockaddr_in *)ss;
|
||||
memset(ss, '\0', sizeof(*ss));
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_addr = ip;
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
/**
|
||||
* Convert an IPv6 struct in_addr to a struct sockaddr_storage.
|
||||
*/
|
||||
void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
|
||||
struct in6_addr ip)
|
||||
{
|
||||
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)ss;
|
||||
memset(ss, '\0', sizeof(*ss));
|
||||
sa->sin6_family = AF_INET6;
|
||||
sa->sin6_addr = ip;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Are two IPs on the same subnet?
|
||||
*/
|
||||
bool same_net(const struct sockaddr *ip1,
|
||||
const struct sockaddr *ip2,
|
||||
const struct sockaddr *mask)
|
||||
{
|
||||
if (ip1->sa_family != ip2->sa_family) {
|
||||
/* Never on the same net. */
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
if (ip1->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 ip1_6 = *(const struct sockaddr_in6 *)ip1;
|
||||
struct sockaddr_in6 ip2_6 = *(const struct sockaddr_in6 *)ip2;
|
||||
struct sockaddr_in6 mask_6 = *(const struct sockaddr_in6 *)mask;
|
||||
char *p1 = (char *)&ip1_6.sin6_addr;
|
||||
char *p2 = (char *)&ip2_6.sin6_addr;
|
||||
char *m = (char *)&mask_6.sin6_addr;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(struct in6_addr); i++) {
|
||||
*p1++ &= *m;
|
||||
*p2++ &= *m;
|
||||
m++;
|
||||
}
|
||||
return (memcmp(&ip1_6.sin6_addr,
|
||||
&ip2_6.sin6_addr,
|
||||
sizeof(struct in6_addr)) == 0);
|
||||
}
|
||||
#endif
|
||||
if (ip1->sa_family == AF_INET) {
|
||||
return same_net_v4(((const struct sockaddr_in *)ip1)->sin_addr,
|
||||
((const struct sockaddr_in *)ip2)->sin_addr,
|
||||
((const struct sockaddr_in *)mask)->sin_addr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are two sockaddr 's the same family and address ? Ignore port etc.
|
||||
*/
|
||||
|
||||
bool addr_equal(const struct sockaddr *ip1,
|
||||
const struct sockaddr *ip2)
|
||||
{
|
||||
if (ip1->sa_family != ip2->sa_family) {
|
||||
/* Never the same. */
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
if (ip1->sa_family == AF_INET6) {
|
||||
return (memcmp(&((const struct sockaddr_in6 *)ip1)->sin6_addr,
|
||||
&((const struct sockaddr_in6 *)ip2)->sin6_addr,
|
||||
sizeof(struct in6_addr)) == 0);
|
||||
}
|
||||
#endif
|
||||
if (ip1->sa_family == AF_INET) {
|
||||
return (memcmp(&((const struct sockaddr_in *)ip1)->sin_addr,
|
||||
&((const struct sockaddr_in *)ip2)->sin_addr,
|
||||
sizeof(struct in_addr)) == 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is an IP address the INADDR_ANY or in6addr_any value ?
|
||||
*/
|
||||
bool is_address_any(const struct sockaddr *psa)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (psa->sa_family == AF_INET6) {
|
||||
const struct sockaddr_in6 *si6 = (const struct sockaddr_in6 *)psa;
|
||||
if (memcmp(&in6addr_any,
|
||||
&si6->sin6_addr,
|
||||
sizeof(in6addr_any)) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (psa->sa_family == AF_INET) {
|
||||
const struct sockaddr_in *si = (const struct sockaddr_in *)psa;
|
||||
if (si->sin_addr.s_addr == INADDR_ANY) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
svcctl interface definitions
|
||||
*/
|
||||
|
||||
import "misc.idl";
|
||||
import "misc.idl", "security.idl";
|
||||
[ uuid("367abb81-9844-35f1-ad32-98f038001003"),
|
||||
version(2.0),
|
||||
pointer_default(unique),
|
||||
@ -227,6 +227,9 @@ import "misc.idl";
|
||||
|
||||
/*****************/
|
||||
/* Function 0x0f */
|
||||
|
||||
/* Service Control Manager Bits */
|
||||
|
||||
typedef [bitmap32bit] bitmap {
|
||||
SC_RIGHT_MGR_CONNECT = 0x0001,
|
||||
SC_RIGHT_MGR_CREATE_SERVICE = 0x0002,
|
||||
@ -236,6 +239,23 @@ import "misc.idl";
|
||||
SC_RIGHT_MGR_MODIFY_BOOT_CONFIG = 0x0020
|
||||
} svcctl_MgrAccessMask;
|
||||
|
||||
const int SC_MANAGER_READ_ACCESS =
|
||||
(SEC_STD_READ_CONTROL |
|
||||
SC_RIGHT_MGR_CONNECT |
|
||||
SC_RIGHT_MGR_ENUMERATE_SERVICE |
|
||||
SC_RIGHT_MGR_QUERY_LOCK_STATUS);
|
||||
|
||||
const int SC_MANAGER_EXECUTE_ACCESS = SC_MANAGER_READ_ACCESS;
|
||||
|
||||
const int SC_MANAGER_WRITE_ACCESS =
|
||||
(SEC_STD_REQUIRED |
|
||||
SC_MANAGER_READ_ACCESS |
|
||||
SC_RIGHT_MGR_CREATE_SERVICE |
|
||||
SC_RIGHT_MGR_LOCK |
|
||||
SC_RIGHT_MGR_MODIFY_BOOT_CONFIG);
|
||||
|
||||
const int SC_MANAGER_ALL_ACCESS = SC_MANAGER_WRITE_ACCESS;
|
||||
|
||||
WERROR svcctl_OpenSCManagerW(
|
||||
[in,unique] [string,charset(UTF16)] uint16 *MachineName,
|
||||
[in,unique] [string,charset(UTF16)] uint16 *DatabaseName,
|
||||
@ -245,6 +265,9 @@ import "misc.idl";
|
||||
|
||||
/*****************/
|
||||
/* Function 0x10 */
|
||||
|
||||
/* Service Object Bits */
|
||||
|
||||
typedef [bitmap32bit] bitmap {
|
||||
SC_RIGHT_SVC_QUERY_CONFIG = 0x0001,
|
||||
SC_RIGHT_SVC_CHANGE_CONFIG = 0x0002,
|
||||
@ -257,6 +280,28 @@ import "misc.idl";
|
||||
SC_RIGHT_SVC_USER_DEFINED_CONTROL = 0x0100
|
||||
} svcctl_ServiceAccessMask;
|
||||
|
||||
const int SERVICE_READ_ACCESS =
|
||||
(SEC_STD_READ_CONTROL |
|
||||
SC_RIGHT_SVC_ENUMERATE_DEPENDENTS |
|
||||
SC_RIGHT_SVC_INTERROGATE |
|
||||
SC_RIGHT_SVC_QUERY_CONFIG |
|
||||
SC_RIGHT_SVC_QUERY_STATUS |
|
||||
SC_RIGHT_SVC_USER_DEFINED_CONTROL);
|
||||
|
||||
const int SERVICE_EXECUTE_ACCESS =
|
||||
(SERVICE_READ_ACCESS |
|
||||
SC_RIGHT_SVC_START |
|
||||
SC_RIGHT_SVC_STOP |
|
||||
SC_RIGHT_SVC_PAUSE_CONTINUE);
|
||||
|
||||
const int SERVICE_WRITE_ACCESS =
|
||||
(SEC_STD_REQUIRED |
|
||||
SERVICE_READ_ACCESS |
|
||||
SERVICE_EXECUTE_ACCESS |
|
||||
SC_RIGHT_SVC_CHANGE_CONFIG);
|
||||
|
||||
const int SERVICE_ALL_ACCESS = SERVICE_WRITE_ACCESS;
|
||||
|
||||
WERROR svcctl_OpenServiceW(
|
||||
[in,ref] policy_handle *scmanager_handle,
|
||||
[in] [string,charset(UTF16)] uint16 ServiceName[],
|
||||
|
@ -320,7 +320,8 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
|
||||
../lib/util/xfile.o ../lib/util/util_strlist.o \
|
||||
../lib/util/util_file.o ../lib/util/data_blob.o \
|
||||
../lib/util/util.o ../lib/util/fsusage.o \
|
||||
../lib/util/params.o ../lib/util/talloc_stack.o
|
||||
../lib/util/params.o ../lib/util/talloc_stack.o \
|
||||
../lib/util/genrand.o ../lib/util/util_net.o
|
||||
|
||||
CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
|
||||
../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
|
||||
@ -336,7 +337,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
|
||||
$(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \
|
||||
lib/interface.o lib/pidfile.o \
|
||||
lib/system.o lib/sendfile.o lib/recvfile.o lib/time.o \
|
||||
lib/genrand.o lib/username.o \
|
||||
lib/username.o \
|
||||
lib/util_pw.o lib/access.o lib/smbrun.o \
|
||||
lib/bitmap.o lib/dprintf.o $(UTIL_REG_OBJ) \
|
||||
lib/wins_srv.o \
|
||||
|
@ -65,7 +65,7 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ismyaddr(&dest_ss)) {
|
||||
if (ismyaddr((struct sockaddr *)&dest_ss)) {
|
||||
DEBUG(1,("Password server loop - disabling password server %s\n",desthost));
|
||||
continue;
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ void gencache_unlock_entry( const char *key );
|
||||
|
||||
/* The following definitions come from lib/genrand.c */
|
||||
|
||||
void set_rand_reseed_callback(void (*fn)(int *));
|
||||
void set_rand_reseed_callback(void (*fn)(void *, int *), void *userdata);
|
||||
void set_need_random_reseed(void);
|
||||
void generate_random_buffer(uint8_t *out, int len);
|
||||
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
|
||||
@ -591,10 +591,10 @@ int smb_iconv_close (smb_iconv_t cd);
|
||||
|
||||
/* The following definitions come from lib/interface.c */
|
||||
|
||||
bool ismyaddr(const struct sockaddr_storage *ip);
|
||||
bool ismyaddr(const struct sockaddr *ip);
|
||||
bool ismyip_v4(struct in_addr ip);
|
||||
bool is_local_net(const struct sockaddr_storage *from);
|
||||
void setup_linklocal_scope_id(struct sockaddr_storage *pss);
|
||||
bool is_local_net(const struct sockaddr *from);
|
||||
void setup_linklocal_scope_id(struct sockaddr *pss);
|
||||
bool is_local_net_v4(struct in_addr from);
|
||||
int iface_count(void);
|
||||
int iface_count_v4_nl(void);
|
||||
@ -604,8 +604,8 @@ const struct sockaddr_storage *iface_n_sockaddr_storage(int n);
|
||||
const struct in_addr *iface_n_ip_v4(int n);
|
||||
const struct in_addr *iface_n_bcast_v4(int n);
|
||||
const struct sockaddr_storage *iface_n_bcast(int n);
|
||||
const struct sockaddr_storage *iface_ip(const struct sockaddr_storage *ip);
|
||||
bool iface_local(const struct sockaddr_storage *ip);
|
||||
const struct sockaddr_storage *iface_ip(const struct sockaddr *ip);
|
||||
bool iface_local(const struct sockaddr *ip);
|
||||
void load_interfaces(void);
|
||||
void gfree_interfaces(void);
|
||||
bool interfaces_changed(void);
|
||||
@ -1476,29 +1476,31 @@ NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
|
||||
|
||||
/* The following definitions come from lib/util_sock.c */
|
||||
|
||||
bool interpret_string_addr_internal(struct addrinfo **ppres,
|
||||
const char *str, int flags);
|
||||
bool is_ipaddress_v4(const char *str);
|
||||
bool is_ipaddress(const char *str);
|
||||
bool is_broadcast_addr(const struct sockaddr_storage *pss);
|
||||
bool is_broadcast_addr(const struct sockaddr *pss);
|
||||
uint32 interpret_addr(const char *str);
|
||||
struct in_addr *interpret_addr2(struct in_addr *ip, const char *str);
|
||||
struct in_addr interpret_addr2(const char *str);
|
||||
bool interpret_string_addr(struct sockaddr_storage *pss,
|
||||
const char *str,
|
||||
int flags);
|
||||
bool is_loopback_ip_v4(struct in_addr ip);
|
||||
bool is_loopback_addr(const struct sockaddr_storage *pss);
|
||||
bool is_loopback_addr(const struct sockaddr *pss);
|
||||
bool is_zero_ip_v4(struct in_addr ip);
|
||||
bool is_zero_addr(const struct sockaddr_storage *pss);
|
||||
bool is_zero_addr(const struct sockaddr *pss);
|
||||
void zero_ip_v4(struct in_addr *ip);
|
||||
void zero_addr(struct sockaddr_storage *pss);
|
||||
bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
|
||||
void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
|
||||
struct in_addr ip);
|
||||
bool same_net(const struct sockaddr_storage *ip1,
|
||||
const struct sockaddr_storage *ip2,
|
||||
const struct sockaddr_storage *mask);
|
||||
bool addr_equal(const struct sockaddr_storage *ip1,
|
||||
const struct sockaddr_storage *ip2);
|
||||
bool is_address_any(const struct sockaddr_storage *psa);
|
||||
bool same_net(const struct sockaddr *ip1,
|
||||
const struct sockaddr *ip2,
|
||||
const struct sockaddr *mask);
|
||||
bool addr_equal(const struct sockaddr *ip1,
|
||||
const struct sockaddr *ip2);
|
||||
bool is_address_any(const struct sockaddr *psa);
|
||||
uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
|
||||
char *print_sockaddr(char *dest,
|
||||
size_t destlen,
|
||||
|
@ -385,76 +385,6 @@ struct standard_mapping {
|
||||
(STANDARD_RIGHTS_EXECUTE_ACCESS | \
|
||||
SA_RIGHT_ALIAS_LOOKUP_INFO ) /* 0x00020008 */
|
||||
|
||||
/*
|
||||
* Acces bits for the svcctl objects
|
||||
*/
|
||||
|
||||
/* Service Control Manager Bits */
|
||||
|
||||
#if 0
|
||||
#define SC_RIGHT_MGR_CONNECT 0x0001
|
||||
#define SC_RIGHT_MGR_CREATE_SERVICE 0x0002
|
||||
#define SC_RIGHT_MGR_ENUMERATE_SERVICE 0x0004
|
||||
#define SC_RIGHT_MGR_LOCK 0x0008
|
||||
#define SC_RIGHT_MGR_QUERY_LOCK_STATUS 0x0010
|
||||
#define SC_RIGHT_MGR_MODIFY_BOOT_CONFIG 0x0020
|
||||
|
||||
#endif
|
||||
|
||||
#define SC_MANAGER_READ_ACCESS \
|
||||
( STANDARD_RIGHTS_READ_ACCESS | \
|
||||
SC_RIGHT_MGR_CONNECT | \
|
||||
SC_RIGHT_MGR_ENUMERATE_SERVICE | \
|
||||
SC_RIGHT_MGR_QUERY_LOCK_STATUS )
|
||||
|
||||
#define SC_MANAGER_EXECUTE_ACCESS SC_MANAGER_READ_ACCESS
|
||||
|
||||
#define SC_MANAGER_WRITE_ACCESS \
|
||||
( STANDARD_RIGHTS_REQUIRED_ACCESS | \
|
||||
SC_MANAGER_READ_ACCESS | \
|
||||
SC_RIGHT_MGR_CREATE_SERVICE | \
|
||||
SC_RIGHT_MGR_LOCK | \
|
||||
SC_RIGHT_MGR_MODIFY_BOOT_CONFIG )
|
||||
|
||||
#define SC_MANAGER_ALL_ACCESS SC_MANAGER_WRITE_ACCESS
|
||||
|
||||
/* Service Object Bits */
|
||||
|
||||
#if 0
|
||||
#define SC_RIGHT_SVC_QUERY_CONFIG 0x0001
|
||||
#define SC_RIGHT_SVC_CHANGE_CONFIG 0x0002
|
||||
#define SC_RIGHT_SVC_QUERY_STATUS 0x0004
|
||||
#define SC_RIGHT_SVC_ENUMERATE_DEPENDENTS 0x0008
|
||||
#define SC_RIGHT_SVC_START 0x0010
|
||||
#define SC_RIGHT_SVC_STOP 0x0020
|
||||
#define SC_RIGHT_SVC_PAUSE_CONTINUE 0x0040
|
||||
#define SC_RIGHT_SVC_INTERROGATE 0x0080
|
||||
#define SC_RIGHT_SVC_USER_DEFINED_CONTROL 0x0100
|
||||
|
||||
#endif
|
||||
|
||||
#define SERVICE_READ_ACCESS \
|
||||
( STANDARD_RIGHTS_READ_ACCESS | \
|
||||
SC_RIGHT_SVC_ENUMERATE_DEPENDENTS | \
|
||||
SC_RIGHT_SVC_INTERROGATE | \
|
||||
SC_RIGHT_SVC_QUERY_CONFIG | \
|
||||
SC_RIGHT_SVC_QUERY_STATUS | \
|
||||
SC_RIGHT_SVC_USER_DEFINED_CONTROL )
|
||||
|
||||
#define SERVICE_EXECUTE_ACCESS \
|
||||
( SERVICE_READ_ACCESS | \
|
||||
SC_RIGHT_SVC_START | \
|
||||
SC_RIGHT_SVC_STOP | \
|
||||
SC_RIGHT_SVC_PAUSE_CONTINUE )
|
||||
|
||||
#define SERVICE_WRITE_ACCESS \
|
||||
( STANDARD_RIGHTS_REQUIRED_ACCESS | \
|
||||
SERVICE_READ_ACCESS | \
|
||||
SERVICE_EXECUTE_ACCESS | \
|
||||
SC_RIGHT_SVC_CHANGE_CONFIG )
|
||||
|
||||
#define SERVICE_ALL_ACCESS SERVICE_WRITE_ACCESS
|
||||
|
||||
/*
|
||||
* Access Bits for registry ACLS
|
||||
*/
|
||||
|
@ -66,7 +66,7 @@ static bool masked_match(const char *tok, const char *slash, const char *s)
|
||||
}
|
||||
}
|
||||
|
||||
return same_net(&ss_host, &ss_tok, &ss_mask);
|
||||
return same_net((struct sockaddr *)&ss_host, (struct sockaddr *)&ss_tok, (struct sockaddr *)&ss_mask);
|
||||
}
|
||||
|
||||
/* string_match - match string s against token tok */
|
||||
|
@ -1,220 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
Functions to create reasonable random numbers for crypto use.
|
||||
|
||||
Copyright (C) Jeremy Allison 2001
|
||||
|
||||
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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
static struct arcfour_state smb_arc4_state;
|
||||
static uint32 counter;
|
||||
|
||||
static bool done_reseed = False;
|
||||
static void (*reseed_callback)(int *newseed);
|
||||
|
||||
/****************************************************************
|
||||
Copy any user given reseed data.
|
||||
*****************************************************************/
|
||||
|
||||
void set_rand_reseed_callback(void (*fn)(int *))
|
||||
{
|
||||
reseed_callback = fn;
|
||||
set_need_random_reseed();
|
||||
}
|
||||
|
||||
void set_need_random_reseed(void)
|
||||
{
|
||||
done_reseed = False;
|
||||
}
|
||||
|
||||
static void get_rand_reseed_data(int *reseed_data)
|
||||
{
|
||||
if (reseed_callback) {
|
||||
reseed_callback(reseed_data);
|
||||
} else {
|
||||
*reseed_data = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
Get a 16 byte hash from the contents of a file.
|
||||
Note that the hash is not initialised.
|
||||
*****************************************************************/
|
||||
|
||||
static void do_filehash(const char *fname, unsigned char *the_hash)
|
||||
{
|
||||
unsigned char buf[1011]; /* deliberate weird size */
|
||||
unsigned char tmp_md4[16];
|
||||
int fd, n;
|
||||
|
||||
fd = sys_open(fname,O_RDONLY,0);
|
||||
if (fd == -1)
|
||||
return;
|
||||
|
||||
while ((n = read(fd, (char *)buf, sizeof(buf))) > 0) {
|
||||
mdfour(tmp_md4, buf, n);
|
||||
for (n=0;n<16;n++)
|
||||
the_hash[n] ^= tmp_md4[n];
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Try and get a good random number seed. Try a number of
|
||||
different factors. Firstly, try /dev/urandom - use if exists.
|
||||
|
||||
We use /dev/urandom as a read of /dev/random can block if
|
||||
the entropy pool dries up. This leads clients to timeout
|
||||
or be very slow on connect.
|
||||
|
||||
If we can't use /dev/urandom then seed the stream random generator
|
||||
above...
|
||||
**************************************************************/
|
||||
|
||||
static int do_reseed(bool use_fd, int fd)
|
||||
{
|
||||
unsigned char seed_inbuf[40];
|
||||
DATA_BLOB seed_blob = { seed_inbuf, 40 };
|
||||
uint32 v1, v2; struct timeval tval; pid_t mypid;
|
||||
struct passwd *pw;
|
||||
int reseed_data = 0;
|
||||
|
||||
if (use_fd) {
|
||||
if (fd != -1)
|
||||
return fd;
|
||||
|
||||
fd = sys_open( "/dev/urandom", O_RDONLY,0);
|
||||
if(fd >= 0)
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Add in some secret file contents */
|
||||
|
||||
do_filehash("/etc/shadow", &seed_inbuf[0]);
|
||||
do_filehash(lp_smb_passwd_file(), &seed_inbuf[16]);
|
||||
|
||||
/*
|
||||
* Add in the root encrypted password.
|
||||
* On any system where security is taken
|
||||
* seriously this will be secret.
|
||||
*/
|
||||
|
||||
pw = getpwnam_alloc(NULL, "root");
|
||||
if (pw && pw->pw_passwd) {
|
||||
size_t i;
|
||||
unsigned char md4_tmp[16];
|
||||
mdfour(md4_tmp, (unsigned char *)pw->pw_passwd, strlen(pw->pw_passwd));
|
||||
for (i=0;i<16;i++)
|
||||
seed_inbuf[8+i] ^= md4_tmp[i];
|
||||
TALLOC_FREE(pw);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the counter, time of day, and pid.
|
||||
*/
|
||||
|
||||
GetTimeOfDay(&tval);
|
||||
mypid = sys_getpid();
|
||||
v1 = (counter++) + mypid + tval.tv_sec;
|
||||
v2 = (counter++) * mypid + tval.tv_usec;
|
||||
|
||||
SIVAL(seed_inbuf, 32, v1 ^ IVAL(seed_inbuf, 32));
|
||||
SIVAL(seed_inbuf, 36, v2 ^ IVAL(seed_inbuf, 36));
|
||||
|
||||
/*
|
||||
* Add any user-given reseed data.
|
||||
*/
|
||||
|
||||
get_rand_reseed_data(&reseed_data);
|
||||
if (reseed_data) {
|
||||
size_t i;
|
||||
for (i = 0; i < sizeof(seed_inbuf); i++)
|
||||
seed_inbuf[i] ^= ((char *)(&reseed_data))[i % sizeof(reseed_data)];
|
||||
}
|
||||
|
||||
arcfour_init(&smb_arc4_state, &seed_blob);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Interface to the (hopefully) good crypto random number generator.
|
||||
********************************************************************/
|
||||
|
||||
void generate_random_buffer(uint8_t *out, int len)
|
||||
{
|
||||
static int urand_fd = -1;
|
||||
unsigned char md4_buf[64];
|
||||
unsigned char tmp_buf[16];
|
||||
unsigned char *p;
|
||||
|
||||
if(!done_reseed) {
|
||||
urand_fd = do_reseed(True, urand_fd);
|
||||
done_reseed = True;
|
||||
}
|
||||
|
||||
if (urand_fd != -1 && len > 0) {
|
||||
|
||||
if (read(urand_fd, out, len) == len)
|
||||
return; /* len bytes of random data read from urandom. */
|
||||
|
||||
/* Read of urand error, drop back to non urand method. */
|
||||
close(urand_fd);
|
||||
urand_fd = -1;
|
||||
do_reseed(False, -1);
|
||||
done_reseed = True;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate random numbers in chunks of 64 bytes,
|
||||
* then md4 them & copy to the output buffer.
|
||||
* This way the raw state of the stream is never externally
|
||||
* seen.
|
||||
*/
|
||||
|
||||
p = out;
|
||||
while(len > 0) {
|
||||
int copy_len = len > 16 ? 16 : len;
|
||||
|
||||
arcfour_crypt_sbox(&smb_arc4_state, md4_buf, sizeof(md4_buf));
|
||||
mdfour(tmp_buf, md4_buf, sizeof(md4_buf));
|
||||
memcpy(p, tmp_buf, copy_len);
|
||||
p += copy_len;
|
||||
len -= copy_len;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Use the random number generator to generate a random string.
|
||||
********************************************************************/
|
||||
|
||||
static char c_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
|
||||
|
||||
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
|
||||
{
|
||||
unsigned char *retstr = talloc_zero_array(mem_ctx, unsigned char, len);
|
||||
size_t i;
|
||||
|
||||
generate_random_buffer( retstr, len);
|
||||
for (i = 0; i < len; i++)
|
||||
retstr[i] = c_list[ retstr[i] % (sizeof(c_list)-1) ];
|
||||
|
||||
retstr[i] = '\0';
|
||||
|
||||
return (char *)retstr;
|
||||
}
|
@ -29,11 +29,11 @@ static struct interface *local_interfaces;
|
||||
Check if an IP is one of mine.
|
||||
**************************************************************************/
|
||||
|
||||
bool ismyaddr(const struct sockaddr_storage *ip)
|
||||
bool ismyaddr(const struct sockaddr *ip)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if (addr_equal(&i->ip,ip)) {
|
||||
if (addr_equal((struct sockaddr *)&i->ip,ip)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -44,14 +44,14 @@ bool ismyip_v4(struct in_addr ip)
|
||||
{
|
||||
struct sockaddr_storage ss;
|
||||
in_addr_to_sockaddr_storage(&ss, ip);
|
||||
return ismyaddr(&ss);
|
||||
return ismyaddr((struct sockaddr *)&ss);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Try and find an interface that matches an ip. If we cannot, return NULL.
|
||||
**************************************************************************/
|
||||
|
||||
static struct interface *iface_find(const struct sockaddr_storage *ip,
|
||||
static struct interface *iface_find(const struct sockaddr *ip,
|
||||
bool check_mask)
|
||||
{
|
||||
struct interface *i;
|
||||
@ -62,10 +62,10 @@ static struct interface *iface_find(const struct sockaddr_storage *ip,
|
||||
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if (check_mask) {
|
||||
if (same_net(ip, &i->ip, &i->netmask)) {
|
||||
if (same_net(ip, (struct sockaddr *)&i->ip, (struct sockaddr *)&i->netmask)) {
|
||||
return i;
|
||||
}
|
||||
} else if (addr_equal(&i->ip, ip)) {
|
||||
} else if (addr_equal((struct sockaddr *)&i->ip, ip)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -77,11 +77,11 @@ static struct interface *iface_find(const struct sockaddr_storage *ip,
|
||||
Check if a packet is from a local (known) net.
|
||||
**************************************************************************/
|
||||
|
||||
bool is_local_net(const struct sockaddr_storage *from)
|
||||
bool is_local_net(const struct sockaddr *from)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if (same_net(from, &i->ip, &i->netmask)) {
|
||||
if (same_net(from, (struct sockaddr *)&i->ip, (struct sockaddr *)&i->netmask)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -89,11 +89,11 @@ bool is_local_net(const struct sockaddr_storage *from)
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
void setup_linklocal_scope_id(struct sockaddr_storage *pss)
|
||||
void setup_linklocal_scope_id(struct sockaddr *pss)
|
||||
{
|
||||
struct interface *i;
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if (addr_equal(&i->ip,pss)) {
|
||||
if (addr_equal((struct sockaddr *)&i->ip,pss)) {
|
||||
struct sockaddr_in6 *psa6 =
|
||||
(struct sockaddr_in6 *)pss;
|
||||
psa6->sin6_scope_id = if_nametoindex(i->name);
|
||||
@ -112,7 +112,7 @@ bool is_local_net_v4(struct in_addr from)
|
||||
struct sockaddr_storage ss;
|
||||
|
||||
in_addr_to_sockaddr_storage(&ss, from);
|
||||
return is_local_net(&ss);
|
||||
return is_local_net((struct sockaddr *)&ss);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -140,7 +140,7 @@ int iface_count_v4_nl(void)
|
||||
struct interface *i;
|
||||
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if (is_loopback_addr(&i->ip)) {
|
||||
if (is_loopback_addr((struct sockaddr *)&i->ip)) {
|
||||
continue;
|
||||
}
|
||||
if (i->ip.ss_family == AF_INET) {
|
||||
@ -265,7 +265,7 @@ const struct sockaddr_storage *iface_n_bcast(int n)
|
||||
an appropriate interface they return the requested field of the
|
||||
first known interface. */
|
||||
|
||||
const struct sockaddr_storage *iface_ip(const struct sockaddr_storage *ip)
|
||||
const struct sockaddr_storage *iface_ip(const struct sockaddr *ip)
|
||||
{
|
||||
struct interface *i = iface_find(ip, true);
|
||||
if (i) {
|
||||
@ -276,7 +276,7 @@ const struct sockaddr_storage *iface_ip(const struct sockaddr_storage *ip)
|
||||
* matching address family. */
|
||||
|
||||
for (i=local_interfaces;i;i=i->next) {
|
||||
if (i->ip.ss_family == ip->ss_family) {
|
||||
if (i->ip.ss_family == ip->sa_family) {
|
||||
return &i->ip;
|
||||
}
|
||||
}
|
||||
@ -287,7 +287,7 @@ const struct sockaddr_storage *iface_ip(const struct sockaddr_storage *ip)
|
||||
return True if a IP is directly reachable on one of our interfaces
|
||||
*/
|
||||
|
||||
bool iface_local(const struct sockaddr_storage *ip)
|
||||
bool iface_local(const struct sockaddr *ip)
|
||||
{
|
||||
return iface_find(ip, True) ? true : false;
|
||||
}
|
||||
@ -301,7 +301,7 @@ static void add_interface(const struct iface_struct *ifs)
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
struct interface *iface;
|
||||
|
||||
if (iface_find(&ifs->ip, False)) {
|
||||
if (iface_find((struct sockaddr *)&ifs->ip, False)) {
|
||||
DEBUG(3,("add_interface: not adding duplicate interface %s\n",
|
||||
print_sockaddr(addr, sizeof(addr), &ifs->ip) ));
|
||||
return;
|
||||
@ -388,7 +388,7 @@ static void interpret_interface(char *token)
|
||||
}
|
||||
|
||||
for (i=0;i<total_probed;i++) {
|
||||
if (addr_equal(&ss, &probed_ifaces[i].ip)) {
|
||||
if (addr_equal((struct sockaddr *)&ss, (struct sockaddr *)&probed_ifaces[i].ip)) {
|
||||
add_interface(&probed_ifaces[i]);
|
||||
return;
|
||||
}
|
||||
@ -441,9 +441,12 @@ static void interpret_interface(char *token)
|
||||
make_net(&ss_net, &ss, &ss_mask);
|
||||
|
||||
/* Maybe the first component was a broadcast address. */
|
||||
if (addr_equal(&ss_bcast, &ss) || addr_equal(&ss_net, &ss)) {
|
||||
if (addr_equal((struct sockaddr *)&ss_bcast, (struct sockaddr *)&ss) ||
|
||||
addr_equal((struct sockaddr *)&ss_net, (struct sockaddr *)&ss)) {
|
||||
for (i=0;i<total_probed;i++) {
|
||||
if (same_net(&ss, &probed_ifaces[i].ip, &ss_mask)) {
|
||||
if (same_net((struct sockaddr *)&ss,
|
||||
(struct sockaddr *)&probed_ifaces[i].ip,
|
||||
(struct sockaddr *)&ss_mask)) {
|
||||
/* Temporarily replace netmask on
|
||||
* the detected interface - user knows
|
||||
* best.... */
|
||||
|
@ -21,188 +21,6 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/****************************************************************************
|
||||
Return true if a string could be an IPv4 address.
|
||||
****************************************************************************/
|
||||
|
||||
bool is_ipaddress_v4(const char *str)
|
||||
{
|
||||
int ret = -1;
|
||||
struct in_addr dest;
|
||||
|
||||
ret = inet_pton(AF_INET, str, &dest);
|
||||
if (ret > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Return true if a string could be an IPv4 or IPv6 address.
|
||||
****************************************************************************/
|
||||
|
||||
bool is_ipaddress(const char *str)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
int ret = -1;
|
||||
|
||||
if (strchr_m(str, ':')) {
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
struct in6_addr dest6;
|
||||
const char *sp = str;
|
||||
char *p = strchr_m(str, '%');
|
||||
|
||||
/*
|
||||
* Cope with link-local.
|
||||
* This is IP:v6:addr%ifname.
|
||||
*/
|
||||
|
||||
if (p && (p > str) && (if_nametoindex(p+1) != 0)) {
|
||||
strlcpy(addr, str,
|
||||
MIN(PTR_DIFF(p,str)+1,
|
||||
sizeof(addr)));
|
||||
sp = addr;
|
||||
}
|
||||
ret = inet_pton(AF_INET6, sp, &dest6);
|
||||
if (ret > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return is_ipaddress_v4(str);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Is a sockaddr_storage a broadcast address ?
|
||||
****************************************************************************/
|
||||
|
||||
bool is_broadcast_addr(const struct sockaddr_storage *pss)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (pss->ss_family == AF_INET6) {
|
||||
const struct in6_addr *sin6 =
|
||||
&((const struct sockaddr_in6 *)pss)->sin6_addr;
|
||||
return IN6_IS_ADDR_MULTICAST(sin6);
|
||||
}
|
||||
#endif
|
||||
if (pss->ss_family == AF_INET) {
|
||||
uint32_t addr =
|
||||
ntohl(((const struct sockaddr_in *)pss)->sin_addr.s_addr);
|
||||
return addr == INADDR_BROADCAST;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Wrap getaddrinfo...
|
||||
******************************************************************/
|
||||
|
||||
static bool interpret_string_addr_internal(struct addrinfo **ppres,
|
||||
const char *str, int flags)
|
||||
{
|
||||
int ret;
|
||||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, '\0', sizeof(hints));
|
||||
/* By default make sure it supports TCP. */
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = flags;
|
||||
|
||||
/* Linux man page on getaddinfo() says port will be
|
||||
uninitialized when service string in NULL */
|
||||
|
||||
ret = getaddrinfo(str, NULL,
|
||||
&hints,
|
||||
ppres);
|
||||
|
||||
if (ret) {
|
||||
DEBUG(3,("interpret_string_addr_internal: getaddrinfo failed "
|
||||
"for name %s [%s]\n",
|
||||
str,
|
||||
gai_strerror(ret) ));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Interpret an internet address or name into an IP address in 4 byte form.
|
||||
RETURNS IN NETWORK BYTE ORDER (big endian).
|
||||
****************************************************************************/
|
||||
|
||||
uint32 interpret_addr(const char *str)
|
||||
{
|
||||
uint32 ret;
|
||||
|
||||
/* If it's in the form of an IP address then
|
||||
* get the lib to interpret it */
|
||||
if (is_ipaddress_v4(str)) {
|
||||
struct in_addr dest;
|
||||
|
||||
if (inet_pton(AF_INET, str, &dest) <= 0) {
|
||||
/* Error - this shouldn't happen ! */
|
||||
DEBUG(0,("interpret_addr: inet_pton failed "
|
||||
"host %s\n",
|
||||
str));
|
||||
return 0;
|
||||
}
|
||||
ret = dest.s_addr; /* NETWORK BYTE ORDER ! */
|
||||
} else {
|
||||
/* Otherwise assume it's a network name of some sort and use
|
||||
getadddrinfo. */
|
||||
struct addrinfo *res = NULL;
|
||||
struct addrinfo *res_list = NULL;
|
||||
if (!interpret_string_addr_internal(&res_list,
|
||||
str,
|
||||
AI_ADDRCONFIG)) {
|
||||
DEBUG(3,("interpret_addr: Unknown host. %s\n",str));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the first IPv4 address. */
|
||||
for (res = res_list; res; res = res->ai_next) {
|
||||
if (res->ai_family != AF_INET) {
|
||||
continue;
|
||||
}
|
||||
if (res->ai_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(res == NULL) {
|
||||
DEBUG(3,("interpret_addr: host address is "
|
||||
"invalid for host %s\n",str));
|
||||
if (res_list) {
|
||||
freeaddrinfo(res_list);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
putip((char *)&ret,
|
||||
&((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr);
|
||||
if (res_list) {
|
||||
freeaddrinfo(res_list);
|
||||
}
|
||||
}
|
||||
|
||||
/* This is so bogus - all callers need fixing... JRA. */
|
||||
if (ret == (uint32)-1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
A convenient addition to interpret_addr().
|
||||
******************************************************************/
|
||||
|
||||
struct in_addr *interpret_addr2(struct in_addr *ip, const char *str)
|
||||
{
|
||||
uint32 a = interpret_addr(str);
|
||||
ip->s_addr = a;
|
||||
return ip;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Map a text hostname or IP address (IPv4 or IPv6) into a
|
||||
struct sockaddr_storage.
|
||||
@ -259,77 +77,6 @@ bool interpret_string_addr(struct sockaddr_storage *pss,
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Check if an IPv7 is 127.0.0.1
|
||||
******************************************************************/
|
||||
|
||||
bool is_loopback_ip_v4(struct in_addr ip)
|
||||
{
|
||||
struct in_addr a;
|
||||
a.s_addr = htonl(INADDR_LOOPBACK);
|
||||
return(ip.s_addr == a.s_addr);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Check if a struct sockaddr_storage is the loopback address.
|
||||
******************************************************************/
|
||||
|
||||
bool is_loopback_addr(const struct sockaddr_storage *pss)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (pss->ss_family == AF_INET6) {
|
||||
struct in6_addr *pin6 =
|
||||
&((struct sockaddr_in6 *)pss)->sin6_addr;
|
||||
return IN6_IS_ADDR_LOOPBACK(pin6);
|
||||
}
|
||||
#endif
|
||||
if (pss->ss_family == AF_INET) {
|
||||
struct in_addr *pin = &((struct sockaddr_in *)pss)->sin_addr;
|
||||
return is_loopback_ip_v4(*pin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Check if an IPv4 is 0.0.0.0.
|
||||
******************************************************************/
|
||||
|
||||
bool is_zero_ip_v4(struct in_addr ip)
|
||||
{
|
||||
uint32 a;
|
||||
putip((char *)&a,(char *)&ip);
|
||||
return(a == 0);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Check if a struct sockaddr_storage has an unspecified address.
|
||||
******************************************************************/
|
||||
|
||||
bool is_zero_addr(const struct sockaddr_storage *pss)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (pss->ss_family == AF_INET6) {
|
||||
struct in6_addr *pin6 =
|
||||
&((struct sockaddr_in6 *)pss)->sin6_addr;
|
||||
return IN6_IS_ADDR_UNSPECIFIED(pin6);
|
||||
}
|
||||
#endif
|
||||
if (pss->ss_family == AF_INET) {
|
||||
struct in_addr *pin = &((struct sockaddr_in *)pss)->sin_addr;
|
||||
return is_zero_ip_v4(*pin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Set an IP to 0.0.0.0.
|
||||
******************************************************************/
|
||||
|
||||
void zero_ip_v4(struct in_addr *ip)
|
||||
{
|
||||
memset(ip, '\0', sizeof(struct in_addr));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Set an address to INADDR_ANY.
|
||||
******************************************************************/
|
||||
@ -341,144 +88,6 @@ void zero_addr(struct sockaddr_storage *pss)
|
||||
pss->ss_family = AF_INET;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Are two IPs on the same subnet - IPv4 version ?
|
||||
********************************************************************/
|
||||
|
||||
bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask)
|
||||
{
|
||||
uint32 net1,net2,nmask;
|
||||
|
||||
nmask = ntohl(mask.s_addr);
|
||||
net1 = ntohl(ip1.s_addr);
|
||||
net2 = ntohl(ip2.s_addr);
|
||||
|
||||
return((net1 & nmask) == (net2 & nmask));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Convert an IPv4 struct in_addr to a struct sockaddr_storage.
|
||||
********************************************************************/
|
||||
|
||||
void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
|
||||
struct in_addr ip)
|
||||
{
|
||||
struct sockaddr_in *sa = (struct sockaddr_in *)ss;
|
||||
memset(ss, '\0', sizeof(*ss));
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_addr = ip;
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
/*******************************************************************
|
||||
Convert an IPv6 struct in_addr to a struct sockaddr_storage.
|
||||
********************************************************************/
|
||||
|
||||
void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
|
||||
struct in6_addr ip)
|
||||
{
|
||||
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)ss;
|
||||
memset(ss, '\0', sizeof(*ss));
|
||||
sa->sin6_family = AF_INET6;
|
||||
sa->sin6_addr = ip;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************
|
||||
Are two IPs on the same subnet?
|
||||
********************************************************************/
|
||||
|
||||
bool same_net(const struct sockaddr_storage *ip1,
|
||||
const struct sockaddr_storage *ip2,
|
||||
const struct sockaddr_storage *mask)
|
||||
{
|
||||
if (ip1->ss_family != ip2->ss_family) {
|
||||
/* Never on the same net. */
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
if (ip1->ss_family == AF_INET6) {
|
||||
struct sockaddr_in6 ip1_6 = *(struct sockaddr_in6 *)ip1;
|
||||
struct sockaddr_in6 ip2_6 = *(struct sockaddr_in6 *)ip2;
|
||||
struct sockaddr_in6 mask_6 = *(struct sockaddr_in6 *)mask;
|
||||
char *p1 = (char *)&ip1_6.sin6_addr;
|
||||
char *p2 = (char *)&ip2_6.sin6_addr;
|
||||
char *m = (char *)&mask_6.sin6_addr;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(struct in6_addr); i++) {
|
||||
*p1++ &= *m;
|
||||
*p2++ &= *m;
|
||||
m++;
|
||||
}
|
||||
return (memcmp(&ip1_6.sin6_addr,
|
||||
&ip2_6.sin6_addr,
|
||||
sizeof(struct in6_addr)) == 0);
|
||||
}
|
||||
#endif
|
||||
if (ip1->ss_family == AF_INET) {
|
||||
return same_net_v4(((const struct sockaddr_in *)ip1)->sin_addr,
|
||||
((const struct sockaddr_in *)ip2)->sin_addr,
|
||||
((const struct sockaddr_in *)mask)->sin_addr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Are two sockaddr_storage's the same family and address ? Ignore port etc.
|
||||
********************************************************************/
|
||||
|
||||
bool addr_equal(const struct sockaddr_storage *ip1,
|
||||
const struct sockaddr_storage *ip2)
|
||||
{
|
||||
if (ip1->ss_family != ip2->ss_family) {
|
||||
/* Never the same. */
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_IPV6)
|
||||
if (ip1->ss_family == AF_INET6) {
|
||||
return (memcmp(&((const struct sockaddr_in6 *)ip1)->sin6_addr,
|
||||
&((const struct sockaddr_in6 *)ip2)->sin6_addr,
|
||||
sizeof(struct in6_addr)) == 0);
|
||||
}
|
||||
#endif
|
||||
if (ip1->ss_family == AF_INET) {
|
||||
return (memcmp(&((const struct sockaddr_in *)ip1)->sin_addr,
|
||||
&((const struct sockaddr_in *)ip2)->sin_addr,
|
||||
sizeof(struct in_addr)) == 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Is an IP address the INADDR_ANY or in6addr_any value ?
|
||||
****************************************************************************/
|
||||
|
||||
bool is_address_any(const struct sockaddr_storage *psa)
|
||||
{
|
||||
#if defined(HAVE_IPV6)
|
||||
if (psa->ss_family == AF_INET6) {
|
||||
struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)psa;
|
||||
if (memcmp(&in6addr_any,
|
||||
&si6->sin6_addr,
|
||||
sizeof(in6addr_any)) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (psa->ss_family == AF_INET) {
|
||||
struct sockaddr_in *si = (struct sockaddr_in *)psa;
|
||||
if (si->sin_addr.s_addr == INADDR_ANY) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Get a port number in host byte order from a sockaddr_storage.
|
||||
****************************************************************************/
|
||||
@ -508,13 +117,13 @@ uint16_t get_sockaddr_port(const struct sockaddr_storage *pss)
|
||||
|
||||
static char *print_sockaddr_len(char *dest,
|
||||
size_t destlen,
|
||||
const struct sockaddr_storage *psa,
|
||||
const struct sockaddr *psa,
|
||||
socklen_t psalen)
|
||||
{
|
||||
if (destlen > 0) {
|
||||
dest[0] = '\0';
|
||||
}
|
||||
(void)sys_getnameinfo((const struct sockaddr *)psa,
|
||||
(void)sys_getnameinfo(psa,
|
||||
psalen,
|
||||
dest, destlen,
|
||||
NULL, 0,
|
||||
@ -530,7 +139,7 @@ char *print_sockaddr(char *dest,
|
||||
size_t destlen,
|
||||
const struct sockaddr_storage *psa)
|
||||
{
|
||||
return print_sockaddr_len(dest, destlen, psa,
|
||||
return print_sockaddr_len(dest, destlen, (struct sockaddr *)psa,
|
||||
sizeof(struct sockaddr_storage));
|
||||
}
|
||||
|
||||
@ -596,7 +205,7 @@ static const char *get_socket_addr(int fd, char *addr_buf, size_t addr_len)
|
||||
return addr_buf;
|
||||
}
|
||||
|
||||
return print_sockaddr_len(addr_buf, addr_len, &sa, length);
|
||||
return print_sockaddr_len(addr_buf, addr_len, (struct sockaddr *)&sa, length);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -1313,7 +922,7 @@ int open_socket_out(int type,
|
||||
psa6->sin6_port = htons(port);
|
||||
if (psa6->sin6_scope_id == 0 &&
|
||||
IN6_IS_ADDR_LINKLOCAL(&psa6->sin6_addr)) {
|
||||
setup_linklocal_scope_id(&sock_out);
|
||||
setup_linklocal_scope_id((struct sockaddr *)&sock_out);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1555,7 +1164,7 @@ int open_udp_socket(const char *host, int port)
|
||||
int res;
|
||||
struct in_addr addr;
|
||||
|
||||
(void)interpret_addr2(&addr, host);
|
||||
addr = interpret_addr2(host);
|
||||
|
||||
res = socket(PF_INET, type, 0);
|
||||
if (res == -1) {
|
||||
@ -1583,7 +1192,7 @@ int open_udp_socket(const char *host, int port)
|
||||
static const char *get_peer_addr_internal(int fd,
|
||||
char *addr_buf,
|
||||
size_t addr_buf_len,
|
||||
struct sockaddr_storage *pss,
|
||||
struct sockaddr *pss,
|
||||
socklen_t *plength)
|
||||
{
|
||||
struct sockaddr_storage ss;
|
||||
@ -1596,9 +1205,7 @@ static const char *get_peer_addr_internal(int fd,
|
||||
}
|
||||
|
||||
if (pss == NULL) {
|
||||
pss = &ss;
|
||||
}
|
||||
if (plength == NULL) {
|
||||
pss = (struct sockaddr *)&ss;
|
||||
plength = &length;
|
||||
}
|
||||
|
||||
@ -1621,7 +1228,7 @@ static const char *get_peer_addr_internal(int fd,
|
||||
******************************************************************/
|
||||
|
||||
static bool matchname(const char *remotehost,
|
||||
const struct sockaddr_storage *pss,
|
||||
const struct sockaddr *pss,
|
||||
socklen_t len)
|
||||
{
|
||||
struct addrinfo *res = NULL;
|
||||
@ -1659,8 +1266,8 @@ static bool matchname(const char *remotehost,
|
||||
if (!res->ai_addr) {
|
||||
continue;
|
||||
}
|
||||
if (addr_equal((const struct sockaddr_storage *)res->ai_addr,
|
||||
pss)) {
|
||||
if (addr_equal((const struct sockaddr *)res->ai_addr,
|
||||
(struct sockaddr *)pss)) {
|
||||
freeaddrinfo(ailist);
|
||||
return true;
|
||||
}
|
||||
@ -1760,7 +1367,7 @@ const char *get_peer_name(int fd, bool force_lookup)
|
||||
if (!lp_hostname_lookups() && (force_lookup == false)) {
|
||||
length = sizeof(nc.ss);
|
||||
nc.name = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf),
|
||||
&nc.ss, &length);
|
||||
(struct sockaddr *)&nc.ss, &length);
|
||||
store_nc(&nc);
|
||||
lookup_nc(&nc);
|
||||
return nc.name ? nc.name : "UNKNOWN";
|
||||
@ -1769,10 +1376,10 @@ const char *get_peer_name(int fd, bool force_lookup)
|
||||
lookup_nc(&nc);
|
||||
|
||||
memset(&ss, '\0', sizeof(ss));
|
||||
p = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), &ss, &length);
|
||||
p = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), (struct sockaddr *)&ss, &length);
|
||||
|
||||
/* it might be the same as the last one - save some DNS work */
|
||||
if (addr_equal(&ss, &nc.ss)) {
|
||||
if (addr_equal((struct sockaddr *)&ss, (struct sockaddr *)&nc.ss)) {
|
||||
return nc.name ? nc.name : "UNKNOWN";
|
||||
}
|
||||
|
||||
@ -1797,7 +1404,7 @@ const char *get_peer_name(int fd, bool force_lookup)
|
||||
gai_strerror(ret)));
|
||||
strlcpy(name_buf, p, sizeof(name_buf));
|
||||
} else {
|
||||
if (!matchname(name_buf, &ss, length)) {
|
||||
if (!matchname(name_buf, (struct sockaddr *)&ss, length)) {
|
||||
DEBUG(0,("Matchname failed on %s %s\n",name_buf,p));
|
||||
strlcpy(name_buf,"UNKNOWN",sizeof(name_buf));
|
||||
}
|
||||
@ -2080,7 +1687,8 @@ bool is_myname_or_ipaddr(const char *s)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_zero_addr(&ss) || is_loopback_addr(&ss)) {
|
||||
if (is_zero_addr((struct sockaddr *)&ss) ||
|
||||
is_loopback_addr((struct sockaddr *)&ss)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2091,7 +1699,7 @@ bool is_myname_or_ipaddr(const char *s)
|
||||
}
|
||||
n = get_interfaces(nics, MAX_INTERFACES);
|
||||
for (i=0; i<n; i++) {
|
||||
if (addr_equal(&nics[i].ip, &ss)) {
|
||||
if (addr_equal((struct sockaddr *)&nics[i].ip, (struct sockaddr *)&ss)) {
|
||||
TALLOC_FREE(nics);
|
||||
return true;
|
||||
}
|
||||
|
@ -183,11 +183,11 @@ static void parse_ip(struct tagged_ip *ip, const char *str)
|
||||
char *s = strchr(str, ':');
|
||||
if (!s) {
|
||||
fstrcpy(ip->tag, "*");
|
||||
(void)interpret_addr2(&ip->ip,str);
|
||||
ip->ip = interpret_addr2(str);
|
||||
return;
|
||||
}
|
||||
|
||||
(void)interpret_addr2(&ip->ip,s+1);
|
||||
ip->ip = interpret_addr2(s+1);
|
||||
fstrcpy(ip->tag, str);
|
||||
s = strchr(ip->tag, ':');
|
||||
if (s) {
|
||||
|
@ -772,7 +772,8 @@ static char *get_kdc_ip_string(char *mem_ctx,
|
||||
get_kdc_list(realm, sitename, &ip_srv_site, &count_site);
|
||||
|
||||
for (i = 0; i < count_site; i++) {
|
||||
if (addr_equal(&ip_srv_site[i].ss, pss)) {
|
||||
if (addr_equal((struct sockaddr *)&ip_srv_site[i].ss,
|
||||
(struct sockaddr *)pss)) {
|
||||
continue;
|
||||
}
|
||||
/* Append to the string - inefficient
|
||||
@ -794,14 +795,14 @@ static char *get_kdc_ip_string(char *mem_ctx,
|
||||
for (i = 0; i < count_nonsite; i++) {
|
||||
int j;
|
||||
|
||||
if (addr_equal(&ip_srv_nonsite[i].ss, pss)) {
|
||||
if (addr_equal((struct sockaddr *)&ip_srv_nonsite[i].ss, (struct sockaddr *)pss)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ensure this isn't an IP already seen (YUK! this is n*n....) */
|
||||
for (j = 0; j < count_site; j++) {
|
||||
if (addr_equal(&ip_srv_nonsite[i].ss,
|
||||
&ip_srv_site[j].ss)) {
|
||||
if (addr_equal((struct sockaddr *)&ip_srv_nonsite[i].ss,
|
||||
(struct sockaddr *)&ip_srv_site[j].ss)) {
|
||||
break;
|
||||
}
|
||||
/* As the lists are sorted we can break early if nonsite > site. */
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "librpc/gen_ndr/ndr_svcctl.h"
|
||||
|
||||
#include "librpc/gen_ndr/ndr_misc.h"
|
||||
#include "librpc/gen_ndr/ndr_security.h"
|
||||
static enum ndr_err_code ndr_push_SERVICE_LOCK_STATUS(struct ndr_push *ndr, int ndr_flags, const struct SERVICE_LOCK_STATUS *r)
|
||||
{
|
||||
if (ndr_flags & NDR_SCALARS) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "librpc/gen_ndr/misc.h"
|
||||
#include "librpc/gen_ndr/security.h"
|
||||
#ifndef _HEADER_svcctl
|
||||
#define _HEADER_svcctl
|
||||
|
||||
@ -18,6 +19,14 @@
|
||||
#define SERVICE_STATE_INACTIVE ( 0x02 )
|
||||
#define SERVICE_STATE_ALL ( 0x03 )
|
||||
#define SV_TYPE_ALL ( 0xFFFFFFFF )
|
||||
#define SC_MANAGER_READ_ACCESS ( (SEC_STD_READ_CONTROL|SC_RIGHT_MGR_CONNECT|SC_RIGHT_MGR_ENUMERATE_SERVICE|SC_RIGHT_MGR_QUERY_LOCK_STATUS) )
|
||||
#define SC_MANAGER_EXECUTE_ACCESS ( SC_MANAGER_READ_ACCESS )
|
||||
#define SC_MANAGER_WRITE_ACCESS ( (SEC_STD_REQUIRED|SC_MANAGER_READ_ACCESS|SC_RIGHT_MGR_CREATE_SERVICE|SC_RIGHT_MGR_LOCK|SC_RIGHT_MGR_MODIFY_BOOT_CONFIG) )
|
||||
#define SC_MANAGER_ALL_ACCESS ( SC_MANAGER_WRITE_ACCESS )
|
||||
#define SERVICE_READ_ACCESS ( (SEC_STD_READ_CONTROL|SC_RIGHT_SVC_ENUMERATE_DEPENDENTS|SC_RIGHT_SVC_INTERROGATE|SC_RIGHT_SVC_QUERY_CONFIG|SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_USER_DEFINED_CONTROL) )
|
||||
#define SERVICE_EXECUTE_ACCESS ( (SERVICE_READ_ACCESS|SC_RIGHT_SVC_START|SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE) )
|
||||
#define SERVICE_WRITE_ACCESS ( (SEC_STD_REQUIRED|SERVICE_READ_ACCESS|SERVICE_EXECUTE_ACCESS|SC_RIGHT_SVC_CHANGE_CONFIG) )
|
||||
#define SERVICE_ALL_ACCESS ( SERVICE_WRITE_ACCESS )
|
||||
struct SERVICE_LOCK_STATUS {
|
||||
uint32_t is_locked;
|
||||
const char *lock_owner;/* [unique,charset(UTF16)] */
|
||||
|
@ -1514,7 +1514,7 @@ NTSTATUS cli_connect(struct cli_state *cli,
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
if (!dest_ss || is_zero_addr(dest_ss)) {
|
||||
if (!dest_ss || is_zero_addr((struct sockaddr *)dest_ss)) {
|
||||
NTSTATUS status =resolve_name_list(frame,
|
||||
cli->desthost,
|
||||
name_type,
|
||||
|
@ -656,7 +656,7 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
|
||||
* back to netbios lookups is that our DNS server doesn't know
|
||||
* anything about the DC's -- jerry */
|
||||
|
||||
if (!is_zero_addr(&r->ss)) {
|
||||
if (!is_zero_addr((struct sockaddr *)&r->ss)) {
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
@ -381,16 +381,16 @@ bool name_status_find(const char *q_name,
|
||||
comparison function used by sort_addr_list
|
||||
*/
|
||||
|
||||
static int addr_compare(const struct sockaddr_storage *ss1,
|
||||
const struct sockaddr_storage *ss2)
|
||||
static int addr_compare(const struct sockaddr *ss1,
|
||||
const struct sockaddr *ss2)
|
||||
{
|
||||
int max_bits1=0, max_bits2=0;
|
||||
int num_interfaces = iface_count();
|
||||
int i;
|
||||
|
||||
/* Sort IPv6 addresses first. */
|
||||
if (ss1->ss_family != ss2->ss_family) {
|
||||
if (ss2->ss_family == AF_INET) {
|
||||
if (ss1->sa_family != ss2->sa_family) {
|
||||
if (ss2->sa_family == AF_INET) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
@ -408,7 +408,7 @@ static int addr_compare(const struct sockaddr_storage *ss1,
|
||||
size_t len = 0;
|
||||
int bits1, bits2;
|
||||
|
||||
if (pss->ss_family != ss1->ss_family) {
|
||||
if (pss->ss_family != ss1->sa_family) {
|
||||
/* Ignore interfaces of the wrong type. */
|
||||
continue;
|
||||
}
|
||||
@ -443,14 +443,14 @@ static int addr_compare(const struct sockaddr_storage *ss1,
|
||||
|
||||
/* Bias towards directly reachable IPs */
|
||||
if (iface_local(ss1)) {
|
||||
if (ss1->ss_family == AF_INET) {
|
||||
if (ss1->sa_family == AF_INET) {
|
||||
max_bits1 += 32;
|
||||
} else {
|
||||
max_bits1 += 128;
|
||||
}
|
||||
}
|
||||
if (iface_local(ss2)) {
|
||||
if (ss2->ss_family == AF_INET) {
|
||||
if (ss2->sa_family == AF_INET) {
|
||||
max_bits2 += 32;
|
||||
} else {
|
||||
max_bits2 += 128;
|
||||
@ -467,7 +467,7 @@ int ip_service_compare(struct ip_service *ss1, struct ip_service *ss2)
|
||||
{
|
||||
int result;
|
||||
|
||||
if ((result = addr_compare(&ss1->ss, &ss2->ss)) != 0) {
|
||||
if ((result = addr_compare((struct sockaddr *)&ss1->ss, (struct sockaddr *)&ss2->ss)) != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -521,12 +521,12 @@ static int remove_duplicate_addrs2(struct ip_service *iplist, int count )
|
||||
|
||||
/* one loop to remove duplicates */
|
||||
for ( i=0; i<count; i++ ) {
|
||||
if ( is_zero_addr(&iplist[i].ss)) {
|
||||
if ( is_zero_addr((struct sockaddr *)&iplist[i].ss)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for ( j=i+1; j<count; j++ ) {
|
||||
if (addr_equal(&iplist[i].ss, &iplist[j].ss) &&
|
||||
if (addr_equal((struct sockaddr *)&iplist[i].ss, (struct sockaddr *)&iplist[j].ss) &&
|
||||
iplist[i].port == iplist[j].port) {
|
||||
zero_addr(&iplist[j].ss);
|
||||
}
|
||||
@ -536,7 +536,7 @@ static int remove_duplicate_addrs2(struct ip_service *iplist, int count )
|
||||
/* one loop to clean up any holes we left */
|
||||
/* first ip should never be a zero_ip() */
|
||||
for (i = 0; i<count; ) {
|
||||
if (is_zero_addr(&iplist[i].ss) ) {
|
||||
if (is_zero_addr((struct sockaddr *)&iplist[i].ss) ) {
|
||||
if (i != count-1) {
|
||||
memmove(&iplist[i], &iplist[i+1],
|
||||
(count - i - 1)*sizeof(iplist[i]));
|
||||
@ -1403,7 +1403,7 @@ static NTSTATUS resolve_ads(const char *name,
|
||||
* for falling back to netbios lookups is that our DNS server
|
||||
* doesn't know anything about the DC's -- jerry */
|
||||
|
||||
if (!is_zero_addr(&r->ss)) {
|
||||
if (!is_zero_addr((struct sockaddr *)&r->ss)) {
|
||||
(*return_count)++;
|
||||
}
|
||||
}
|
||||
@ -1632,8 +1632,8 @@ bool resolve_name(const char *name,
|
||||
|
||||
/* only return valid addresses for TCP connections */
|
||||
for (i=0; i<count; i++) {
|
||||
if (!is_zero_addr(&ss_list[i].ss) &&
|
||||
!is_broadcast_addr(&ss_list[i].ss)) {
|
||||
if (!is_zero_addr((struct sockaddr *)&ss_list[i].ss) &&
|
||||
!is_broadcast_addr((struct sockaddr *)&ss_list[i].ss)) {
|
||||
*return_ss = ss_list[i].ss;
|
||||
SAFE_FREE(ss_list);
|
||||
SAFE_FREE(sitename);
|
||||
@ -1696,8 +1696,8 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
|
||||
|
||||
/* only return valid addresses for TCP connections */
|
||||
for (i=0, num_entries = 0; i<count; i++) {
|
||||
if (!is_zero_addr(&ss_list[i].ss) &&
|
||||
!is_broadcast_addr(&ss_list[i].ss)) {
|
||||
if (!is_zero_addr((struct sockaddr *)&ss_list[i].ss) &&
|
||||
!is_broadcast_addr((struct sockaddr *)&ss_list[i].ss)) {
|
||||
num_entries++;
|
||||
}
|
||||
}
|
||||
@ -1715,8 +1715,8 @@ NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
|
||||
}
|
||||
|
||||
for (i=0, num_entries = 0; i<count; i++) {
|
||||
if (!is_zero_addr(&ss_list[i].ss) &&
|
||||
!is_broadcast_addr(&ss_list[i].ss)) {
|
||||
if (!is_zero_addr((struct sockaddr *)&ss_list[i].ss) &&
|
||||
!is_broadcast_addr((struct sockaddr *)&ss_list[i].ss)) {
|
||||
(*return_ss_arr)[num_entries++] = ss_list[i].ss;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ static bool rpc_dc_name(const char *domain,
|
||||
/* Remove the entry we've already failed with (should be the PDC). */
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (is_zero_addr(&ip_list[i].ss))
|
||||
if (is_zero_addr((struct sockaddr *)&ip_list[i].ss))
|
||||
continue;
|
||||
|
||||
if (name_status_find(domain, 0x1c, 0x20, &ip_list[i].ss, srv_name)) {
|
||||
|
@ -219,7 +219,7 @@ static void reload_interfaces(time_t t)
|
||||
* ignore it here. JRA.
|
||||
*/
|
||||
|
||||
if (is_loopback_addr(&iface->ip)) {
|
||||
if (is_loopback_addr((struct sockaddr *)&iface->ip)) {
|
||||
DEBUG(2,("reload_interfaces: Ignoring loopback "
|
||||
"interface %s\n",
|
||||
print_sockaddr(str, sizeof(str), &iface->ip) ));
|
||||
@ -397,7 +397,7 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
|
||||
}
|
||||
|
||||
in_addr_to_sockaddr_storage(&ss, p->ip);
|
||||
pss = iface_ip(&ss);
|
||||
pss = iface_ip((struct sockaddr *)&ss);
|
||||
|
||||
if (pss == NULL) {
|
||||
DEBUG(2, ("Could not find ip for packet from %d\n",
|
||||
|
@ -168,7 +168,8 @@ bool register_my_workgroup_and_names(void)
|
||||
namerec = find_name_on_subnet(unicast_subnet, &nmbname, FIND_SELF_NAME);
|
||||
if (namerec == NULL) continue;
|
||||
for (a=0;cluster_addresses[a];a++) {
|
||||
add_ip_to_name_record(namerec, *interpret_addr2(&ip, cluster_addresses[a]));
|
||||
ip = interpret_addr2(cluster_addresses[a]);
|
||||
add_ip_to_name_record(namerec, ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ struct response_record *queue_register_name( struct subnet_record *subrec,
|
||||
return NULL;
|
||||
|
||||
in_addr_to_sockaddr_storage(&ss, subrec->bcast_ip);
|
||||
pss = iface_ip(&ss);
|
||||
pss = iface_ip((struct sockaddr *)&ss);
|
||||
if (!pss || pss->ss_family != AF_INET) {
|
||||
p->locked = False;
|
||||
free_packet(p);
|
||||
|
@ -93,7 +93,7 @@ void process_logon_packet(struct packet_struct *p, char *buf,int len,
|
||||
struct in_addr ip;
|
||||
|
||||
in_addr_to_sockaddr_storage(&ss, p->ip);
|
||||
pss = iface_ip(&ss);
|
||||
pss = iface_ip((struct sockaddr *)&ss);
|
||||
if (!pss) {
|
||||
DEBUG(5,("process_logon_packet:can't find outgoing interface "
|
||||
"for packet from IP %s\n",
|
||||
|
@ -490,7 +490,7 @@ void announce_remote(time_t t)
|
||||
else
|
||||
wgroup = pwgroup;
|
||||
|
||||
(void)interpret_addr2(&addr,s2);
|
||||
addr = interpret_addr2(s2);
|
||||
|
||||
/* Announce all our names including aliases */
|
||||
/* Give the ip address as the address of our first
|
||||
@ -574,7 +574,7 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
|
||||
frame = talloc_stackframe();
|
||||
for (ptr=s; next_token_talloc(frame,&ptr,&s2,NULL); ) {
|
||||
/* The entries are of the form a.b.c.d */
|
||||
(void)interpret_addr2(&addr,s2);
|
||||
addr = interpret_addr2(s2);
|
||||
|
||||
DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
|
||||
global_myname(), inet_ntoa(addr) ));
|
||||
|
@ -260,7 +260,7 @@ bool create_subnets(void)
|
||||
* ignore it here. JRA.
|
||||
*/
|
||||
|
||||
if (is_loopback_addr(&iface->ip)) {
|
||||
if (is_loopback_addr((struct sockaddr *)&iface->ip)) {
|
||||
DEBUG(2,("create_subnets: Ignoring loopback interface.\n" ));
|
||||
continue;
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ bool initialise_wins(void)
|
||||
next_token_talloc(frame,&ptr,&ttl_str,NULL);
|
||||
for(i = 0; i < num_ips; i++) {
|
||||
next_token_talloc(frame,&ptr, &ip_str, NULL);
|
||||
(void)interpret_addr2(&ip_list[i], ip_str);
|
||||
ip_list[i] = interpret_addr2(ip_str);
|
||||
}
|
||||
next_token_talloc(frame,&ptr,&nb_flags_str,NULL);
|
||||
|
||||
@ -835,7 +835,7 @@ void wins_process_name_refresh_request( struct subnet_record *subrec,
|
||||
struct in_addr from_ip;
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
our_fake_ip = interpret_addr2("0.0.0.0");
|
||||
putip( (char *)&from_ip, &nmb->additional->rdata[2] );
|
||||
|
||||
if(bcast) {
|
||||
@ -1142,7 +1142,7 @@ void wins_process_name_registration_request(struct subnet_record *subrec,
|
||||
bool registering_group_name = (nb_flags & NB_GROUP) ? True : False;
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
our_fake_ip = interpret_addr2("0.0.0.0");
|
||||
putip((char *)&from_ip,&nmb->additional->rdata[2]);
|
||||
|
||||
if(bcast) {
|
||||
@ -1217,7 +1217,7 @@ to register name %s. Name already exists in WINS with source type %d.\n",
|
||||
*/
|
||||
|
||||
if(registering_group_name && (question->name_type != 0x1c)) {
|
||||
(void)interpret_addr2(&from_ip, "255.255.255.255");
|
||||
from_ip = interpret_addr2("255.255.255.255");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1424,7 +1424,7 @@ static void wins_multihomed_register_query_success(struct subnet_record *subrec,
|
||||
int ttl;
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
our_fake_ip = interpret_addr2("0.0.0.0");
|
||||
memcpy((char *)&orig_reg_packet, userdata->data, sizeof(struct packet_struct *));
|
||||
|
||||
nmb = &orig_reg_packet->packet.nmb;
|
||||
@ -1515,7 +1515,7 @@ void wins_process_multihomed_name_registration_request( struct subnet_record *su
|
||||
struct in_addr our_fake_ip;
|
||||
unstring qname;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
our_fake_ip = interpret_addr2("0.0.0.0");
|
||||
putip((char *)&from_ip,&nmb->additional->rdata[2]);
|
||||
|
||||
if(bcast) {
|
||||
@ -2141,7 +2141,7 @@ static int wins_processing_traverse_fn(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA
|
||||
struct name_record *namerec = NULL;
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
our_fake_ip = interpret_addr2("0.0.0.0");
|
||||
if (kbuf.dsize != sizeof(unstring) + 1) {
|
||||
return 0;
|
||||
}
|
||||
@ -2422,7 +2422,7 @@ void nmbd_wins_new_entry(struct messaging_context *msg,
|
||||
struct in_addr our_fake_ip;
|
||||
int i;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
our_fake_ip = interpret_addr2("0.0.0.0");
|
||||
if (buf==NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ bool global_machine_password_needs_changing;
|
||||
*
|
||||
* @note Not called by systems with a working /dev/urandom.
|
||||
*/
|
||||
static void get_rand_seed(int *new_seed)
|
||||
static void get_rand_seed(void *userdata, int *new_seed)
|
||||
{
|
||||
*new_seed = sys_getpid();
|
||||
if (db_ctx) {
|
||||
@ -81,7 +81,7 @@ bool secrets_init(void)
|
||||
* This avoids a problem where systems without /dev/urandom
|
||||
* could send the same challenge to multiple clients
|
||||
*/
|
||||
set_rand_reseed_callback(get_rand_seed);
|
||||
set_rand_reseed_callback(get_rand_seed, NULL);
|
||||
|
||||
/* Ensure that the reseed is done now, while we are root, etc */
|
||||
generate_random_buffer(&dummy, sizeof(dummy));
|
||||
|
@ -2573,13 +2573,13 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
|
||||
struct cli_state *the_cli;
|
||||
struct sockaddr_storage rm_addr;
|
||||
|
||||
if ( is_zero_addr(client_ss) ) {
|
||||
if ( is_zero_addr((struct sockaddr *)client_ss) ) {
|
||||
if ( !resolve_name( remote_machine, &rm_addr, 0x20) ) {
|
||||
DEBUG(2,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (ismyaddr(&rm_addr)) {
|
||||
if (ismyaddr((struct sockaddr *)&rm_addr)) {
|
||||
DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine));
|
||||
return False;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ bool net_find_server(struct net_context *c,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_zero_addr(&pdc_ss)) {
|
||||
if (is_zero_addr((struct sockaddr *)&pdc_ss)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -463,7 +463,7 @@ bool net_find_pdc(struct sockaddr_storage *server_ss,
|
||||
if (!get_pdc_ip(domain_name, server_ss)) {
|
||||
return false;
|
||||
}
|
||||
if (is_zero_addr(server_ss)) {
|
||||
if (is_zero_addr((struct sockaddr *)server_ss)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ int main(int argc,char *argv[])
|
||||
|
||||
if(lookup_by_ip) {
|
||||
struct sockaddr_storage ss;
|
||||
(void)interpret_addr2(&ip, lookup);
|
||||
ip = interpret_addr2(lookup);
|
||||
in_addr_to_sockaddr_storage(&ss, ip);
|
||||
fstrcpy(lookup,"*");
|
||||
do_node_status(ServerFD, lookup, lookup_type, &ss);
|
||||
|
@ -1129,7 +1129,7 @@ static bool do_nodestatus(struct messaging_context *msg_ctx,
|
||||
|
||||
ZERO_STRUCT(p);
|
||||
|
||||
(void)interpret_addr2(&p.ip, argv[1]);
|
||||
p.ip = interpret_addr2(argv[1]);
|
||||
p.port = 137;
|
||||
p.packet_type = NMB_PACKET;
|
||||
|
||||
|
@ -1038,7 +1038,7 @@ static bool add_one_dc_unique(TALLOC_CTX *mem_ctx, const char *domain_name,
|
||||
|
||||
/* Make sure there's no duplicates in the list */
|
||||
for (i=0; i<*num; i++)
|
||||
if (addr_equal(&(*dcs)[i].ss, pss))
|
||||
if (addr_equal((struct sockaddr *)&(*dcs)[i].ss, (struct sockaddr *)pss))
|
||||
return False;
|
||||
|
||||
*dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1);
|
||||
|
@ -800,7 +800,7 @@ static void parse_mount_smb(int argc, char **argv)
|
||||
DEBUGLEVEL = val;
|
||||
} else if(!strcmp(opts, "ip")) {
|
||||
dest_ip = interpret_addr2(opteq+1);
|
||||
if (is_zero_ip(dest_ip)) {
|
||||
if (is_zero_ip_v4(dest_ip)) {
|
||||
fprintf(stderr,"Can't resolve address %s\n", opteq+1);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ static struct interface *iface_find(struct interface *interfaces,
|
||||
struct in_addr ip, bool CheckMask)
|
||||
{
|
||||
struct interface *i;
|
||||
if (is_zero_ip(ip)) return interfaces;
|
||||
if (is_zero_ip_v4(ip)) return interfaces;
|
||||
|
||||
for (i=interfaces;i;i=i->next)
|
||||
if (CheckMask) {
|
||||
if (same_net(i->ip,ip,i->nmask)) return i;
|
||||
if (same_net_v4(i->ip,ip,i->nmask)) return i;
|
||||
} else if (i->ip.s_addr == ip.s_addr) return i;
|
||||
|
||||
return NULL;
|
||||
@ -173,7 +173,7 @@ static void interpret_interface(TALLOC_CTX *mem_ctx,
|
||||
if (ip.s_addr == MKBCADDR(ip.s_addr, nmask.s_addr) ||
|
||||
ip.s_addr == MKNETADDR(ip.s_addr, nmask.s_addr)) {
|
||||
for (i=0;i<total_probed;i++) {
|
||||
if (same_net(ip, probed_ifaces[i].ip, nmask)) {
|
||||
if (same_net_v4(ip, probed_ifaces[i].ip, nmask)) {
|
||||
add_interface(mem_ctx, probed_ifaces[i].ip, nmask,
|
||||
local_interfaces);
|
||||
talloc_free(address);
|
||||
@ -329,7 +329,7 @@ bool iface_is_local(struct interface *ifaces, const char *dest)
|
||||
*/
|
||||
bool iface_same_net(const char *ip1, const char *ip2, const char *netmask)
|
||||
{
|
||||
return same_net(interpret_addr2(ip1),
|
||||
return same_net_v4(interpret_addr2(ip1),
|
||||
interpret_addr2(ip2),
|
||||
interpret_addr2(netmask));
|
||||
}
|
||||
|
@ -198,40 +198,6 @@ NTSTATUS tdr_print_charset(struct tdr_print *tdr, const char *name, const char *
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
pull a ipv4address
|
||||
*/
|
||||
NTSTATUS tdr_pull_ipv4address(struct tdr_pull *tdr, TALLOC_CTX *ctx,
|
||||
const char **address)
|
||||
{
|
||||
struct in_addr in;
|
||||
TDR_CHECK(tdr_pull_uint32(tdr, ctx, &in.s_addr));
|
||||
in.s_addr = htonl(in.s_addr);
|
||||
*address = talloc_strdup(tdr, inet_ntoa(in));
|
||||
NT_STATUS_HAVE_NO_MEMORY(*address);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
push a ipv4address
|
||||
*/
|
||||
NTSTATUS tdr_push_ipv4address(struct tdr_push *tdr, const char **address)
|
||||
{
|
||||
uint32_t addr = htonl(interpret_addr(*address));
|
||||
TDR_CHECK(tdr_push_uint32(tdr, &addr));
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
print a ipv4address
|
||||
*/
|
||||
NTSTATUS tdr_print_ipv4address(struct tdr_print *tdr, const char *name,
|
||||
const char **address)
|
||||
{
|
||||
tdr->print(tdr, "%-25s: %s", name, *address);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
parse a hyper
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user