mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-20 19:52:10 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8389b943d3 | ||
|
|
f2266d9678 | ||
|
|
56bd806978 | ||
|
|
ac7eeea44d | ||
|
|
b741059549 | ||
|
|
cbd984287f | ||
|
|
32e15c3f45 | ||
|
|
f0dc324e35 | ||
|
|
f83c6cf51a | ||
|
|
c068b3ae2f | ||
|
|
adf9dec1e6 | ||
|
|
767d9cbd96 |
No files matched your search
@@ -76,6 +76,12 @@ version 2.86
|
|||||||
Disallowed queries are not forwarded; they are rejected
|
Disallowed queries are not forwarded; they are rejected
|
||||||
with a REFUSED error code.
|
with a REFUSED error code.
|
||||||
|
|
||||||
|
Allow smaller then 64 prefix lengths in synth-domain, with caveats.
|
||||||
|
--synth-domain=1234:4567::/56,example.com is now valid.
|
||||||
|
|
||||||
|
Make domains generated by --synth-domain appear in replies
|
||||||
|
when in authoritative mode.
|
||||||
|
|
||||||
|
|
||||||
version 2.85
|
version 2.85
|
||||||
Fix problem with DNS retries in 2.83/2.84.
|
Fix problem with DNS retries in 2.83/2.84.
|
||||||
|
|||||||
+10
-4
@@ -705,7 +705,8 @@ configured a zero is added in front of the label. ::1 becomes 0--1.
|
|||||||
V4 mapped IPv6 addresses, which have a representation like ::ffff:1.2.3.4 are handled specially, and become like 0--ffff-1-2-3-4
|
V4 mapped IPv6 addresses, which have a representation like ::ffff:1.2.3.4 are handled specially, and become like 0--ffff-1-2-3-4
|
||||||
|
|
||||||
The address range can be of the form
|
The address range can be of the form
|
||||||
<ip address>,<ip address> or <ip address>/<netmask> in both forms of the option.
|
<start address>,<end address> or <ip address>/<prefix-length> in both forms of the option. For IPv6 the start and end addresses
|
||||||
|
must fall in the same /64 network, or prefix-length must be greater than or equal to 64 except that shorter prefix lengths than 64 are allowed only if non-sequential names are in use.
|
||||||
.TP
|
.TP
|
||||||
.B --dumpfile=<path/to/file>
|
.B --dumpfile=<path/to/file>
|
||||||
Specify the location of a pcap-format file which dnsmasq uses to dump copies of network packets for debugging purposes. If the file exists when dnsmasq starts, it is not deleted; new packets are added to the end.
|
Specify the location of a pcap-format file which dnsmasq uses to dump copies of network packets for debugging purposes. If the file exists when dnsmasq starts, it is not deleted; new packets are added to the end.
|
||||||
@@ -1612,10 +1613,11 @@ tried. This flag disables this check. Use with caution.
|
|||||||
Extra logging for DHCP: log all the options sent to DHCP clients and
|
Extra logging for DHCP: log all the options sent to DHCP clients and
|
||||||
the tags used to determine them.
|
the tags used to determine them.
|
||||||
.TP
|
.TP
|
||||||
.B --quiet-dhcp, --quiet-dhcp6, --quiet-ra
|
.B --quiet-dhcp, --quiet-dhcp6, --quiet-ra, --quiet-tftp
|
||||||
Suppress logging of the routine operation of these protocols. Errors and
|
Suppress logging of the routine operation of these protocols. Errors and
|
||||||
problems will still be logged. \fB--quiet-dhcp\fP and quiet-dhcp6 are
|
problems will still be logged. \fB--quiet-tftp\fP does not consider file not
|
||||||
over-ridden by \fB--log-dhcp\fP.
|
found to be an error. \fB--quiet-dhcp\fP and quiet-dhcp6 are over-ridden by
|
||||||
|
\fB--log-dhcp\fP.
|
||||||
.TP
|
.TP
|
||||||
.B \-l, --dhcp-leasefile=<path>
|
.B \-l, --dhcp-leasefile=<path>
|
||||||
Use the specified file to store DHCP lease information.
|
Use the specified file to store DHCP lease information.
|
||||||
@@ -2417,6 +2419,10 @@ following data is used to populate the authoritative zone.
|
|||||||
.B --mx-host, --srv-host, --dns-rr, --txt-record, --naptr-record, --caa-record,
|
.B --mx-host, --srv-host, --dns-rr, --txt-record, --naptr-record, --caa-record,
|
||||||
as long as the record names are in the authoritative domain.
|
as long as the record names are in the authoritative domain.
|
||||||
.PP
|
.PP
|
||||||
|
.B --synth-domain
|
||||||
|
as long as the domain is in the authoritative zone and, for
|
||||||
|
reverse (PTR) queries, the address is in the relevant subnet.
|
||||||
|
.PP
|
||||||
.B --cname
|
.B --cname
|
||||||
as long as the record name is in the authoritative domain. If the
|
as long as the record name is in the authoritative domain. If the
|
||||||
target of the CNAME is unqualified, then it is qualified with the
|
target of the CNAME is unqualified, then it is qualified with the
|
||||||
|
|||||||
+38
-1
@@ -105,7 +105,7 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
int nameoffset, axfroffset = 0;
|
int nameoffset, axfroffset = 0;
|
||||||
int q, anscount = 0, authcount = 0;
|
int q, anscount = 0, authcount = 0;
|
||||||
struct crec *crecp;
|
struct crec *crecp;
|
||||||
int auth = !local_query, trunc = 0, nxdomain = 1, soa = 0, ns = 0, axfr = 0;
|
int auth = !local_query, trunc = 0, nxdomain = 1, soa = 0, ns = 0, axfr = 0, out_of_zone = 0;
|
||||||
struct auth_zone *zone = NULL;
|
struct auth_zone *zone = NULL;
|
||||||
struct addrlist *subnet = NULL;
|
struct addrlist *subnet = NULL;
|
||||||
char *cut;
|
char *cut;
|
||||||
@@ -146,6 +146,7 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
if (qclass != C_IN)
|
if (qclass != C_IN)
|
||||||
{
|
{
|
||||||
auth = 0;
|
auth = 0;
|
||||||
|
out_of_zone = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +160,7 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
|
|
||||||
if (!zone)
|
if (!zone)
|
||||||
{
|
{
|
||||||
|
out_of_zone = 1;
|
||||||
auth = 0;
|
auth = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -253,6 +255,17 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
|
|
||||||
} while ((crecp = cache_find_by_addr(crecp, &addr, now, flag)));
|
} while ((crecp = cache_find_by_addr(crecp, &addr, now, flag)));
|
||||||
|
|
||||||
|
if (!found && is_rev_synth(flag, &addr, name) && (local_query || in_zone(zone, name, NULL)))
|
||||||
|
{
|
||||||
|
log_query(F_CONFIG | F_REVERSE | flag, name, &addr, NULL);
|
||||||
|
found = 1;
|
||||||
|
|
||||||
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
daemon->auth_ttl, NULL,
|
||||||
|
T_PTR, C_IN, "d", name))
|
||||||
|
anscount++;
|
||||||
|
}
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
nxdomain = 0;
|
nxdomain = 0;
|
||||||
else
|
else
|
||||||
@@ -273,6 +286,7 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
|
|
||||||
if (!zone)
|
if (!zone)
|
||||||
{
|
{
|
||||||
|
out_of_zone = 1;
|
||||||
auth = 0;
|
auth = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -401,6 +415,17 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found && is_name_synthetic(flag, name, &addr) )
|
||||||
|
{
|
||||||
|
found = 1;
|
||||||
|
nxdomain = 0;
|
||||||
|
|
||||||
|
log_query(F_FORWARD | F_CONFIG | flag, name, &addr, NULL);
|
||||||
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
daemon->auth_ttl, NULL, qtype, C_IN, qtype == T_A ? "4" : "6", &addr))
|
||||||
|
anscount++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!cut)
|
if (!cut)
|
||||||
{
|
{
|
||||||
nxdomain = 0;
|
nxdomain = 0;
|
||||||
@@ -855,10 +880,22 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
SET_RCODE(header, NXDOMAIN);
|
SET_RCODE(header, NXDOMAIN);
|
||||||
else
|
else
|
||||||
SET_RCODE(header, NOERROR); /* no error */
|
SET_RCODE(header, NOERROR); /* no error */
|
||||||
|
|
||||||
header->ancount = htons(anscount);
|
header->ancount = htons(anscount);
|
||||||
header->nscount = htons(authcount);
|
header->nscount = htons(authcount);
|
||||||
header->arcount = htons(0);
|
header->arcount = htons(0);
|
||||||
|
|
||||||
|
if (!local_query && out_of_zone)
|
||||||
|
{
|
||||||
|
SET_RCODE(header, REFUSED);
|
||||||
|
header->ancount = htons(0);
|
||||||
|
header->nscount = htons(0);
|
||||||
|
addr.log.rcode = REFUSED;
|
||||||
|
addr.log.ede = EDE_NOT_AUTH;
|
||||||
|
log_query(F_UPSTREAM | F_RCODE, "error", &addr, NULL);
|
||||||
|
return resize_packet(header, ansp - (unsigned char *)header, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Advertise our packet size limit in our reply */
|
/* Advertise our packet size limit in our reply */
|
||||||
if (have_pseudoheader)
|
if (have_pseudoheader)
|
||||||
return add_pseudoheader(header, ansp - (unsigned char *)header, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0);
|
return add_pseudoheader(header, ansp - (unsigned char *)header, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0);
|
||||||
|
|||||||
+2
-2
@@ -1974,7 +1974,7 @@ void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg)
|
|||||||
source = "reply";
|
source = "reply";
|
||||||
else if (flags & F_SECSTAT)
|
else if (flags & F_SECSTAT)
|
||||||
{
|
{
|
||||||
if (addr && addr->log.ede != EDE_UNSET)
|
if (addr && addr->log.ede != EDE_UNSET && option_bool(OPT_EXTRALOG))
|
||||||
{
|
{
|
||||||
extra = daemon->addrbuff;
|
extra = daemon->addrbuff;
|
||||||
sprintf(extra, " (EDE: %s)", edestr(addr->log.ede));
|
sprintf(extra, " (EDE: %s)", edestr(addr->log.ede));
|
||||||
@@ -2023,5 +2023,5 @@ void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
my_syslog(LOG_INFO, "%s %s %s %s", source, name, verb, dest);
|
my_syslog(LOG_INFO, "%s %s %s %s%s", source, name, verb, dest, extra);
|
||||||
}
|
}
|
||||||
+5
-3
@@ -107,6 +107,7 @@ typedef unsigned long long u64;
|
|||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -273,7 +274,8 @@ struct event_desc {
|
|||||||
#define OPT_UMBRELLA 63
|
#define OPT_UMBRELLA 63
|
||||||
#define OPT_UMBRELLA_DEVID 64
|
#define OPT_UMBRELLA_DEVID 64
|
||||||
#define OPT_CMARK_ALST_EN 65
|
#define OPT_CMARK_ALST_EN 65
|
||||||
#define OPT_LAST 66
|
#define OPT_QUIET_TFTP 66
|
||||||
|
#define OPT_LAST 67
|
||||||
|
|
||||||
#define OPTION_BITS (sizeof(unsigned int)*8)
|
#define OPTION_BITS (sizeof(unsigned int)*8)
|
||||||
#define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) )
|
#define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) )
|
||||||
@@ -959,10 +961,10 @@ struct dhcp_bridge {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cond_domain {
|
struct cond_domain {
|
||||||
char *domain, *prefix;
|
char *domain, *prefix; /* prefix is text-prefix on domain name */
|
||||||
struct in_addr start, end;
|
struct in_addr start, end;
|
||||||
struct in6_addr start6, end6;
|
struct in6_addr start6, end6;
|
||||||
int is6, indexed;
|
int is6, indexed, prefixlen;
|
||||||
struct cond_domain *next;
|
struct cond_domain *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+34
-30
@@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
|
|
||||||
static struct cond_domain *search_domain(struct in_addr addr, struct cond_domain *c);
|
static struct cond_domain *search_domain(struct in_addr addr, struct cond_domain *c);
|
||||||
|
static int match_domain(struct in_addr addr, struct cond_domain *c);
|
||||||
static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c);
|
static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c);
|
||||||
|
static int match_domain6(struct in6_addr *addr, struct cond_domain *c);
|
||||||
|
|
||||||
int is_name_synthetic(int flags, char *name, union all_addr *addr)
|
int is_name_synthetic(int flags, char *name, union all_addr *addr)
|
||||||
{
|
{
|
||||||
@@ -135,26 +136,7 @@ int is_name_synthetic(int flags, char *name, union all_addr *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hostname_isequal(c->domain, p+1) && inet_pton(prot, tail, addr))
|
if (hostname_isequal(c->domain, p+1) && inet_pton(prot, tail, addr))
|
||||||
{
|
found = (prot == AF_INET) ? match_domain(addr->addr4, c) : match_domain6(&addr->addr6, c);
|
||||||
if (prot == AF_INET)
|
|
||||||
{
|
|
||||||
if (!c->is6 &&
|
|
||||||
ntohl(addr->addr4.s_addr) >= ntohl(c->start.s_addr) &&
|
|
||||||
ntohl(addr->addr4.s_addr) <= ntohl(c->end.s_addr))
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u64 addrpart = addr6part(&addr->addr6);
|
|
||||||
|
|
||||||
if (c->is6 &&
|
|
||||||
is_same_net6(&addr->addr6, &c->start6, 64) &&
|
|
||||||
addrpart >= addr6part(&c->start6) &&
|
|
||||||
addrpart <= addr6part(&c->end6))
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore name */
|
/* restore name */
|
||||||
@@ -246,12 +228,20 @@ int is_rev_synth(int flag, union all_addr *addr, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int match_domain(struct in_addr addr, struct cond_domain *c)
|
||||||
|
{
|
||||||
|
if (!c->is6 &&
|
||||||
|
ntohl(addr.s_addr) >= ntohl(c->start.s_addr) &&
|
||||||
|
ntohl(addr.s_addr) <= ntohl(c->end.s_addr))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct cond_domain *search_domain(struct in_addr addr, struct cond_domain *c)
|
static struct cond_domain *search_domain(struct in_addr addr, struct cond_domain *c)
|
||||||
{
|
{
|
||||||
for (; c; c = c->next)
|
for (; c; c = c->next)
|
||||||
if (!c->is6 &&
|
if (match_domain(addr, c))
|
||||||
ntohl(addr.s_addr) >= ntohl(c->start.s_addr) &&
|
|
||||||
ntohl(addr.s_addr) <= ntohl(c->end.s_addr))
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -267,16 +257,30 @@ char *get_domain(struct in_addr addr)
|
|||||||
return daemon->domain_suffix;
|
return daemon->domain_suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int match_domain6(struct in6_addr *addr, struct cond_domain *c)
|
||||||
static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c)
|
|
||||||
{
|
{
|
||||||
u64 addrpart = addr6part(addr);
|
u64 addrpart = addr6part(addr);
|
||||||
|
|
||||||
|
if (c->is6)
|
||||||
|
{
|
||||||
|
if (c->prefixlen >= 64)
|
||||||
|
{
|
||||||
|
if (is_same_net6(addr, &c->start6, 64) &&
|
||||||
|
addrpart >= addr6part(&c->start6) &&
|
||||||
|
addrpart <= addr6part(&c->end6))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (is_same_net6(addr, &c->start6, c->prefixlen))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c)
|
||||||
|
{
|
||||||
for (; c; c = c->next)
|
for (; c; c = c->next)
|
||||||
if (c->is6 &&
|
if (match_domain6(addr, c))
|
||||||
is_same_net6(addr, &c->start6, 64) &&
|
|
||||||
addrpart >= addr6part(&c->start6) &&
|
|
||||||
addrpart <= addr6part(&c->end6))
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
+1
-1
@@ -537,7 +537,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
{
|
{
|
||||||
u16 swap = htons((u16)ede);
|
u16 swap = htons((u16)ede);
|
||||||
|
|
||||||
if (ede != -EDE_UNSET)
|
if (ede != EDE_UNSET)
|
||||||
plen = add_pseudoheader(header, plen, (unsigned char *)limit, daemon->edns_pktsz, EDNS0_OPTION_EDE, (unsigned char *)&swap, 2, do_bit, 0);
|
plen = add_pseudoheader(header, plen, (unsigned char *)limit, daemon->edns_pktsz, EDNS0_OPTION_EDE, (unsigned char *)&swap, 2, do_bit, 0);
|
||||||
else
|
else
|
||||||
plen = add_pseudoheader(header, plen, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0);
|
plen = add_pseudoheader(header, plen, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0);
|
||||||
|
|||||||
+37
-17
@@ -173,6 +173,7 @@ struct myoption {
|
|||||||
#define LOPT_UMBRELLA 364
|
#define LOPT_UMBRELLA 364
|
||||||
#define LOPT_CMARK_ALST_EN 365
|
#define LOPT_CMARK_ALST_EN 365
|
||||||
#define LOPT_CMARK_ALST 366
|
#define LOPT_CMARK_ALST 366
|
||||||
|
#define LOPT_QUIET_TFTP 367
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
static const struct option opts[] =
|
static const struct option opts[] =
|
||||||
@@ -351,6 +352,7 @@ static const struct myoption opts[] =
|
|||||||
{ "dynamic-host", 1, 0, LOPT_DYNHOST },
|
{ "dynamic-host", 1, 0, LOPT_DYNHOST },
|
||||||
{ "log-debug", 0, 0, LOPT_LOG_DEBUG },
|
{ "log-debug", 0, 0, LOPT_LOG_DEBUG },
|
||||||
{ "umbrella", 2, 0, LOPT_UMBRELLA },
|
{ "umbrella", 2, 0, LOPT_UMBRELLA },
|
||||||
|
{ "quiet-tftp", 0, 0, LOPT_QUIET_TFTP },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -536,6 +538,7 @@ static struct {
|
|||||||
{ LOPT_DUMPMASK, ARG_ONE, "<hex>", gettext_noop("Mask which packets to dump"), NULL },
|
{ LOPT_DUMPMASK, ARG_ONE, "<hex>", gettext_noop("Mask which packets to dump"), NULL },
|
||||||
{ LOPT_SCRIPT_TIME, OPT_LEASE_RENEW, NULL, gettext_noop("Call dhcp-script when lease expiry changes."), NULL },
|
{ LOPT_SCRIPT_TIME, OPT_LEASE_RENEW, NULL, gettext_noop("Call dhcp-script when lease expiry changes."), NULL },
|
||||||
{ LOPT_UMBRELLA, ARG_ONE, "[=<optspec>]", gettext_noop("Send Cisco Umbrella identifiers including remote IP."), NULL },
|
{ LOPT_UMBRELLA, ARG_ONE, "[=<optspec>]", gettext_noop("Send Cisco Umbrella identifiers including remote IP."), NULL },
|
||||||
|
{ LOPT_QUIET_TFTP, OPT_QUIET_TFTP, NULL, gettext_noop("Do not log routine TFTP."), NULL },
|
||||||
{ 0, 0, NULL, NULL, NULL }
|
{ 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -651,7 +654,7 @@ static char *canonicalise_opt(char *s)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strlen(s) == 0)
|
if (strlen(s) == 0)
|
||||||
return "";
|
return opt_string_alloc("");
|
||||||
|
|
||||||
unhide_metas(s);
|
unhide_metas(s);
|
||||||
if (!(ret = canonicalise(s, &nomem)) && nomem)
|
if (!(ret = canonicalise(s, &nomem)) && nomem)
|
||||||
@@ -965,7 +968,7 @@ static int domain_rev6(char *domain, struct in6_addr *addr, int msize)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (msize%4)
|
if (msize > 128 || msize%4)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*domain = 0;
|
*domain = 0;
|
||||||
@@ -1185,11 +1188,15 @@ static int parse_dhcp_opt(char *errstr, char *arg, int flags)
|
|||||||
{
|
{
|
||||||
new->u.vendor_class = (unsigned char *)opt_string_alloc(arg+7);
|
new->u.vendor_class = (unsigned char *)opt_string_alloc(arg+7);
|
||||||
new->flags |= DHOPT_VENDOR;
|
new->flags |= DHOPT_VENDOR;
|
||||||
|
if ((new->flags & DHOPT_ENCAPSULATE) || flags == DHOPT_MATCH)
|
||||||
|
goto_err(_("inappropriate vendor:"));
|
||||||
}
|
}
|
||||||
else if (strstr(arg, "encap:") == arg)
|
else if (strstr(arg, "encap:") == arg)
|
||||||
{
|
{
|
||||||
new->u.encap = atoi(arg+6);
|
new->u.encap = atoi(arg+6);
|
||||||
new->flags |= DHOPT_ENCAPSULATE;
|
new->flags |= DHOPT_ENCAPSULATE;
|
||||||
|
if ((new->flags & DHOPT_VENDOR) || flags == DHOPT_MATCH)
|
||||||
|
goto_err(_("inappropriate encap:"));
|
||||||
}
|
}
|
||||||
else if (strstr(arg, "vi-encap:") == arg)
|
else if (strstr(arg, "vi-encap:") == arg)
|
||||||
{
|
{
|
||||||
@@ -2224,7 +2231,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
arg = comma;
|
arg = comma;
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
daemon->hostmaster = opt_string_alloc(arg);
|
daemon->hostmaster = opt_string_alloc(arg);
|
||||||
for (cp = daemon->hostmaster; *cp; cp++)
|
for (cp = daemon->hostmaster; cp && *cp; cp++)
|
||||||
if (*cp == '@')
|
if (*cp == '@')
|
||||||
*cp = '.';
|
*cp = '.';
|
||||||
|
|
||||||
@@ -2254,10 +2261,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
{
|
{
|
||||||
char *d, *d_raw = arg;
|
char *d, *d_raw = arg;
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
if (!(d = canonicalise_opt(arg)))
|
if (!(d = canonicalise_opt(d_raw)))
|
||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
free(d); /* allocate this again below. */
|
||||||
if (comma)
|
if (comma)
|
||||||
{
|
{
|
||||||
struct cond_domain *new = opt_malloc(sizeof(struct cond_domain));
|
struct cond_domain *new = opt_malloc(sizeof(struct cond_domain));
|
||||||
@@ -2265,6 +2273,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
|
|
||||||
new->prefix = NULL;
|
new->prefix = NULL;
|
||||||
new->indexed = 0;
|
new->indexed = 0;
|
||||||
|
new->prefixlen = 0;
|
||||||
|
|
||||||
unhide_metas(comma);
|
unhide_metas(comma);
|
||||||
if ((netpart = split_chr(comma, '/')))
|
if ((netpart = split_chr(comma, '/')))
|
||||||
@@ -2276,7 +2285,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
ret_err_free(gen_err, new);
|
ret_err_free(gen_err, new);
|
||||||
else if (inet_pton(AF_INET, comma, &new->start))
|
else if (inet_pton(AF_INET, comma, &new->start))
|
||||||
{
|
{
|
||||||
int mask = (1 << (32 - msize)) - 1;
|
int mask;
|
||||||
|
|
||||||
|
if (msize > 32)
|
||||||
|
ret_err_free(_("bad prefix length"), new);
|
||||||
|
|
||||||
|
mask = (1 << (32 - msize)) - 1;
|
||||||
new->is6 = 0;
|
new->is6 = 0;
|
||||||
new->start.s_addr = ntohl(htonl(new->start.s_addr) & ~mask);
|
new->start.s_addr = ntohl(htonl(new->start.s_addr) & ~mask);
|
||||||
new->end.s_addr = new->start.s_addr | htonl(mask);
|
new->end.s_addr = new->start.s_addr | htonl(mask);
|
||||||
@@ -2307,21 +2321,25 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
}
|
}
|
||||||
else if (inet_pton(AF_INET6, comma, &new->start6))
|
else if (inet_pton(AF_INET6, comma, &new->start6))
|
||||||
{
|
{
|
||||||
u64 mask = (1LLU << (128 - msize)) - 1LLU;
|
u64 mask, addrpart = addr6part(&new->start6);
|
||||||
u64 addrpart = addr6part(&new->start6);
|
|
||||||
|
if (msize > 128)
|
||||||
|
ret_err_free(_("bad prefix length"), new);
|
||||||
|
|
||||||
|
mask = (1LLU << (128 - msize)) - 1LLU;
|
||||||
|
|
||||||
new->is6 = 1;
|
new->is6 = 1;
|
||||||
|
new->prefixlen = msize;
|
||||||
|
|
||||||
/* prefix==64 overflows the mask calculation above */
|
/* prefix==64 overflows the mask calculation above */
|
||||||
if (msize == 64)
|
if (msize <= 64)
|
||||||
mask = (u64)-1LL;
|
mask = (u64)-1LL;
|
||||||
|
|
||||||
new->end6 = new->start6;
|
new->end6 = new->start6;
|
||||||
setaddr6part(&new->start6, addrpart & ~mask);
|
setaddr6part(&new->start6, addrpart & ~mask);
|
||||||
setaddr6part(&new->end6, addrpart | mask);
|
setaddr6part(&new->end6, addrpart | mask);
|
||||||
|
|
||||||
if (msize < 64)
|
if (arg)
|
||||||
ret_err_free(gen_err, new);
|
|
||||||
else if (arg)
|
|
||||||
{
|
{
|
||||||
if (option != 's')
|
if (option != 's')
|
||||||
{
|
{
|
||||||
@@ -2381,7 +2399,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new->domain = d;
|
new->domain = canonicalise_opt(d_raw);
|
||||||
if (option == 's')
|
if (option == 's')
|
||||||
{
|
{
|
||||||
new->next = daemon->cond_domain;
|
new->next = daemon->cond_domain;
|
||||||
@@ -2390,19 +2408,21 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *star;
|
char *star;
|
||||||
new->next = daemon->synth_domains;
|
|
||||||
daemon->synth_domains = new;
|
|
||||||
if (new->prefix &&
|
if (new->prefix &&
|
||||||
(star = strrchr(new->prefix, '*'))
|
(star = strrchr(new->prefix, '*'))
|
||||||
&& *(star+1) == 0)
|
&& *(star+1) == 0)
|
||||||
{
|
{
|
||||||
*star = 0;
|
*star = 0;
|
||||||
new->indexed = 1;
|
new->indexed = 1;
|
||||||
|
if (new->is6 && new->prefixlen < 64)
|
||||||
|
ret_err_free(_("prefix length too small"), new);
|
||||||
}
|
}
|
||||||
|
new->next = daemon->synth_domains;
|
||||||
|
daemon->synth_domains = new;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (option == 's')
|
else if (option == 's')
|
||||||
daemon->domain_suffix = d;
|
daemon->domain_suffix = canonicalise_opt(d_raw);
|
||||||
else
|
else
|
||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
}
|
}
|
||||||
@@ -4163,13 +4183,13 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
new->interface = opt_string_alloc(split(comma));
|
new->interface = opt_string_alloc(split(comma));
|
||||||
new->iface_index = 0;
|
new->iface_index = 0;
|
||||||
if (inet_pton(AF_INET, arg, &new->local) && inet_pton(AF_INET, comma, &new->server))
|
if (comma && inet_pton(AF_INET, arg, &new->local) && inet_pton(AF_INET, comma, &new->server))
|
||||||
{
|
{
|
||||||
new->next = daemon->relay4;
|
new->next = daemon->relay4;
|
||||||
daemon->relay4 = new;
|
daemon->relay4 = new;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
else if (inet_pton(AF_INET6, arg, &new->local) && inet_pton(AF_INET6, comma, &new->server))
|
else if (comma && inet_pton(AF_INET6, arg, &new->local) && inet_pton(AF_INET6, comma, &new->server))
|
||||||
{
|
{
|
||||||
new->next = daemon->relay6;
|
new->next = daemon->relay6;
|
||||||
daemon->relay6 = new;
|
daemon->relay6 = new;
|
||||||
|
|||||||
+2
-1
@@ -761,7 +761,8 @@ static ssize_t tftp_err(int err, char *packet, char *message, char *file)
|
|||||||
len = snprintf(mess->message, MAXMESSAGE, message, file, errstr);
|
len = snprintf(mess->message, MAXMESSAGE, message, file, errstr);
|
||||||
ret += (len < MAXMESSAGE) ? len + 1 : MAXMESSAGE; /* include terminating zero */
|
ret += (len < MAXMESSAGE) ? len + 1 : MAXMESSAGE; /* include terminating zero */
|
||||||
|
|
||||||
my_syslog(MS_TFTP | LOG_ERR, "%s", mess->message);
|
if (err != ERR_FNF || !option_bool(OPT_QUIET_TFTP))
|
||||||
|
my_syslog(MS_TFTP | LOG_ERR, "%s", mess->message);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user