mirror of
https://github.com/samba-team/samba.git
synced 2025-02-22 05:57:43 +03:00
Remove more static data from lib/util_sock.c and
callers. Jeremy. (This used to be commit 35aaa36f82c70964cee5d0778eb04547b226dd3f)
This commit is contained in:
parent
56aa420195
commit
51a0354d75
@ -3485,7 +3485,7 @@ static int do_message_op(void)
|
||||
snprintf(name_type_hex, sizeof(name_type_hex), "#%X", name_type);
|
||||
fstrcat(server_name, name_type_hex);
|
||||
|
||||
zero_ip_v4(&ip);
|
||||
zero_ip_v4(&ip);
|
||||
if (have_ip)
|
||||
ip = dest_ip;
|
||||
|
||||
@ -3595,7 +3595,7 @@ static int do_message_op(void)
|
||||
break;
|
||||
case 'I':
|
||||
{
|
||||
dest_ip = *interpret_addr2(poptGetOptArg(pc));
|
||||
(void)interpret_addr2(&dest_ip, poptGetOptArg(pc));
|
||||
if (is_zero_ip_v4(dest_ip))
|
||||
exit(1);
|
||||
have_ip = True;
|
||||
|
@ -41,6 +41,7 @@ void set_local_machine_name(const char* local_name, bool perm)
|
||||
{
|
||||
static bool already_perm = False;
|
||||
fstring tmp_local_machine;
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
|
||||
fstrcpy(tmp_local_machine,local_name);
|
||||
trim_char(tmp_local_machine,' ',' ');
|
||||
@ -51,7 +52,7 @@ void set_local_machine_name(const char* local_name, bool perm)
|
||||
*/
|
||||
|
||||
if ( strequal(tmp_local_machine, "*SMBSERVER") || strequal(tmp_local_machine, "*SMBSERV") ) {
|
||||
fstrcpy( local_machine, client_socket_addr() );
|
||||
fstrcpy( local_machine, client_socket_addr(addr, sizeof(addr)) );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -499,7 +500,8 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
|
||||
client_addr(addr, sizeof(addr)));
|
||||
break;
|
||||
case 'i':
|
||||
a_string = realloc_string_sub( a_string, "%i", client_socket_addr() );
|
||||
a_string = realloc_string_sub( a_string, "%i",
|
||||
client_socket_addr(addr, sizeof(addr)) );
|
||||
break;
|
||||
case 'L' :
|
||||
if ( StrnCaseCmp(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
|
||||
|
@ -199,12 +199,11 @@ uint32 interpret_addr(const char *str)
|
||||
A convenient addition to interpret_addr().
|
||||
******************************************************************/
|
||||
|
||||
struct in_addr *interpret_addr2(const char *str)
|
||||
struct in_addr *interpret_addr2(struct in_addr *ip, const char *str)
|
||||
{
|
||||
static struct in_addr ret;
|
||||
uint32 a = interpret_addr(str);
|
||||
ret.s_addr = a;
|
||||
return(&ret);
|
||||
ip->s_addr = a;
|
||||
return ip;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -331,15 +330,7 @@ bool is_zero_addr(const struct sockaddr_storage *pss)
|
||||
|
||||
void zero_ip_v4(struct in_addr *ip)
|
||||
{
|
||||
static bool init;
|
||||
static struct in_addr ipzero;
|
||||
|
||||
if (!init) {
|
||||
ipzero = *interpret_addr2("0.0.0.0");
|
||||
init = true;
|
||||
}
|
||||
|
||||
*ip = ipzero;
|
||||
memset(ip, '\0', sizeof(struct in_addr));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -595,21 +586,20 @@ void client_setfd(int fd)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Return a static string of an IP address (IPv4 or IPv6).
|
||||
Return the string of an IP address (IPv4 or IPv6).
|
||||
****************************************************************************/
|
||||
|
||||
static const char *get_socket_addr(int fd)
|
||||
static const char *get_socket_addr(int fd, char *addr_buf, size_t addr_len)
|
||||
{
|
||||
struct sockaddr_storage sa;
|
||||
socklen_t length = sizeof(sa);
|
||||
static char addr_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
/* Ok, returning a hard coded IPv4 address
|
||||
* is bogus, but it's just as bogus as a
|
||||
* zero IPv6 address. No good choice here.
|
||||
*/
|
||||
|
||||
safe_strcpy(addr_buf, "0.0.0.0", sizeof(addr_buf)-1);
|
||||
safe_strcpy(addr_buf, "0.0.0.0", addr_len-1);
|
||||
|
||||
if (fd == -1) {
|
||||
return addr_buf;
|
||||
@ -621,7 +611,7 @@ static const char *get_socket_addr(int fd)
|
||||
return addr_buf;
|
||||
}
|
||||
|
||||
return print_sockaddr_len(addr_buf, sizeof(addr_buf), &sa, length);
|
||||
return print_sockaddr_len(addr_buf, addr_len, &sa, length);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -664,9 +654,9 @@ const char *client_addr(char *addr, size_t addrlen)
|
||||
return get_peer_addr(client_fd,addr,addrlen);
|
||||
}
|
||||
|
||||
const char *client_socket_addr(void)
|
||||
const char *client_socket_addr(char *addr, size_t addr_len)
|
||||
{
|
||||
return get_socket_addr(client_fd);
|
||||
return get_socket_addr(client_fd, addr, addr_len);
|
||||
}
|
||||
|
||||
int client_socket_port(void)
|
||||
@ -1672,9 +1662,9 @@ int open_udp_socket(const char *host, int port)
|
||||
int type = SOCK_DGRAM;
|
||||
struct sockaddr_in sock_out;
|
||||
int res;
|
||||
struct in_addr *addr;
|
||||
struct in_addr addr;
|
||||
|
||||
addr = interpret_addr2(host);
|
||||
(void)interpret_addr2(&addr, host);
|
||||
|
||||
res = socket(PF_INET, type, 0);
|
||||
if (res == -1) {
|
||||
@ -1682,7 +1672,7 @@ int open_udp_socket(const char *host, int port)
|
||||
}
|
||||
|
||||
memset((char *)&sock_out,'\0',sizeof(sock_out));
|
||||
putip((char *)&sock_out.sin_addr,(char *)addr);
|
||||
putip((char *)&sock_out.sin_addr,(char *)&addr);
|
||||
sock_out.sin_port = htons(port);
|
||||
sock_out.sin_family = PF_INET;
|
||||
|
||||
@ -1987,32 +1977,32 @@ out_umask:
|
||||
Get my own canonical name, including domain.
|
||||
****************************************************************************/
|
||||
|
||||
static fstring dnshostname_cache;
|
||||
|
||||
bool get_mydnsfullname(fstring my_dnsname)
|
||||
{
|
||||
static fstring dnshostname;
|
||||
|
||||
if (!*dnshostname) {
|
||||
if (!*dnshostname_cache) {
|
||||
struct addrinfo *res = NULL;
|
||||
bool ret;
|
||||
|
||||
/* get my host name */
|
||||
if (gethostname(dnshostname, sizeof(dnshostname)) == -1) {
|
||||
*dnshostname = '\0';
|
||||
if (gethostname(dnshostname_cache, sizeof(dnshostname_cache)) == -1) {
|
||||
*dnshostname_cache = '\0';
|
||||
DEBUG(0,("get_mydnsfullname: gethostname failed\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Ensure null termination. */
|
||||
dnshostname[sizeof(dnshostname)-1] = '\0';
|
||||
dnshostname_cache[sizeof(dnshostname_cache)-1] = '\0';
|
||||
|
||||
ret = interpret_string_addr_internal(&res,
|
||||
dnshostname,
|
||||
dnshostname_cache,
|
||||
AI_ADDRCONFIG|AI_CANONNAME);
|
||||
|
||||
if (!ret || res == NULL) {
|
||||
DEBUG(3,("get_mydnsfullname: getaddrinfo failed for "
|
||||
"name %s [%s]\n",
|
||||
dnshostname,
|
||||
dnshostname_cache,
|
||||
gai_strerror(ret) ));
|
||||
return false;
|
||||
}
|
||||
@ -2024,16 +2014,16 @@ bool get_mydnsfullname(fstring my_dnsname)
|
||||
if (res->ai_canonname == NULL) {
|
||||
DEBUG(3,("get_mydnsfullname: failed to get "
|
||||
"canonical name for %s\n",
|
||||
dnshostname));
|
||||
dnshostname_cache));
|
||||
freeaddrinfo(res);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
fstrcpy(dnshostname, res->ai_canonname);
|
||||
fstrcpy(dnshostname_cache, res->ai_canonname);
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
fstrcpy(my_dnsname, dnshostname);
|
||||
fstrcpy(my_dnsname, dnshostname_cache);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -183,14 +183,16 @@ static void parse_ip(struct tagged_ip *ip, const char *str)
|
||||
char *s = strchr(str, ':');
|
||||
if (!s) {
|
||||
fstrcpy(ip->tag, "*");
|
||||
ip->ip = *interpret_addr2(str);
|
||||
(void)interpret_addr2(&ip->ip,str);
|
||||
return;
|
||||
}
|
||||
|
||||
ip->ip = *interpret_addr2(s+1);
|
||||
(void)interpret_addr2(&ip->ip,s+1);
|
||||
fstrcpy(ip->tag, str);
|
||||
s = strchr(ip->tag, ':');
|
||||
if (s) *s = 0;
|
||||
if (s) {
|
||||
*s = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,12 +162,13 @@ bool register_my_workgroup_and_names(void)
|
||||
for(subrec = FIRST_SUBNET; subrec; subrec = subrec->next) {
|
||||
for (n=0;n<ARRAY_SIZE(name_types);n++) {
|
||||
struct name_record *namerec;
|
||||
struct nmb_name nmbname;
|
||||
struct nmb_name nmbname;
|
||||
struct in_addr ip;
|
||||
make_nmb_name(&nmbname, my_netbios_names(i), name_types[n]);
|
||||
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(cluster_addresses[a]));
|
||||
add_ip_to_name_record(namerec, *interpret_addr2(&ip, cluster_addresses[a]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ void announce_remote(time_t t)
|
||||
else
|
||||
wgroup = pwgroup;
|
||||
|
||||
addr = *interpret_addr2(s2);
|
||||
(void)interpret_addr2(&addr,s2);
|
||||
|
||||
/* Announce all our names including aliases */
|
||||
/* Give the ip address as the address of our first
|
||||
@ -569,7 +569,7 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
|
||||
|
||||
for (ptr=s; next_token(&ptr,s2,NULL,sizeof(s2)); ) {
|
||||
/* The entries are of the form a.b.c.d */
|
||||
addr = *interpret_addr2(s2);
|
||||
(void)interpret_addr2(&addr,s2);
|
||||
|
||||
DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
|
||||
global_myname(), inet_ntoa(addr) ));
|
||||
|
@ -680,7 +680,7 @@ bool initialise_wins(void)
|
||||
next_token(&ptr,ttl_str,NULL,sizeof(ttl_str));
|
||||
for(i = 0; i < num_ips; i++) {
|
||||
next_token(&ptr, ip_str, NULL, sizeof(ip_str));
|
||||
ip_list[i] = *interpret_addr2(ip_str);
|
||||
(void)interpret_addr2(&ip_list[i], ip_str);
|
||||
}
|
||||
next_token(&ptr,nb_flags_str,NULL, sizeof(nb_flags_str));
|
||||
|
||||
@ -810,8 +810,9 @@ void wins_process_name_refresh_request( struct subnet_record *subrec,
|
||||
struct name_record *namerec = NULL;
|
||||
int ttl = get_ttl_from_packet(nmb);
|
||||
struct in_addr from_ip;
|
||||
struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
putip( (char *)&from_ip, &nmb->additional->rdata[2] );
|
||||
|
||||
if(bcast) {
|
||||
@ -1116,8 +1117,9 @@ void wins_process_name_registration_request(struct subnet_record *subrec,
|
||||
struct name_record *namerec = NULL;
|
||||
struct in_addr from_ip;
|
||||
bool registering_group_name = (nb_flags & NB_GROUP) ? True : False;
|
||||
struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
putip((char *)&from_ip,&nmb->additional->rdata[2]);
|
||||
|
||||
if(bcast) {
|
||||
@ -1192,7 +1194,7 @@ to register name %s. Name already exists in WINS with source type %d.\n",
|
||||
*/
|
||||
|
||||
if(registering_group_name && (question->name_type != 0x1c)) {
|
||||
from_ip = *interpret_addr2("255.255.255.255");
|
||||
(void)interpret_addr2(&from_ip, "255.255.255.255");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1397,8 +1399,9 @@ static void wins_multihomed_register_query_success(struct subnet_record *subrec,
|
||||
struct name_record *namerec = NULL;
|
||||
struct in_addr from_ip;
|
||||
int ttl;
|
||||
struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
memcpy((char *)&orig_reg_packet, userdata->data, sizeof(struct packet_struct *));
|
||||
|
||||
nmb = &orig_reg_packet->packet.nmb;
|
||||
@ -1486,9 +1489,10 @@ void wins_process_multihomed_name_registration_request( struct subnet_record *su
|
||||
struct name_record *namerec = NULL;
|
||||
struct in_addr from_ip;
|
||||
bool group = (nb_flags & NB_GROUP) ? True : False;
|
||||
struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
|
||||
struct in_addr our_fake_ip;
|
||||
unstring qname;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
putip((char *)&from_ip,&nmb->additional->rdata[2]);
|
||||
|
||||
if(bcast) {
|
||||
@ -2112,8 +2116,9 @@ static int wins_processing_traverse_fn(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA
|
||||
time_t t = *(time_t *)state;
|
||||
bool store_record = False;
|
||||
struct name_record *namerec = NULL;
|
||||
struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
|
||||
struct in_addr our_fake_ip;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
if (kbuf.dsize != sizeof(unstring) + 1) {
|
||||
return 0;
|
||||
}
|
||||
@ -2381,9 +2386,10 @@ void nmbd_wins_new_entry(struct messaging_context *msg,
|
||||
struct name_record *new_namerec = NULL;
|
||||
struct nmb_name question;
|
||||
bool overwrite=False;
|
||||
struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
|
||||
struct in_addr our_fake_ip;
|
||||
int i;
|
||||
|
||||
(void)interpret_addr2(&our_fake_ip, "0.0.0.0");
|
||||
if (buf==NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ static NODE_STATUS_STRUCT *lookup_byaddr_backend(char *addr, int *count)
|
||||
return NULL;
|
||||
|
||||
make_nmb_name(&nname, "*", 0);
|
||||
ip = *interpret_addr2(addr);
|
||||
(void)interpret_addr2(&ip,addr);
|
||||
status = node_status_query(fd,&nname,ip, count, NULL);
|
||||
|
||||
close(fd);
|
||||
|
@ -405,7 +405,7 @@ enum client_action
|
||||
|
||||
case 'I':
|
||||
{
|
||||
cli_info.dest_ip = *interpret_addr2(optarg);
|
||||
(void)interpret_addr2(&cli_info.dest_ip, optarg);
|
||||
if (is_zero_ip(cli_info.dest_ip))
|
||||
{
|
||||
exit(1);
|
||||
|
@ -332,7 +332,7 @@ int main(int argc,char *argv[])
|
||||
|
||||
if(lookup_by_ip) {
|
||||
struct sockaddr_storage ss;
|
||||
ip = *interpret_addr2(lookup);
|
||||
(void)interpret_addr2(&ip, lookup);
|
||||
in_addr_to_sockaddr_storage(&ss, ip);
|
||||
fstrcpy(lookup,"*");
|
||||
do_node_status(ServerFD, lookup, lookup_type, &ss);
|
||||
|
@ -1087,7 +1087,7 @@ static bool do_nodestatus(struct messaging_context *msg_ctx,
|
||||
|
||||
ZERO_STRUCT(p);
|
||||
|
||||
p.ip = *interpret_addr2(argv[1]);
|
||||
(void)interpret_addr2(&p.ip, argv[1]);
|
||||
p.port = 137;
|
||||
p.packet_type = NMB_PACKET;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user