mirror of
https://github.com/samba-team/samba.git
synced 2025-03-12 20:58:37 +03:00
Merge commit '5e95c548864bc8b075b8343e69a69e1a22c92456' into 3.2-trivial
This commit is contained in:
commit
f8580abbd5
@ -545,7 +545,7 @@ SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \
|
|||||||
PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_aix.o \
|
PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_aix.o \
|
||||||
printing/print_cups.o printing/print_generic.o \
|
printing/print_cups.o printing/print_generic.o \
|
||||||
printing/lpq_parse.o printing/load.o \
|
printing/lpq_parse.o printing/load.o \
|
||||||
printing/print_iprint.o printing/print_test.o
|
printing/print_iprint.o
|
||||||
|
|
||||||
PRINTBASE_OBJ = printing/notify.o printing/printing_db.o
|
PRINTBASE_OBJ = printing/notify.o printing/printing_db.o
|
||||||
PRINTBACKEND_OBJ = printing/printing.o printing/nt_printing.o $(PRINTBASE_OBJ)
|
PRINTBACKEND_OBJ = printing/printing.o printing/nt_printing.o $(PRINTBASE_OBJ)
|
||||||
|
@ -460,7 +460,13 @@ static void interpret_interface(char *token)
|
|||||||
|
|
||||||
/* maybe it is a DNS name */
|
/* maybe it is a DNS name */
|
||||||
p = strchr_m(token,'/');
|
p = strchr_m(token,'/');
|
||||||
if (!p && interpret_string_addr(&ss, token)) {
|
if (p == NULL) {
|
||||||
|
if (!interpret_string_addr(&ss, token)) {
|
||||||
|
DEBUG(2, ("interpret_interface: Can't find address "
|
||||||
|
"for %s\n", token));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0;i<total_probed;i++) {
|
for (i=0;i<total_probed;i++) {
|
||||||
if (addr_equal(&ss, &probed_ifaces[i].ip)) {
|
if (addr_equal(&ss, &probed_ifaces[i].ip)) {
|
||||||
add_interface(&probed_ifaces[i]);
|
add_interface(&probed_ifaces[i]);
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
|
#include "lib/replace/replace.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Try the "standard" getifaddrs/freeifaddrs interfaces.
|
Try the "standard" getifaddrs/freeifaddrs interfaces.
|
||||||
@ -136,7 +137,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
|
|||||||
memcpy(&ifaces[total].ip, ifptr->ifa_addr, copy_size);
|
memcpy(&ifaces[total].ip, ifptr->ifa_addr, copy_size);
|
||||||
memcpy(&ifaces[total].netmask, ifptr->ifa_netmask, copy_size);
|
memcpy(&ifaces[total].netmask, ifptr->ifa_netmask, copy_size);
|
||||||
|
|
||||||
if ((ifaces[total].flags & IFF_BROADCAST) &&
|
if ((ifaces[total].flags & (IFF_BROADCAST|IFF_LOOPBACK)) &&
|
||||||
ifptr->ifa_broadaddr) {
|
ifptr->ifa_broadaddr) {
|
||||||
memcpy(&ifaces[total].bcast,
|
memcpy(&ifaces[total].bcast,
|
||||||
ifptr->ifa_broadaddr,
|
ifptr->ifa_broadaddr,
|
||||||
@ -150,9 +151,8 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ifaces[total].name, ifptr->ifa_name,
|
strlcpy(ifaces[total].name, ifptr->ifa_name,
|
||||||
sizeof(ifaces[total].name)-1);
|
sizeof(ifaces[total].name));
|
||||||
ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
|
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,9 +218,8 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ifaces[total].name, ifr[i].ifr_name,
|
strlcpy(ifaces[total].name, ifr[i].ifr_name,
|
||||||
sizeof(ifaces[total].name)-1);
|
sizeof(ifaces[total].name));
|
||||||
ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
|
|
||||||
|
|
||||||
memcpy(&ifaces[total].ip, &ifr[i].ifr_addr,
|
memcpy(&ifaces[total].ip, &ifr[i].ifr_addr,
|
||||||
sizeof(struct sockaddr_in));
|
sizeof(struct sockaddr_in));
|
||||||
@ -331,9 +330,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ifaces[total].name, iname,
|
strlcpy(ifaces[total].name, iname, sizeof(ifaces[total].name));
|
||||||
sizeof(ifaces[total].name)-1);
|
|
||||||
ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
|
|
||||||
|
|
||||||
memcpy(&ifaces[total].ip, &ifreq.ifr_addr,
|
memcpy(&ifaces[total].ip, &ifreq.ifr_addr,
|
||||||
sizeof(struct sockaddr_in));
|
sizeof(struct sockaddr_in));
|
||||||
@ -436,9 +433,8 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
|
|||||||
memcpy(&ifaces[total].ip, &ifr->ifr_addr,
|
memcpy(&ifaces[total].ip, &ifr->ifr_addr,
|
||||||
sizeof(struct sockaddr_in));
|
sizeof(struct sockaddr_in));
|
||||||
|
|
||||||
strncpy(ifaces[total].name, ifr->ifr_name,
|
strlcpy(ifaces[total].name, ifr->ifr_name,
|
||||||
sizeof(ifaces[total].name)-1);
|
sizeof(ifaces[total].name));
|
||||||
ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
|
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
|
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
|
||||||
goto next;
|
goto next;
|
||||||
@ -549,10 +545,10 @@ static int iface_comp(struct iface_struct *i1, struct iface_struct *i2)
|
|||||||
s1 = (struct sockaddr_in *)&i1->netmask;
|
s1 = (struct sockaddr_in *)&i1->netmask;
|
||||||
s2 = (struct sockaddr_in *)&i2->netmask;
|
s2 = (struct sockaddr_in *)&i2->netmask;
|
||||||
|
|
||||||
r = ntohl(s1->sin_addr.s_addr) -
|
return ntohl(s1->sin_addr.s_addr) -
|
||||||
ntohl(s2->sin_addr.s_addr);
|
ntohl(s2->sin_addr.s_addr);
|
||||||
}
|
}
|
||||||
return r;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_interfaces(struct iface_struct *ifaces, int max_interfaces);
|
int get_interfaces(struct iface_struct *ifaces, int max_interfaces);
|
||||||
|
@ -1546,42 +1546,103 @@ int open_udp_socket(const char *host, int port)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
Return the IP addr of the remote end of a socket as a string.
|
||||||
|
Optionally return the struct sockaddr_storage.
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
|
static const char *get_peer_addr_internal(int fd,
|
||||||
|
struct sockaddr_storage *pss,
|
||||||
|
socklen_t *plength)
|
||||||
|
{
|
||||||
|
struct sockaddr_storage ss;
|
||||||
|
socklen_t length = sizeof(ss);
|
||||||
|
static char addr_buf[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
|
safe_strcpy(addr_buf,"0.0.0.0",sizeof(addr_buf)-1);
|
||||||
|
|
||||||
|
if (fd == -1) {
|
||||||
|
return addr_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pss == NULL) {
|
||||||
|
pss = &ss;
|
||||||
|
}
|
||||||
|
if (plength == NULL) {
|
||||||
|
plength = &length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getpeername(fd, (struct sockaddr *)pss, plength) < 0) {
|
||||||
|
DEBUG(0,("getpeername failed. Error was %s\n",
|
||||||
|
strerror(errno) ));
|
||||||
|
return addr_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_sockaddr(addr_buf,
|
||||||
|
sizeof(addr_buf),
|
||||||
|
pss,
|
||||||
|
*plength);
|
||||||
|
return addr_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Matchname - determine if host name matches IP address. Used to
|
Matchname - determine if host name matches IP address. Used to
|
||||||
confirm a hostname lookup to prevent spoof attacks.
|
confirm a hostname lookup to prevent spoof attacks.
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
static bool matchname(char *remotehost,struct in_addr addr)
|
static bool matchname(const char *remotehost,
|
||||||
|
const struct sockaddr_storage *pss,
|
||||||
|
socklen_t len)
|
||||||
{
|
{
|
||||||
struct hostent *hp;
|
struct addrinfo hints;
|
||||||
int i;
|
struct addrinfo *res = NULL;
|
||||||
|
struct addrinfo *ailist = NULL;
|
||||||
|
char addr_buf[INET6_ADDRSTRLEN];
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if ((hp = sys_gethostbyname(remotehost)) == 0) {
|
memset(&hints,'\0',sizeof(struct addrinfo));
|
||||||
DEBUG(0,("sys_gethostbyname(%s): lookup failure.\n",
|
/* By default make sure it supports TCP. */
|
||||||
remotehost));
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_ADDRCONFIG|AI_CANONNAME;
|
||||||
|
|
||||||
|
ret = getaddrinfo(remotehost, NULL,
|
||||||
|
&hints,
|
||||||
|
&res);
|
||||||
|
|
||||||
|
if (ret || res == NULL) {
|
||||||
|
DEBUG(3,("matchname: getaddrinfo failed for "
|
||||||
|
"name %s [%s]\n",
|
||||||
|
remotehost,
|
||||||
|
gai_strerror(ret) ));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that gethostbyname() returns the "correct" host name.
|
* Make sure that getaddrinfo() returns the "correct" host name.
|
||||||
* Unfortunately, gethostbyname("localhost") sometimes yields
|
|
||||||
* "localhost.domain". Since the latter host name comes from the
|
|
||||||
* local DNS, we just have to trust it (all bets are off if the local
|
|
||||||
* DNS is perverted). We always check the address list, though.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!strequal(remotehost, hp->h_name)
|
if (res->ai_canonname == NULL ||
|
||||||
&& !strequal(remotehost, "localhost")) {
|
(!strequal(remotehost, res->ai_canonname) &&
|
||||||
DEBUG(0,("host name/name mismatch: %s != %s\n",
|
!strequal(remotehost, "localhost"))) {
|
||||||
remotehost, hp->h_name));
|
DEBUG(0,("matchname: host name/name mismatch: %s != %s\n",
|
||||||
|
remotehost,
|
||||||
|
res->ai_canonname ? res->ai_canonname : "(NULL)"));
|
||||||
|
freeaddrinfo(res);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look up the host address in the address list we just got. */
|
/* Look up the host address in the address list we just got. */
|
||||||
for (i = 0; hp->h_addr_list[i]; i++) {
|
for (ailist = res; ailist; ailist = ailist->ai_next) {
|
||||||
if (memcmp(hp->h_addr_list[i], (char *)&addr,sizeof(addr)) == 0)
|
if (!ailist->ai_addr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (addr_equal((const struct sockaddr_storage *)ailist->ai_addr,
|
||||||
|
pss)) {
|
||||||
|
freeaddrinfo(res);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The host name does not map to the original host address. Perhaps
|
* The host name does not map to the original host address. Perhaps
|
||||||
@ -1589,8 +1650,14 @@ static bool matchname(char *remotehost,struct in_addr addr)
|
|||||||
* it, but that could be dangerous, too.
|
* it, but that could be dangerous, too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUG(0,("host name/address mismatch: %s != %s\n",
|
DEBUG(0,("matchname: host name/address mismatch: %s != %s\n",
|
||||||
inet_ntoa(addr), hp->h_name));
|
print_sockaddr(addr_buf,
|
||||||
|
sizeof(addr_buf),
|
||||||
|
pss,
|
||||||
|
len),
|
||||||
|
res->ai_canonname ? res->ai_canonname : "(NULL)"));
|
||||||
|
|
||||||
|
freeaddrinfo(res);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1600,12 +1667,13 @@ static bool matchname(char *remotehost,struct in_addr addr)
|
|||||||
|
|
||||||
const char *get_peer_name(int fd, bool force_lookup)
|
const char *get_peer_name(int fd, bool force_lookup)
|
||||||
{
|
{
|
||||||
static pstring name_buf;
|
|
||||||
pstring tmp_name;
|
|
||||||
static fstring addr_buf;
|
static fstring addr_buf;
|
||||||
struct hostent *hp;
|
static pstring name_buf;
|
||||||
struct in_addr addr;
|
struct sockaddr_storage ss;
|
||||||
|
socklen_t length = sizeof(ss);
|
||||||
const char *p;
|
const char *p;
|
||||||
|
int ret;
|
||||||
|
pstring tmp_name;
|
||||||
|
|
||||||
/* reverse lookups can be *very* expensive, and in many
|
/* reverse lookups can be *very* expensive, and in many
|
||||||
situations won't work because many networks don't link dhcp
|
situations won't work because many networks don't link dhcp
|
||||||
@ -1615,28 +1683,37 @@ const char *get_peer_name(int fd, bool force_lookup)
|
|||||||
return get_peer_addr(fd);
|
return get_peer_addr(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = get_peer_addr(fd);
|
p = get_peer_addr_internal(fd, &ss, &length);
|
||||||
|
|
||||||
/* it might be the same as the last one - save some DNS work */
|
/* it might be the same as the last one - save some DNS work */
|
||||||
if (strcmp(p, addr_buf) == 0)
|
if (strcmp(p, addr_buf) == 0) {
|
||||||
return name_buf;
|
return name_buf;
|
||||||
|
}
|
||||||
|
|
||||||
pstrcpy(name_buf,"UNKNOWN");
|
pstrcpy(name_buf,"UNKNOWN");
|
||||||
if (fd == -1)
|
if (fd == -1) {
|
||||||
return name_buf;
|
return name_buf;
|
||||||
|
}
|
||||||
|
|
||||||
fstrcpy(addr_buf, p);
|
fstrcpy(addr_buf, p);
|
||||||
|
|
||||||
addr = *interpret_addr2(p);
|
|
||||||
|
|
||||||
/* Look up the remote host name. */
|
/* Look up the remote host name. */
|
||||||
if ((hp = gethostbyaddr((char *)&addr.s_addr,
|
ret = getnameinfo((struct sockaddr *)&ss,
|
||||||
sizeof(addr.s_addr), AF_INET)) == 0) {
|
length,
|
||||||
DEBUG(1,("Gethostbyaddr failed for %s\n",p));
|
name_buf,
|
||||||
|
sizeof(name_buf),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NI_NUMERICHOST);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
DEBUG(1,("get_peer_name: getnameinfo failed "
|
||||||
|
"for %s with error %s\n",
|
||||||
|
p,
|
||||||
|
gai_strerror(ret)));
|
||||||
pstrcpy(name_buf, p);
|
pstrcpy(name_buf, p);
|
||||||
} else {
|
} else {
|
||||||
pstrcpy(name_buf,(char *)hp->h_name);
|
if (!matchname(name_buf, &ss, length)) {
|
||||||
if (!matchname(name_buf, addr)) {
|
|
||||||
DEBUG(0,("Matchname failed on %s %s\n",name_buf,p));
|
DEBUG(0,("Matchname failed on %s %s\n",name_buf,p));
|
||||||
pstrcpy(name_buf,"UNKNOWN");
|
pstrcpy(name_buf,"UNKNOWN");
|
||||||
}
|
}
|
||||||
@ -1661,27 +1738,7 @@ const char *get_peer_name(int fd, bool force_lookup)
|
|||||||
|
|
||||||
const char *get_peer_addr(int fd)
|
const char *get_peer_addr(int fd)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage ss;
|
return get_peer_addr_internal(fd, NULL, NULL);
|
||||||
socklen_t length = sizeof(ss);
|
|
||||||
static char addr_buf[INET6_ADDRSTRLEN];
|
|
||||||
|
|
||||||
safe_strcpy(addr_buf,"0.0.0.0",sizeof(addr_buf)-1);
|
|
||||||
|
|
||||||
if (fd == -1) {
|
|
||||||
return addr_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr *)&ss, &length) < 0) {
|
|
||||||
DEBUG(0,("getpeername failed. Error was %s\n",
|
|
||||||
strerror(errno) ));
|
|
||||||
return addr_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_sockaddr(addr_buf,
|
|
||||||
sizeof(addr_buf),
|
|
||||||
&ss,
|
|
||||||
length);
|
|
||||||
return addr_buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
@ -1789,8 +1846,9 @@ bool is_myname_or_ipaddr(const char *s)
|
|||||||
fstring name, dnsname;
|
fstring name, dnsname;
|
||||||
char *servername;
|
char *servername;
|
||||||
|
|
||||||
if ( !s )
|
if ( !s ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* santize the string from '\\name' */
|
/* santize the string from '\\name' */
|
||||||
|
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Printing backend for the build farm
|
|
||||||
*
|
|
||||||
* Copyright (C) Volker Lendecke 2006
|
|
||||||
*
|
|
||||||
* 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"
|
|
||||||
#include "printing.h"
|
|
||||||
|
|
||||||
#if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
|
|
||||||
|
|
||||||
static int test_queue_get(const char *printer_name,
|
|
||||||
enum printing_types printing_type,
|
|
||||||
char *lpq_command,
|
|
||||||
print_queue_struct **q,
|
|
||||||
print_status_struct *status)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_queue_pause(int snum)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_queue_resume(int snum)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_job_delete(const char *sharename, const char *lprm_command,
|
|
||||||
struct printjob *pjob)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_job_pause(int snum, struct printjob *pjob)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_job_resume(int snum, struct printjob *pjob)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int test_job_submit(int snum, struct printjob *pjob)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct printif test_printif =
|
|
||||||
{
|
|
||||||
PRINT_TEST,
|
|
||||||
test_queue_get,
|
|
||||||
test_queue_pause,
|
|
||||||
test_queue_resume,
|
|
||||||
test_job_delete,
|
|
||||||
test_job_pause,
|
|
||||||
test_job_resume,
|
|
||||||
test_job_submit,
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* this keeps fussy compilers happy */
|
|
||||||
void print_test_dummy(void);
|
|
||||||
void print_test_dummy(void) {}
|
|
||||||
#endif /* DEVELOPER||ENABLE_BUILD_FARM_HACKS */
|
|
Loading…
x
Reference in New Issue
Block a user