mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
import of dnsmasq-2.24.tar.gz
This commit is contained in:
19
src/cache.c
19
src/cache.c
@@ -562,7 +562,7 @@ static void read_hostsfile(char *filename, int opts, char *buff, char *domain_su
|
||||
|
||||
if (!f)
|
||||
{
|
||||
syslog(LOG_ERR, "failed to load names from %s: %m", filename);
|
||||
syslog(LOG_ERR, _("failed to load names from %s: %m"), filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,10 @@ static void read_hostsfile(char *filename, int opts, char *buff, char *domain_su
|
||||
}
|
||||
#endif
|
||||
else
|
||||
continue;
|
||||
{
|
||||
syslog(LOG_ERR, _("bad address at %s line %d"), filename, lineno);
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((token = strtok(NULL, " \t\n\r")) && (*token != '#'))
|
||||
{
|
||||
@@ -622,13 +625,13 @@ static void read_hostsfile(char *filename, int opts, char *buff, char *domain_su
|
||||
}
|
||||
}
|
||||
else
|
||||
syslog(LOG_ERR, "bad name at %s line %d", filename, lineno);
|
||||
syslog(LOG_ERR, _("bad name at %s line %d"), filename, lineno);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
syslog(LOG_INFO, "read %s - %d addresses", filename, count);
|
||||
syslog(LOG_INFO, _("read %s - %d addresses"), filename, count);
|
||||
}
|
||||
|
||||
void cache_reload(int opts, char *buff, char *domain_suffix, struct hostsfile *addn_hosts)
|
||||
@@ -664,7 +667,7 @@ void cache_reload(int opts, char *buff, char *domain_suffix, struct hostsfile *a
|
||||
if ((opts & OPT_NO_HOSTS) && !addn_hosts)
|
||||
{
|
||||
if (cache_size > 0)
|
||||
syslog(LOG_INFO, "cleared cache");
|
||||
syslog(LOG_INFO, _("cleared cache"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -717,8 +720,8 @@ void cache_add_dhcp_entry(struct daemon *daemon, char *host_name,
|
||||
{
|
||||
strcpy(daemon->namebuff, inet_ntoa(crec->addr.addr.addr.addr4));
|
||||
syslog(LOG_WARNING,
|
||||
"not giving name %s to the DHCP lease of %s because "
|
||||
"the name exists in %s with address %s",
|
||||
_("not giving name %s to the DHCP lease of %s because "
|
||||
"the name exists in %s with address %s"),
|
||||
host_name, inet_ntoa(*host_address),
|
||||
record_source(daemon->addn_hosts, crec->uid), daemon->namebuff);
|
||||
}
|
||||
@@ -761,7 +764,7 @@ void cache_add_dhcp_entry(struct daemon *daemon, char *host_name,
|
||||
|
||||
void dump_cache(struct daemon *daemon)
|
||||
{
|
||||
syslog(LOG_INFO, "cache size %d, %d/%d cache insertions re-used unexpired cache entries.",
|
||||
syslog(LOG_INFO, _("cache size %d, %d/%d cache insertions re-used unexpired cache entries."),
|
||||
daemon->cachesize, cache_live_freed, cache_inserted);
|
||||
|
||||
if (daemon->options & (OPT_DEBUG | OPT_LOG))
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
/* Author's email: simon@thekelleys.org.uk */
|
||||
|
||||
#define VERSION "2.23"
|
||||
#define VERSION "2.24"
|
||||
|
||||
#define FTABSIZ 150 /* max number of outstanding requests */
|
||||
#define MAX_PROCS 20 /* max no children for TCP requests */
|
||||
|
||||
@@ -109,7 +109,7 @@ static void dbus_read_servers(struct daemon *daemon, DBusMessage *message)
|
||||
}
|
||||
|
||||
#ifndef HAVE_IPV6
|
||||
syslog(LOG_WARNING, "attempt to set an IPv6 server address via DBus - no IPv6 support");
|
||||
syslog(LOG_WARNING, _("attempt to set an IPv6 server address via DBus - no IPv6 support"));
|
||||
#else
|
||||
if (i == sizeof(struct in6_addr)-1)
|
||||
{
|
||||
@@ -234,7 +234,7 @@ DBusHandlerResult message_handler (DBusConnection *connection,
|
||||
}
|
||||
else if (strcmp(method, "SetServers") == 0)
|
||||
{
|
||||
syslog(LOG_INFO, "setting upstream servers from DBus");
|
||||
syslog(LOG_INFO, _("setting upstream servers from DBus"));
|
||||
dbus_read_servers(daemon, message);
|
||||
check_servers(daemon);
|
||||
}
|
||||
@@ -270,7 +270,7 @@ char *dbus_init(struct daemon *daemon)
|
||||
|
||||
if (!dbus_connection_register_object_path(connection, DNSMASQ_PATH,
|
||||
&dnsmasq_vtable, daemon))
|
||||
return "could not register a DBus message handler";
|
||||
return _("could not register a DBus message handler");
|
||||
|
||||
daemon->dbus = connection;
|
||||
|
||||
|
||||
76
src/dhcp.c
76
src/dhcp.c
@@ -22,7 +22,7 @@ void dhcp_init(struct daemon *daemon)
|
||||
struct dhcp_config *configs, *cp;
|
||||
|
||||
if (fd == -1)
|
||||
die ("cannot create DHCP socket : %s", NULL);
|
||||
die (_("cannot create DHCP socket : %s"), NULL);
|
||||
|
||||
if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
|
||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1 ||
|
||||
@@ -32,14 +32,14 @@ void dhcp_init(struct daemon *daemon)
|
||||
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &oneopt, sizeof(oneopt)) == -1 ||
|
||||
#endif
|
||||
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &oneopt, sizeof(oneopt)) == -1)
|
||||
die("failed to set options on DHCP socket: %s", NULL);
|
||||
die(_("failed to set options on DHCP socket: %s"), NULL);
|
||||
|
||||
/* When bind-interfaces is set, there might be more than one dnmsasq
|
||||
instance binding port 67. That's Ok if they serve different networks.
|
||||
Need to set REUSEADDR to make this posible. */
|
||||
if ((daemon->options & OPT_NOWILD) &&
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt)) == -1)
|
||||
die("failed to set SO_REUSEADDR on DHCP socket: %s", NULL);
|
||||
die(_("failed to set SO_REUSEADDR on DHCP socket: %s"), NULL);
|
||||
|
||||
saddr.sin_family = AF_INET;
|
||||
saddr.sin_port = htons(DHCP_SERVER_PORT);
|
||||
@@ -49,7 +49,7 @@ void dhcp_init(struct daemon *daemon)
|
||||
#endif
|
||||
|
||||
if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)))
|
||||
die("failed to bind DHCP server socket: %s", NULL);
|
||||
die(_("failed to bind DHCP server socket: %s"), NULL);
|
||||
|
||||
daemon->dhcpfd = fd;
|
||||
|
||||
@@ -58,7 +58,7 @@ void dhcp_init(struct daemon *daemon)
|
||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1 ||
|
||||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &oneopt, sizeof(oneopt)) == -1 ||
|
||||
setsockopt(fd, SOL_SOCKET, SO_DONTROUTE, &zeroopt, sizeof(zeroopt)) == -1)
|
||||
die("cannot create ICMP raw socket: %s.", NULL);
|
||||
die(_("cannot create ICMP raw socket: %s."), NULL);
|
||||
|
||||
daemon->dhcp_icmp_fd = fd;
|
||||
|
||||
@@ -72,7 +72,7 @@ void dhcp_init(struct daemon *daemon)
|
||||
if ((fd = open(filename, O_RDWR, 0)) != -1)
|
||||
break;
|
||||
if (errno != EBUSY)
|
||||
die("cannot create DHCP BPF socket: %s", NULL);
|
||||
die(_("cannot create DHCP BPF socket: %s"), NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -83,8 +83,8 @@ void dhcp_init(struct daemon *daemon)
|
||||
rejected as non-sensical by some BSD kernels) */
|
||||
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETHERTYPE_IP))) == -1 ||
|
||||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &oneopt, sizeof(oneopt)) == -1)
|
||||
die("cannot create DHCP packet socket: %s. "
|
||||
"Is CONFIG_PACKET enabled in your kernel?", NULL);
|
||||
die(_("cannot create DHCP packet socket: %s. "
|
||||
"Is CONFIG_PACKET enabled in your kernel?"), NULL);
|
||||
#endif
|
||||
|
||||
daemon->dhcp_raw_fd = fd;
|
||||
@@ -95,7 +95,7 @@ void dhcp_init(struct daemon *daemon)
|
||||
for (configs = daemon->dhcp_conf; configs; configs = configs->next)
|
||||
for (cp = configs->next; cp; cp = cp->next)
|
||||
if ((configs->flags & cp->flags & CONFIG_ADDR) && configs->addr.s_addr == cp->addr.s_addr)
|
||||
die("duplicate IP address %s in dhcp-config directive.", inet_ntoa(cp->addr));
|
||||
die(_("duplicate IP address %s in dhcp-config directive."), inet_ntoa(cp->addr));
|
||||
|
||||
daemon->dhcp_packet = safe_malloc(sizeof(struct udp_dhcp_packet));
|
||||
/* These two each hold a DHCP option max size 255
|
||||
@@ -116,6 +116,7 @@ void dhcp_packet(struct daemon *daemon, time_t now)
|
||||
struct iovec iov[2];
|
||||
struct cmsghdr *cmptr;
|
||||
int sz, newlen, iface_index = 0;
|
||||
int unicast_dest = 0;
|
||||
struct in_addr iface_addr;
|
||||
#ifdef HAVE_BPF
|
||||
unsigned char iface_hwaddr[ETHER_ADDR_LEN];
|
||||
@@ -151,19 +152,23 @@ void dhcp_packet(struct daemon *daemon, time_t now)
|
||||
return;
|
||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
||||
iface_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
||||
|
||||
{
|
||||
iface_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
||||
if (((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_addr.s_addr != INADDR_BROADCAST)
|
||||
unicast_dest = 1;
|
||||
}
|
||||
|
||||
if (!(ifr.ifr_ifindex = iface_index) ||
|
||||
ioctl(daemon->dhcpfd, SIOCGIFNAME, &ifr) == -1)
|
||||
return;
|
||||
|
||||
|
||||
#elif defined(IP_RECVIF)
|
||||
if (msg.msg_controllen < sizeof(struct cmsghdr))
|
||||
return;
|
||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||
iface_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
||||
|
||||
|
||||
if (!iface_index || !if_indextoname(iface_index, ifr.ifr_name))
|
||||
return;
|
||||
|
||||
@@ -233,7 +238,7 @@ void dhcp_packet(struct daemon *daemon, time_t now)
|
||||
}
|
||||
|
||||
lease_prune(NULL, now); /* lose any expired leases */
|
||||
newlen = dhcp_reply(daemon, context, ifr.ifr_name, sz, now);
|
||||
newlen = dhcp_reply(daemon, context, ifr.ifr_name, sz, now, unicast_dest);
|
||||
lease_update_file(0, now);
|
||||
lease_update_dns(daemon);
|
||||
|
||||
@@ -376,7 +381,7 @@ struct dhcp_context *complete_context(struct daemon *daemon, struct in_addr loca
|
||||
{
|
||||
strcpy(daemon->dhcp_buff, inet_ntoa(context->start));
|
||||
strcpy(daemon->dhcp_buff2, inet_ntoa(context->end));
|
||||
syslog(LOG_WARNING, "DHCP range %s -- %s is not consistent with netmask %s",
|
||||
syslog(LOG_WARNING, _("DHCP range %s -- %s is not consistent with netmask %s"),
|
||||
daemon->dhcp_buff, daemon->dhcp_buff2, inet_ntoa(netmask));
|
||||
}
|
||||
context->netmask = netmask;
|
||||
@@ -596,12 +601,13 @@ int address_allocate(struct dhcp_context *context, struct daemon *daemon,
|
||||
|
||||
static int is_addr_in_context(struct dhcp_context *context, struct dhcp_config *config)
|
||||
{
|
||||
if (!context)
|
||||
if (!context) /* called via find_config() from lease_update_from_configs() */
|
||||
return 1;
|
||||
if (!(config->flags & CONFIG_ADDR))
|
||||
return 1;
|
||||
if (is_same_net(config->addr, context->start, context->netmask))
|
||||
return 1;
|
||||
for (; context; context = context->current)
|
||||
if (is_same_net(config->addr, context->start, context->netmask))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -675,18 +681,20 @@ void dhcp_read_ethers(struct daemon *daemon)
|
||||
struct in_addr addr;
|
||||
unsigned char hwaddr[ETHER_ADDR_LEN];
|
||||
struct dhcp_config *config, *configs = daemon->dhcp_conf;
|
||||
int count = 0;
|
||||
int count = 0, lineno = 0;
|
||||
|
||||
addr.s_addr = 0; /* eliminate warning */
|
||||
|
||||
if (!f)
|
||||
{
|
||||
syslog(LOG_ERR, "failed to read " ETHERSFILE ":%m");
|
||||
syslog(LOG_ERR, _("failed to read %s:%m"), ETHERSFILE);
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(buff, MAXDNAME, f))
|
||||
{
|
||||
lineno++;
|
||||
|
||||
while (strlen(buff) > 0 && isspace(buff[strlen(buff)-1]))
|
||||
buff[strlen(buff)-1] = 0;
|
||||
|
||||
@@ -696,11 +704,11 @@ void dhcp_read_ethers(struct daemon *daemon)
|
||||
for (ip = buff; *ip && !isspace(*ip); ip++);
|
||||
for(; *ip && isspace(*ip); ip++)
|
||||
*ip = 0;
|
||||
if (!*ip)
|
||||
continue;
|
||||
|
||||
if (parse_hex(buff, hwaddr, 6, NULL) != 6)
|
||||
continue;
|
||||
if (!*ip || parse_hex(buff, hwaddr, 6, NULL) != 6)
|
||||
{
|
||||
syslog(LOG_ERR, _("bad line at %s line %d"), ETHERSFILE, lineno);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check for name or dotted-quad */
|
||||
for (cp = ip; *cp; cp++)
|
||||
@@ -710,7 +718,11 @@ void dhcp_read_ethers(struct daemon *daemon)
|
||||
if (!*cp)
|
||||
{
|
||||
if ((addr.s_addr = inet_addr(ip)) == (in_addr_t)-1)
|
||||
continue;
|
||||
{
|
||||
syslog(LOG_ERR, _("bad address at %s line %d"), ETHERSFILE, lineno);
|
||||
continue;
|
||||
}
|
||||
|
||||
flags = CONFIG_ADDR;
|
||||
|
||||
for (config = configs; config; config = config->next)
|
||||
@@ -720,7 +732,11 @@ void dhcp_read_ethers(struct daemon *daemon)
|
||||
else
|
||||
{
|
||||
if (!canonicalise(ip))
|
||||
continue;
|
||||
{
|
||||
syslog(LOG_ERR, _("bad name at %s line %d"), ETHERSFILE, lineno);
|
||||
continue;
|
||||
}
|
||||
|
||||
flags = CONFIG_NAME;
|
||||
|
||||
for (config = configs; config; config = config->next)
|
||||
@@ -768,7 +784,7 @@ void dhcp_read_ethers(struct daemon *daemon)
|
||||
|
||||
fclose(f);
|
||||
|
||||
syslog(LOG_INFO, "read " ETHERSFILE " - %d addresses", count);
|
||||
syslog(LOG_INFO, _("read %s - %d addresses"), ETHERSFILE, count);
|
||||
|
||||
daemon->dhcp_conf = configs;
|
||||
}
|
||||
@@ -791,7 +807,7 @@ void dhcp_update_configs(struct dhcp_config *configs)
|
||||
(crec->flags & F_HOSTS))
|
||||
{
|
||||
if (config_find_by_address(configs, crec->addr.addr.addr.addr4))
|
||||
syslog(LOG_WARNING, "duplicate IP address %s (%s) in dhcp-config directive",
|
||||
syslog(LOG_WARNING, _("duplicate IP address %s (%s) in dhcp-config directive"),
|
||||
inet_ntoa(crec->addr.addr.addr.addr4), config->hostname);
|
||||
else
|
||||
{
|
||||
@@ -827,7 +843,7 @@ char *strip_hostname(struct daemon *daemon, char *hostname)
|
||||
{
|
||||
if (!daemon->domain_suffix || !hostname_isequal(dot+1, daemon->domain_suffix))
|
||||
{
|
||||
syslog(LOG_WARNING, "Ignoring DHCP host name %s because it has an illegal domain part", hostname);
|
||||
syslog(LOG_WARNING, _("Ignoring DHCP host name %s because it has an illegal domain part"), hostname);
|
||||
hostname = NULL;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -33,7 +33,11 @@ static char *compile_opts =
|
||||
#ifndef HAVE_DBUS
|
||||
"no-"
|
||||
#endif
|
||||
"DBus";
|
||||
"DBus "
|
||||
#ifdef NO_GETTEXT
|
||||
"no-"
|
||||
#endif
|
||||
"i18n";
|
||||
|
||||
static volatile int sigterm, sighup, sigusr1, sigalarm, num_kids, in_child;
|
||||
|
||||
@@ -51,6 +55,12 @@ int main (int argc, char **argv)
|
||||
sigset_t sigmask;
|
||||
struct iname *if_tmp;
|
||||
|
||||
#ifndef NO_GETTEXT
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain("dnsmasq", LOCALEDIR);
|
||||
textdomain("dnsmasq");
|
||||
#endif
|
||||
|
||||
sighup = 1; /* init cache the first time through */
|
||||
sigusr1 = 0; /* but don't dump */
|
||||
sigterm = 0; /* or die */
|
||||
@@ -99,11 +109,11 @@ int main (int argc, char **argv)
|
||||
}
|
||||
#ifndef HAVE_ISC_READER
|
||||
else if (!daemon->dhcp)
|
||||
die("ISC dhcpd integration not available: set HAVE_ISC_READER in src/config.h", NULL);
|
||||
die(_("ISC dhcpd integration not available: set HAVE_ISC_READER in src/config.h"), NULL);
|
||||
#endif
|
||||
|
||||
if (!enumerate_interfaces(daemon, &daemon->interfaces, NULL, NULL))
|
||||
die("failed to find list of interfaces: %s", NULL);
|
||||
die(_("failed to find list of interfaces: %s"), NULL);
|
||||
|
||||
if (!(daemon->options & OPT_NOWILD) &&
|
||||
!(daemon->listeners = create_wildcard_listeners(daemon->port)))
|
||||
@@ -118,13 +128,13 @@ int main (int argc, char **argv)
|
||||
|
||||
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
||||
if (if_tmp->name && !if_tmp->used)
|
||||
die("unknown interface %s", if_tmp->name);
|
||||
die(_("unknown interface %s"), if_tmp->name);
|
||||
|
||||
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
|
||||
if (!if_tmp->used)
|
||||
{
|
||||
prettyprint_addr(&if_tmp->addr, daemon->namebuff);
|
||||
die("no interface with address %s", daemon->namebuff);
|
||||
die(_("no interface with address %s"), daemon->namebuff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +143,7 @@ int main (int argc, char **argv)
|
||||
|
||||
#ifdef HAVE_BROKEN_RTC
|
||||
if ((daemon->uptime_fd = open(UPTIME, O_RDONLY)) == -1)
|
||||
die("cannot open " UPTIME ":%s", NULL);
|
||||
die(_("cannot open %s:%s"), UPTIME);
|
||||
#endif
|
||||
|
||||
now = dnsmasq_time(daemon->uptime_fd);
|
||||
@@ -147,7 +157,7 @@ int main (int argc, char **argv)
|
||||
if (!tmp->isloop)
|
||||
c++;
|
||||
if (c != 1)
|
||||
die("must set exactly one interface on broken systems without IP_RECVIF", NULL);
|
||||
die(_("must set exactly one interface on broken systems without IP_RECVIF"), NULL);
|
||||
#endif
|
||||
dhcp_init(daemon);
|
||||
lease_init(daemon, now);
|
||||
@@ -160,11 +170,11 @@ int main (int argc, char **argv)
|
||||
daemon->dbus = NULL;
|
||||
daemon->watches = NULL;
|
||||
if ((err = dbus_init(daemon)))
|
||||
die("DBus error: %s", err);
|
||||
die(_("DBus error: %s"), err);
|
||||
}
|
||||
#else
|
||||
if (daemon->options & OPT_DBUS)
|
||||
die("DBus not available: set HAVE_DBUS in src/config.h", NULL);
|
||||
die(_("DBus not available: set HAVE_DBUS in src/config.h"), NULL);
|
||||
#endif
|
||||
|
||||
/* If query_port is set then create a socket now, before dumping root
|
||||
@@ -277,29 +287,29 @@ int main (int argc, char **argv)
|
||||
DNSMASQ_LOG_FAC(daemon->options & OPT_DEBUG));
|
||||
|
||||
if (daemon->cachesize != 0)
|
||||
syslog(LOG_INFO, "started, version %s cachesize %d", VERSION, daemon->cachesize);
|
||||
syslog(LOG_INFO, _("started, version %s cachesize %d"), VERSION, daemon->cachesize);
|
||||
else
|
||||
syslog(LOG_INFO, "started, version %s cache disabled", VERSION);
|
||||
syslog(LOG_INFO, _("started, version %s cache disabled"), VERSION);
|
||||
|
||||
syslog(LOG_INFO, "compile time options: %s", compile_opts);
|
||||
syslog(LOG_INFO, _("compile time options: %s"), compile_opts);
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
if (daemon->options & OPT_DBUS)
|
||||
{
|
||||
if (daemon->dbus)
|
||||
syslog(LOG_INFO, "DBus support enabled: connected to system bus");
|
||||
syslog(LOG_INFO, _("DBus support enabled: connected to system bus"));
|
||||
else
|
||||
syslog(LOG_INFO, "DBus support enabled: bus connection pending");
|
||||
syslog(LOG_INFO, _("DBus support enabled: bus connection pending"));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bind_fallback)
|
||||
syslog(LOG_WARNING, "setting --bind-interfaces option because of OS limitations");
|
||||
syslog(LOG_WARNING, _("setting --bind-interfaces option because of OS limitations"));
|
||||
|
||||
if (!(daemon->options & OPT_NOWILD))
|
||||
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
||||
if (if_tmp->name && !if_tmp->used)
|
||||
syslog(LOG_WARNING, "warning: interface %s does not currently exist", if_tmp->name);
|
||||
syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name);
|
||||
|
||||
if (daemon->dhcp)
|
||||
{
|
||||
@@ -316,8 +326,8 @@ int main (int argc, char **argv)
|
||||
strcpy(daemon->dhcp_buff, inet_ntoa(dhcp_tmp->start));
|
||||
syslog(LOG_INFO,
|
||||
(dhcp_tmp->flags & CONTEXT_STATIC) ?
|
||||
"DHCP, static leases only on %.0s%s, lease time %s" :
|
||||
"DHCP, IP range %s -- %s, lease time %s",
|
||||
_("DHCP, static leases only on %.0s%s, lease time %s") :
|
||||
_("DHCP, IP range %s -- %s, lease time %s"),
|
||||
daemon->dhcp_buff, inet_ntoa(dhcp_tmp->end), daemon->dhcp_buff2);
|
||||
}
|
||||
|
||||
@@ -328,12 +338,12 @@ int main (int argc, char **argv)
|
||||
if (daemon->min_leasetime < 60)
|
||||
daemon->min_leasetime = 60;
|
||||
prettyprint_time(daemon->dhcp_buff2, daemon->min_leasetime);
|
||||
syslog(LOG_INFO, "DHCP, %s will be written every %s", daemon->lease_file, daemon->dhcp_buff2);
|
||||
syslog(LOG_INFO, _("DHCP, %s will be written every %s"), daemon->lease_file, daemon->dhcp_buff2);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!(daemon->options & OPT_DEBUG) && (getuid() == 0 || geteuid() == 0))
|
||||
syslog(LOG_WARNING, "running as root");
|
||||
syslog(LOG_WARNING, _("running as root"));
|
||||
|
||||
check_servers(daemon);
|
||||
|
||||
@@ -458,7 +468,7 @@ int main (int argc, char **argv)
|
||||
if (stat(res->name, &statbuf) == -1)
|
||||
{
|
||||
if (!res->logged)
|
||||
syslog(LOG_WARNING, "failed to access %s: %m", res->name);
|
||||
syslog(LOG_WARNING, _("failed to access %s: %m"), res->name);
|
||||
res->logged = 1;
|
||||
}
|
||||
else
|
||||
@@ -491,9 +501,9 @@ int main (int argc, char **argv)
|
||||
{
|
||||
char *err;
|
||||
if ((err = dbus_init(daemon)))
|
||||
syslog(LOG_WARNING, "DBus error: %s", err);
|
||||
syslog(LOG_WARNING, _("DBus error: %s"), err);
|
||||
if (daemon->dbus)
|
||||
syslog(LOG_INFO, "connected to system DBus");
|
||||
syslog(LOG_INFO, _("connected to system DBus"));
|
||||
}
|
||||
check_dbus_listeners(daemon, &rset, &wset, &eset);
|
||||
#endif
|
||||
@@ -504,7 +514,7 @@ int main (int argc, char **argv)
|
||||
dhcp_packet(daemon, now);
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "exiting on receipt of SIGTERM");
|
||||
syslog(LOG_INFO, _("exiting on receipt of SIGTERM"));
|
||||
|
||||
if (daemon->dhcp)
|
||||
{
|
||||
@@ -551,7 +561,7 @@ void clear_cache_and_reload(struct daemon *daemon, time_t now)
|
||||
if (daemon->options & OPT_ETHERS)
|
||||
dhcp_read_ethers(daemon);
|
||||
dhcp_update_configs(daemon->dhcp_conf);
|
||||
lease_update_from_configs(daemon->dhcp_conf, daemon->domain_suffix);
|
||||
lease_update_from_configs(daemon);
|
||||
lease_update_file(0, now);
|
||||
lease_update_dns(daemon);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,16 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#define gettext_noop(S) (S)
|
||||
#ifdef NO_GETTEXT
|
||||
# define _(S) (S)
|
||||
#else
|
||||
# include <libintl.h>
|
||||
# include <locale.h>
|
||||
# define _(S) gettext(S)
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -288,6 +297,7 @@ struct dhcp_lease {
|
||||
int clid_len; /* length of client identifier */
|
||||
unsigned char *clid; /* clientid */
|
||||
char *hostname, *fqdn; /* name from client-hostname option or config */
|
||||
int auth_name; /* hostname came from config, not from client */
|
||||
time_t expires; /* lease expiry */
|
||||
unsigned char hwaddr[ETHER_ADDR_LEN];
|
||||
struct in_addr addr;
|
||||
@@ -558,16 +568,17 @@ struct dhcp_lease *lease_allocate(unsigned char *hwaddr, unsigned char *clid,
|
||||
int clid_len, struct in_addr addr);
|
||||
int lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
||||
unsigned char *clid, int clid_len);
|
||||
void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix);
|
||||
void lease_set_hostname(struct dhcp_lease *lease, char *name,
|
||||
char *suffix, int auth);
|
||||
void lease_set_expires(struct dhcp_lease *lease, time_t exp);
|
||||
struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr,
|
||||
unsigned char *clid, int clid_len);
|
||||
struct dhcp_lease *lease_find_by_addr(struct in_addr addr);
|
||||
void lease_prune(struct dhcp_lease *target, time_t now);
|
||||
void lease_update_from_configs(struct dhcp_config *dhcp_configs, char *domain);
|
||||
void lease_update_from_configs(struct daemon *daemon);
|
||||
|
||||
/* rfc2131.c */
|
||||
int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, unsigned int sz, time_t now);
|
||||
int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, unsigned int sz, time_t now, int unicast_dest);
|
||||
|
||||
/* dnsmasq.c */
|
||||
int icmp_ping(struct daemon *daemon, struct in_addr addr);
|
||||
|
||||
@@ -90,7 +90,7 @@ static void send_from(int fd, int nowild, char *packet, int len,
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#ifdef HAVE_IPV
|
||||
#ifdef HAVE_IPV6
|
||||
{
|
||||
struct in6_pktinfo *pkt = (struct in6_pktinfo *)CMSG_DATA(cmptr);
|
||||
pkt->ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
|
||||
@@ -160,9 +160,11 @@ static unsigned short search_servers(struct daemon *daemon, time_t now, struct a
|
||||
else if (serv->flags & SERV_HAS_DOMAIN)
|
||||
{
|
||||
unsigned int domainlen = strlen(serv->domain);
|
||||
char *matchstart = qdomain + namelen - domainlen;
|
||||
if (namelen >= domainlen &&
|
||||
hostname_isequal(qdomain + namelen - domainlen, serv->domain) &&
|
||||
domainlen >= matchlen)
|
||||
hostname_isequal(matchstart, serv->domain) &&
|
||||
domainlen >= matchlen &&
|
||||
(namelen == domainlen || *(serv->domain) == '.' || *(matchstart-1) == '.' ))
|
||||
{
|
||||
unsigned short sflag = serv->addr.sa.sa_family == AF_INET ? F_IPV4 : F_IPV6;
|
||||
*type = SERV_HAS_DOMAIN;
|
||||
@@ -210,9 +212,8 @@ static unsigned short search_servers(struct daemon *daemon, time_t now, struct a
|
||||
/* returns new last_server */
|
||||
static void forward_query(struct daemon *daemon, int udpfd, union mysockaddr *udpaddr,
|
||||
struct all_addr *dst_addr, unsigned int dst_iface,
|
||||
HEADER *header, int plen, time_t now)
|
||||
HEADER *header, int plen, time_t now, struct frec *forward)
|
||||
{
|
||||
struct frec *forward;
|
||||
char *domain = NULL;
|
||||
int type = 0;
|
||||
struct all_addr *addrp = NULL;
|
||||
@@ -224,7 +225,7 @@ static void forward_query(struct daemon *daemon, int udpfd, union mysockaddr *ud
|
||||
/* may be no servers available. */
|
||||
if (!daemon->servers)
|
||||
forward = NULL;
|
||||
else if ((forward = lookup_frec_by_sender(ntohs(header->id), udpaddr, crc)))
|
||||
else if (forward || (forward = lookup_frec_by_sender(ntohs(header->id), udpaddr, crc)))
|
||||
{
|
||||
/* retry on existing query, send to all available servers */
|
||||
domain = forward->sentto->domain;
|
||||
@@ -337,9 +338,12 @@ static void forward_query(struct daemon *daemon, int udpfd, union mysockaddr *ud
|
||||
}
|
||||
|
||||
/* could not send on, return empty answer or address if known for whole domain */
|
||||
plen = setup_reply(header, (unsigned int)plen, addrp, flags, daemon->local_ttl);
|
||||
send_from(udpfd, daemon->options & OPT_NOWILD, (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
||||
|
||||
if (udpfd != -1)
|
||||
{
|
||||
plen = setup_reply(header, (unsigned int)plen, addrp, flags, daemon->local_ttl);
|
||||
send_from(udpfd, daemon->options & OPT_NOWILD, (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -371,7 +375,7 @@ static int process_reply(struct daemon *daemon, HEADER *header, time_t now,
|
||||
server && !(server->flags & SERV_WARNED_RECURSIVE))
|
||||
{
|
||||
prettyprint_addr(&server->addr, daemon->namebuff);
|
||||
syslog(LOG_WARNING, "nameserver %s refused to do a recursive query", daemon->namebuff);
|
||||
syslog(LOG_WARNING, _("nameserver %s refused to do a recursive query"), daemon->namebuff);
|
||||
if (!(daemon->options & OPT_LOG))
|
||||
server->flags |= SERV_WARNED_RECURSIVE;
|
||||
}
|
||||
@@ -445,40 +449,62 @@ void reply_query(struct serverfd *sfd, struct daemon *daemon, time_t now)
|
||||
{
|
||||
struct server *server = forward->sentto;
|
||||
|
||||
if ((header->rcode == SERVFAIL || header->rcode == REFUSED) && forward->forwardall == 0)
|
||||
/* for broken servers, attempt to send to another one. */
|
||||
{
|
||||
unsigned char *pheader;
|
||||
unsigned int plen;
|
||||
int nn;
|
||||
/* recreate query from reply */
|
||||
pheader = find_pseudoheader(header, n, &plen, NULL);
|
||||
header->ancount = htons(0);
|
||||
header->nscount = htons(0);
|
||||
header->arcount = htons(0);
|
||||
if ((nn = resize_packet(header, n, pheader, plen)))
|
||||
{
|
||||
forward->forwardall = 1;
|
||||
header->qr = 0;
|
||||
header->tc = 0;
|
||||
forward_query(daemon, -1, NULL, NULL, 0, header, nn, now, forward);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((forward->sentto->flags & SERV_TYPE) == 0)
|
||||
{
|
||||
if (header->rcode == SERVFAIL || header->rcode == REFUSED)
|
||||
server = NULL;
|
||||
else
|
||||
{
|
||||
/* find good server by address if possible, otherwise assume the last one we sent to */
|
||||
struct server *last_server;
|
||||
for (last_server = daemon->servers; last_server; last_server = last_server->next)
|
||||
if (!(last_server->flags & (SERV_LITERAL_ADDRESS | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_NO_ADDR)) &&
|
||||
sockaddr_isequal(&last_server->addr, &serveraddr))
|
||||
{
|
||||
server = last_server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
struct server *last_server;
|
||||
/* find good server by address if possible, otherwise assume the last one we sent to */
|
||||
for (last_server = daemon->servers; last_server; last_server = last_server->next)
|
||||
if (!(last_server->flags & (SERV_LITERAL_ADDRESS | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_NO_ADDR)) &&
|
||||
sockaddr_isequal(&last_server->addr, &serveraddr))
|
||||
{
|
||||
server = last_server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
daemon->last_server = server;
|
||||
}
|
||||
|
||||
if ((n = process_reply(daemon, header, now, forward->crc, server, (unsigned int)n)))
|
||||
{
|
||||
header->id = htons(forward->orig_id);
|
||||
header->ra = 1; /* recursion if available */
|
||||
send_from(forward->fd, daemon->options & OPT_NOWILD, daemon->packet, n,
|
||||
&forward->source, &forward->dest, forward->iface);
|
||||
}
|
||||
|
||||
|
||||
/* If the answer is an error, keep the forward record in place in case
|
||||
we get a good reply from another server. Kill it when we've
|
||||
had replies from all to avoid filling the forwarding table when
|
||||
everything is broken */
|
||||
if (forward->forwardall == 0 || --forward->forwardall == 1 ||
|
||||
(header->rcode != REFUSED && header->rcode != SERVFAIL))
|
||||
forward->new_id = 0; /* cancel */
|
||||
{
|
||||
if ((n = process_reply(daemon, header, now, forward->crc, server, (unsigned int)n)))
|
||||
{
|
||||
header->id = htons(forward->orig_id);
|
||||
header->ra = 1; /* recursion if available */
|
||||
send_from(forward->fd, daemon->options & OPT_NOWILD, daemon->packet, n,
|
||||
&forward->source, &forward->dest, forward->iface);
|
||||
}
|
||||
forward->new_id = 0; /* cancel */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +676,7 @@ void receive_query(struct listener *listen, struct daemon *daemon, time_t now)
|
||||
send_from(listen->fd, daemon->options & OPT_NOWILD, (char *)header, m, &source_addr, &dst_addr, if_index);
|
||||
else
|
||||
forward_query(daemon, listen->fd, &source_addr, &dst_addr, if_index,
|
||||
header, n, now);
|
||||
header, n, now, NULL);
|
||||
}
|
||||
|
||||
static int read_write(int fd, unsigned char *packet, int size, int rw)
|
||||
@@ -870,7 +896,7 @@ static struct frec *get_new_frec(time_t now)
|
||||
if (!warntime || difftime(now, warntime) > LOGRATE)
|
||||
{
|
||||
warntime = now;
|
||||
syslog(LOG_WARNING, "forwarding table overflow: check for server loops.");
|
||||
syslog(LOG_WARNING, _("forwarding table overflow: check for server loops."));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
10
src/isc.c
10
src/isc.c
@@ -68,7 +68,7 @@ void load_dhcp(struct daemon *daemon, time_t now)
|
||||
if (stat(daemon->lease_file, &statbuf) == -1)
|
||||
{
|
||||
if (!logged_lease)
|
||||
syslog(LOG_WARNING, "failed to access %s: %m", daemon->lease_file);
|
||||
syslog(LOG_WARNING, _("failed to access %s: %m"), daemon->lease_file);
|
||||
logged_lease = 1;
|
||||
return;
|
||||
}
|
||||
@@ -84,11 +84,11 @@ void load_dhcp(struct daemon *daemon, time_t now)
|
||||
|
||||
if (!(fp = fopen (daemon->lease_file, "r")))
|
||||
{
|
||||
syslog (LOG_ERR, "failed to load %s: %m", daemon->lease_file);
|
||||
syslog (LOG_ERR, _("failed to load %s: %m"), daemon->lease_file);
|
||||
return;
|
||||
}
|
||||
|
||||
syslog (LOG_INFO, "reading %s", daemon->lease_file);
|
||||
syslog (LOG_INFO, _("reading %s"), daemon->lease_file);
|
||||
|
||||
while ((next_token(token, MAXTOK, fp)))
|
||||
{
|
||||
@@ -110,7 +110,7 @@ void load_dhcp(struct daemon *daemon, time_t now)
|
||||
if (!canonicalise(hostname))
|
||||
{
|
||||
*hostname = 0;
|
||||
syslog(LOG_ERR, "bad name in %s", daemon->lease_file);
|
||||
syslog(LOG_ERR, _("bad name in %s"), daemon->lease_file);
|
||||
}
|
||||
}
|
||||
else if ((strcmp(token, "ends") == 0) ||
|
||||
@@ -172,7 +172,7 @@ void load_dhcp(struct daemon *daemon, time_t now)
|
||||
if (!daemon->domain_suffix || hostname_isequal(dot+1, daemon->domain_suffix))
|
||||
{
|
||||
syslog(LOG_WARNING,
|
||||
"Ignoring DHCP lease for %s because it has an illegal domain part",
|
||||
_("Ignoring DHCP lease for %s because it has an illegal domain part"),
|
||||
hostname);
|
||||
continue;
|
||||
}
|
||||
|
||||
34
src/lease.c
34
src/lease.c
@@ -36,7 +36,7 @@ void lease_init(struct daemon *daemon, time_t now)
|
||||
|
||||
/* NOTE: need a+ mode to create file if it doesn't exist */
|
||||
if (!(lease_file = fopen(daemon->lease_file, "a+")))
|
||||
die("cannot open or create leases file: %s", NULL);
|
||||
die(_("cannot open or create leases file: %s"), NULL);
|
||||
|
||||
/* a+ mode lease pointer at end. */
|
||||
rewind(lease_file);
|
||||
@@ -74,12 +74,12 @@ void lease_init(struct daemon *daemon, time_t now)
|
||||
clid_len = parse_hex(daemon->packet, (unsigned char *)daemon->packet, 255, NULL);
|
||||
|
||||
if (!(lease = lease_allocate(hwaddr, (unsigned char *)daemon->packet, clid_len, addr)))
|
||||
die ("too many stored leases", NULL);
|
||||
die (_("too many stored leases"), NULL);
|
||||
|
||||
lease->expires = expires;
|
||||
|
||||
if (strcmp(daemon->dhcp_buff, "*") != 0)
|
||||
lease_set_hostname(lease, daemon->dhcp_buff, daemon->domain_suffix);
|
||||
lease_set_hostname(lease, daemon->dhcp_buff, daemon->domain_suffix, 0);
|
||||
}
|
||||
|
||||
dns_dirty = 1;
|
||||
@@ -88,17 +88,21 @@ void lease_init(struct daemon *daemon, time_t now)
|
||||
daemon->lease_fd = fileno(lease_file);
|
||||
}
|
||||
|
||||
void lease_update_from_configs(struct dhcp_config *dhcp_configs, char *domain)
|
||||
void lease_update_from_configs(struct daemon *daemon)
|
||||
{
|
||||
/* changes to the config may change current leases. */
|
||||
|
||||
struct dhcp_lease *lease;
|
||||
struct dhcp_config *config;
|
||||
|
||||
char *name;
|
||||
|
||||
for (lease = leases; lease; lease = lease->next)
|
||||
if ((config = find_config(dhcp_configs, NULL, lease->clid, lease->clid_len, lease->hwaddr, NULL)) &&
|
||||
(config->flags & CONFIG_NAME))
|
||||
lease_set_hostname(lease, config->hostname, domain);
|
||||
if ((config = find_config(daemon->dhcp_conf, NULL, lease->clid, lease->clid_len, lease->hwaddr, NULL)) &&
|
||||
(config->flags & CONFIG_NAME) &&
|
||||
(!(config->flags & CONFIG_ADDR) || config->addr.s_addr == lease->addr.s_addr))
|
||||
lease_set_hostname(lease, config->hostname, daemon->domain_suffix, 1);
|
||||
else if ((name = host_from_dns(daemon, lease->addr)))
|
||||
lease_set_hostname(lease, name, daemon->domain_suffix, 1); /* updates auth flag only */
|
||||
}
|
||||
|
||||
void lease_update_file(int always, time_t now)
|
||||
@@ -304,26 +308,32 @@ int lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix)
|
||||
void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix, int auth)
|
||||
{
|
||||
struct dhcp_lease *lease_tmp;
|
||||
char *new_name = NULL, *new_fqdn = NULL;
|
||||
|
||||
if (lease->hostname && name && hostname_isequal(lease->hostname, name))
|
||||
return;
|
||||
{
|
||||
lease->auth_name = auth;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!name && !lease->hostname)
|
||||
return;
|
||||
|
||||
/* If a machine turns up on a new net without dropping the old lease,
|
||||
or two machines claim the same name, then we end up with two interfaces with
|
||||
the same name. Check for that here and remove the name from the old lease. */
|
||||
the same name. Check for that here and remove the name from the old lease.
|
||||
Don't allow a name from the client to override a name from dnsmasq config. */
|
||||
|
||||
if (name)
|
||||
{
|
||||
for (lease_tmp = leases; lease_tmp; lease_tmp = lease_tmp->next)
|
||||
if (lease_tmp->hostname && hostname_isequal(lease_tmp->hostname, name))
|
||||
{
|
||||
if (lease_tmp->auth_name && !auth)
|
||||
return;
|
||||
new_name = lease_tmp->hostname;
|
||||
lease_tmp->hostname = NULL;
|
||||
if (lease_tmp->fqdn)
|
||||
@@ -331,6 +341,7 @@ void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix)
|
||||
new_fqdn = lease_tmp->fqdn;
|
||||
lease_tmp->fqdn = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!new_name && (new_name = malloc(strlen(name) + 1)))
|
||||
@@ -351,6 +362,7 @@ void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix)
|
||||
|
||||
lease->hostname = new_name;
|
||||
lease->fqdn = new_fqdn;
|
||||
lease->auth_name = auth;
|
||||
|
||||
file_dirty = force;
|
||||
dns_dirty = 1;
|
||||
|
||||
@@ -34,7 +34,7 @@ int netlink_init(void)
|
||||
addr.nl_groups = 0;
|
||||
|
||||
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
die("cannot bind netlink socket: %s", NULL);
|
||||
die(_("cannot bind netlink socket: %s"), NULL);
|
||||
|
||||
return sock;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ int netlink_process(struct daemon *daemon, int index, struct in_addr relay,
|
||||
rta = RTA_NEXT(rta, len1);
|
||||
}
|
||||
|
||||
if (addr.s_addr && broadcast.s_addr)
|
||||
if (addr.s_addr)
|
||||
{
|
||||
ret = complete_context(daemon, addr, ret, netmask, broadcast, relay, primary);
|
||||
if (addr.s_addr == primary.s_addr)
|
||||
|
||||
@@ -415,14 +415,14 @@ struct listener *create_bound_listeners(struct irec *interfaces, int port)
|
||||
fcntl(new->tcpfd, F_SETFL, flags | O_NONBLOCK) == -1 ||
|
||||
(flags = fcntl(new->fd, F_GETFL, 0)) == -1 ||
|
||||
fcntl(new->fd, F_SETFL, flags | O_NONBLOCK) == -1)
|
||||
die("failed to create listening socket: %s", NULL);
|
||||
die(_("failed to create listening socket: %s"), NULL);
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (iface->addr.sa.sa_family == AF_INET6)
|
||||
{
|
||||
if (setsockopt(new->fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
|
||||
setsockopt(new->tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
|
||||
die("failed to set IPV6 options on listening socket: %s", NULL);
|
||||
die(_("failed to set IPV6 options on listening socket: %s"), NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -441,14 +441,14 @@ struct listener *create_bound_listeners(struct irec *interfaces, int port)
|
||||
{
|
||||
char addrbuff[ADDRSTRLEN];
|
||||
prettyprint_addr(&iface->addr, addrbuff);
|
||||
die("failed to bind listening socket for %s: %s", addrbuff);
|
||||
die(_("failed to bind listening socket for %s: %s"), addrbuff);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listeners = new;
|
||||
if (listen(new->tcpfd, 5) == -1)
|
||||
die("failed to listen on socket: %s", NULL);
|
||||
die(_("failed to listen on socket: %s"), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,7 +518,7 @@ void check_servers(struct daemon *daemon)
|
||||
break;
|
||||
if (iface)
|
||||
{
|
||||
syslog(LOG_WARNING, "ignoring nameserver %s - local interface", daemon->namebuff);
|
||||
syslog(LOG_WARNING, _("ignoring nameserver %s - local interface"), daemon->namebuff);
|
||||
free(new);
|
||||
continue;
|
||||
}
|
||||
@@ -527,7 +527,7 @@ void check_servers(struct daemon *daemon)
|
||||
if (!new->sfd && !(new->sfd = allocate_sfd(&new->source_addr, &daemon->sfds)))
|
||||
{
|
||||
syslog(LOG_WARNING,
|
||||
"ignoring nameserver %s - cannot make/bind socket: %m", daemon->namebuff);
|
||||
_("ignoring nameserver %s - cannot make/bind socket: %m"), daemon->namebuff);
|
||||
free(new);
|
||||
continue;
|
||||
}
|
||||
@@ -541,17 +541,17 @@ void check_servers(struct daemon *daemon)
|
||||
{
|
||||
char *s1, *s2;
|
||||
if (new->flags & SERV_HAS_DOMAIN)
|
||||
s1 = "domain", s2 = new->domain;
|
||||
s1 = _("domain"), s2 = new->domain;
|
||||
else
|
||||
s1 = "unqualified", s2 = "domains";
|
||||
s1 = _("unqualified"), s2 = _("domains");
|
||||
|
||||
if (new->flags & SERV_NO_ADDR)
|
||||
syslog(LOG_INFO, "using local addresses only for %s %s", s1, s2);
|
||||
syslog(LOG_INFO, _("using local addresses only for %s %s"), s1, s2);
|
||||
else if (!(new->flags & SERV_LITERAL_ADDRESS))
|
||||
syslog(LOG_INFO, "using nameserver %s#%d for %s %s", daemon->namebuff, port, s1, s2);
|
||||
syslog(LOG_INFO, _("using nameserver %s#%d for %s %s"), daemon->namebuff, port, s1, s2);
|
||||
}
|
||||
else
|
||||
syslog(LOG_INFO, "using nameserver %s#%d", daemon->namebuff, port);
|
||||
syslog(LOG_INFO, _("using nameserver %s#%d"), daemon->namebuff, port);
|
||||
}
|
||||
|
||||
daemon->servers = ret;
|
||||
@@ -588,11 +588,11 @@ void reload_servers(char *fname, struct daemon *daemon)
|
||||
f = fopen(fname, "r");
|
||||
if (!f)
|
||||
{
|
||||
syslog(LOG_ERR, "failed to read %s: %m", fname);
|
||||
syslog(LOG_ERR, _("failed to read %s: %m"), fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
syslog(LOG_INFO, "reading %s", fname);
|
||||
syslog(LOG_INFO, _("reading %s"), fname);
|
||||
while ((line = fgets(daemon->namebuff, MAXDNAME, f)))
|
||||
{
|
||||
union mysockaddr addr, source_addr;
|
||||
|
||||
232
src/option.c
232
src/option.c
@@ -116,69 +116,69 @@ static const struct optflags optmap[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const char * const usage =
|
||||
"Usage: dnsmasq [options]\n\n"
|
||||
#ifndef HAVE_GETOPT_LONG
|
||||
"Use short options only on the command line.\n"
|
||||
#endif
|
||||
"Valid options are :\n"
|
||||
"-a, --listen-address=ipaddr Specify local address(es) to listen on.\n"
|
||||
"-A, --address=/domain/ipaddr Return ipaddr for all hosts in specified domains.\n"
|
||||
"-b, --bogus-priv Fake reverse lookups for RFC1918 private address ranges.\n"
|
||||
"-B, --bogus-nxdomain=ipaddr Treat ipaddr as NXDOMAIN (defeats Verisign wildcard).\n"
|
||||
"-c, --cache-size=cachesize Specify the size of the cache in entries (defaults to %d).\n"
|
||||
"-C, --conf-file=path Specify configuration file (defaults to " CONFFILE ").\n"
|
||||
"-d, --no-daemon Do NOT fork into the background: run in debug mode.\n"
|
||||
"-D, --domain-needed Do NOT forward queries with no domain part.\n"
|
||||
"-e, --selfmx Return self-pointing MX records for local hosts.\n"
|
||||
"-E, --expand-hosts Expand simple names in /etc/hosts with domain-suffix.\n"
|
||||
"-f, --filterwin2k Don't forward spurious DNS requests from Windows hosts.\n"
|
||||
"-F, --dhcp-range=ipaddr,ipaddr,time Enable DHCP in the range given with lease duration.\n"
|
||||
"-g, --group=groupname Change to this group after startup (defaults to " CHGRP ").\n"
|
||||
"-G, --dhcp-host=<hostspec> Set address or hostname for a specified machine.\n"
|
||||
"-h, --no-hosts Do NOT load " HOSTSFILE " file.\n"
|
||||
"-H, --addn-hosts=path Specify a hosts file to be read in addition to " HOSTSFILE ".\n"
|
||||
"-i, --interface=interface Specify interface(s) to listen on.\n"
|
||||
"-I, --except-interface=int Specify interface(s) NOT to listen on.\n"
|
||||
"-j, --dhcp-userclass=<id>,<class> Map DHCP user class to option set.\n"
|
||||
"-J, --dhcp-ignore=<id> Don't do DHCP for hosts in option set.\n"
|
||||
"-k, --keep-in-foreground Do NOT fork into the background, do NOT run in debug mode.\n"
|
||||
"-K, --dhcp-authoritative Assume we are the only DHCP server on the local network.\n"
|
||||
"-l, --dhcp-leasefile=path Specify where to store DHCP leases (defaults to " LEASEFILE ").\n"
|
||||
"-L, --localmx Return MX records for local hosts.\n"
|
||||
"-m, --mx-host=host_name,target,pref Specify an MX record.\n"
|
||||
"-M, --dhcp-boot=<bootp opts> Specify BOOTP options to DHCP server.\n"
|
||||
"-n, --no-poll Do NOT poll " RESOLVFILE " file, reload only on SIGHUP.\n"
|
||||
"-N, --no-negcache Do NOT cache failed search results.\n"
|
||||
"-o, --strict-order Use nameservers strictly in the order given in " RESOLVFILE ".\n"
|
||||
"-O, --dhcp-option=<optspec> Set extra options to be set to DHCP clients.\n"
|
||||
"-p, --port=number Specify port to listen for DNS requests on (defaults to 53).\n"
|
||||
"-P, --edns-packet-max=<size> Maximum supported UDP packet size for EDNS.0 (defaults to %d).\n"
|
||||
"-q, --log-queries Log queries.\n"
|
||||
"-Q, --query-port=number Force the originating port for upstream queries.\n"
|
||||
"-R, --no-resolv Do NOT read resolv.conf.\n"
|
||||
"-r, --resolv-file=path Specify path to resolv.conf (defaults to " RESOLVFILE ").\n"
|
||||
"-S, --server=/domain/ipaddr Specify address(es) of upstream servers with optional domains.\n"
|
||||
" --local=/domain/ Never forward queries to specified domains.\n"
|
||||
"-s, --domain=domain Specify the domain to be assigned in DHCP leases.\n"
|
||||
"-t, --mx-target=host_name Specify default target in an MX record.\n"
|
||||
"-T, --local-ttl=time Specify time-to-live in seconds for replies from /etc/hosts.\n"
|
||||
"-u, --user=username Change to this user after startup. (defaults to " CHUSER ").\n"
|
||||
"-U, --dhcp-vendorclass=<id>,<class> Map DHCP vendor class to option set.\n"
|
||||
"-v, --version Display dnsmasq version and copyright information.\n"
|
||||
"-V, --alias=addr,addr,mask Translate IPv4 addresses from upstream servers.\n"
|
||||
"-W, --srv-host=name,target,... Specify a SRV record.\n"
|
||||
"-w, --help Display this message.\n"
|
||||
"-x, --pid-file=path Specify path of PID file. (defaults to " RUNFILE ").\n"
|
||||
"-X, --dhcp-lease-max=number Specify maximum number of DHCP leases (defaults to %d).\n"
|
||||
"-y, --localise-queries Answer DNS queries based on the interface a query was sent to.\n"
|
||||
"-Y --txt-record=name,txt.... Specify TXT DNS record.\n"
|
||||
"-z, --bind-interfaces Bind only to interfaces in use.\n"
|
||||
"-Z, --read-ethers Read DHCP static host information from " ETHERSFILE ".\n"
|
||||
"-1, --enable-dbus Enable the DBus interface for setting upstream servers, etc.\n"
|
||||
"-2, --no-dhcp-interface=interface Do not provide DHCP on this interface, only provide DNS.\n"
|
||||
"-3, --bootp-dynamic Enable dynamic address allocation for bootp.\n"
|
||||
"\n";
|
||||
static const struct {
|
||||
char * const flag;
|
||||
char * const desc;
|
||||
char * const arg;
|
||||
} usage[] = {
|
||||
{ "-a, --listen-address=ipaddr", gettext_noop("Specify local address(es) to listen on."), NULL },
|
||||
{ "-A, --address=/domain/ipaddr", gettext_noop("Return ipaddr for all hosts in specified domains."), NULL },
|
||||
{ "-b, --bogus-priv", gettext_noop("Fake reverse lookups for RFC1918 private address ranges."), NULL },
|
||||
{ "-B, --bogus-nxdomain=ipaddr", gettext_noop("Treat ipaddr as NXDOMAIN (defeats Verisign wildcard)."), NULL },
|
||||
{ "-c, --cache-size=cachesize", gettext_noop("Specify the size of the cache in entries (defaults to %s)."), "$" },
|
||||
{ "-C, --conf-file=path", gettext_noop("Specify configuration file (defaults to %s)."), CONFFILE },
|
||||
{ "-d, --no-daemon", gettext_noop("Do NOT fork into the background: run in debug mode."), NULL },
|
||||
{ "-D, --domain-needed", gettext_noop("Do NOT forward queries with no domain part."), NULL },
|
||||
{ "-e, --selfmx", gettext_noop("Return self-pointing MX records for local hosts."), NULL },
|
||||
{ "-E, --expand-hosts", gettext_noop("Expand simple names in /etc/hosts with domain-suffix."), NULL },
|
||||
{ "-f, --filterwin2k", gettext_noop("Don't forward spurious DNS requests from Windows hosts."), NULL },
|
||||
{ "-F, --dhcp-range=ipaddr,ipaddr,time", gettext_noop("Enable DHCP in the range given with lease duration."), NULL },
|
||||
{ "-g, --group=groupname", gettext_noop("Change to this group after startup (defaults to %s)."), CHGRP },
|
||||
{ "-G, --dhcp-host=<hostspec>", gettext_noop("Set address or hostname for a specified machine."), NULL },
|
||||
{ "-h, --no-hosts", gettext_noop("Do NOT load %s file."), HOSTSFILE },
|
||||
{ "-H, --addn-hosts=path", gettext_noop("Specify a hosts file to be read in addition to %s."), HOSTSFILE },
|
||||
{ "-i, --interface=interface", gettext_noop("Specify interface(s) to listen on."), NULL },
|
||||
{ "-I, --except-interface=int", gettext_noop("Specify interface(s) NOT to listen on.") , NULL },
|
||||
{ "-j, --dhcp-userclass=<id>,<class>", gettext_noop("Map DHCP user class to option set."), NULL },
|
||||
{ "-J, --dhcp-ignore=<id>", gettext_noop("Don't do DHCP for hosts in option set."), NULL },
|
||||
{ "-k, --keep-in-foreground", gettext_noop("Do NOT fork into the background, do NOT run in debug mode."), NULL },
|
||||
{ "-K, --dhcp-authoritative", gettext_noop("Assume we are the only DHCP server on the local network."), NULL },
|
||||
{ "-l, --dhcp-leasefile=path", gettext_noop("Specify where to store DHCP leases (defaults to %s)."), LEASEFILE },
|
||||
{ "-L, --localmx", gettext_noop("Return MX records for local hosts."), NULL },
|
||||
{ "-m, --mx-host=host_name,target,pref", gettext_noop("Specify an MX record."), NULL },
|
||||
{ "-M, --dhcp-boot=<bootp opts>", gettext_noop("Specify BOOTP options to DHCP server."), NULL },
|
||||
{ "-n, --no-poll", gettext_noop("Do NOT poll %s file, reload only on SIGHUP."), RESOLVFILE },
|
||||
{ "-N, --no-negcache", gettext_noop("Do NOT cache failed search results."), NULL },
|
||||
{ "-o, --strict-order", gettext_noop("Use nameservers strictly in the order given in %s."), RESOLVFILE },
|
||||
{ "-O, --dhcp-option=<optspec>", gettext_noop("Set extra options to be set to DHCP clients."), NULL },
|
||||
{ "-p, --port=number", gettext_noop("Specify port to listen for DNS requests on (defaults to 53)."), NULL },
|
||||
{ "-P, --edns-packet-max=<size>", gettext_noop("Maximum supported UDP packet size for EDNS.0 (defaults to %s)."), "*" },
|
||||
{ "-q, --log-queries", gettext_noop("Log queries."), NULL },
|
||||
{ "-Q, --query-port=number", gettext_noop("Force the originating port for upstream queries."), NULL },
|
||||
{ "-R, --no-resolv", gettext_noop("Do NOT read resolv.conf."), NULL },
|
||||
{ "-r, --resolv-file=path", gettext_noop("Specify path to resolv.conf (defaults to %s)."), RESOLVFILE },
|
||||
{ "-S, --server=/domain/ipaddr", gettext_noop("Specify address(es) of upstream servers with optional domains."), NULL },
|
||||
{ " --local=/domain/", gettext_noop("Never forward queries to specified domains."), NULL },
|
||||
{ "-s, --domain=domain", gettext_noop("Specify the domain to be assigned in DHCP leases."), NULL },
|
||||
{ "-t, --mx-target=host_name", gettext_noop("Specify default target in an MX record."), NULL },
|
||||
{ "-T, --local-ttl=time", gettext_noop("Specify time-to-live in seconds for replies from /etc/hosts."), NULL },
|
||||
{ "-u, --user=username", gettext_noop("Change to this user after startup. (defaults to %s)."), CHUSER },
|
||||
{ "-U, --dhcp-vendorclass=<id>,<class>", gettext_noop("Map DHCP vendor class to option set."), NULL },
|
||||
{ "-v, --version", gettext_noop("Display dnsmasq version and copyright information."), NULL },
|
||||
{ "-V, --alias=addr,addr,mask", gettext_noop("Translate IPv4 addresses from upstream servers."), NULL },
|
||||
{ "-W, --srv-host=name,target,...", gettext_noop("Specify a SRV record."), NULL },
|
||||
{ "-w, --help", gettext_noop("Display this message."), NULL },
|
||||
{ "-x, --pid-file=path", gettext_noop("Specify path of PID file. (defaults to %s)."), RUNFILE },
|
||||
{ "-X, --dhcp-lease-max=number", gettext_noop("Specify maximum number of DHCP leases (defaults to %s)."), "&" },
|
||||
{ "-y, --localise-queries", gettext_noop("Answer DNS queries based on the interface a query was sent to."), NULL },
|
||||
{ "-Y --txt-record=name,txt....", gettext_noop("Specify TXT DNS record."), NULL },
|
||||
{ "-z, --bind-interfaces", gettext_noop("Bind only to interfaces in use."), NULL },
|
||||
{ "-Z, --read-ethers", gettext_noop("Read DHCP static host information from %s."), ETHERSFILE },
|
||||
{ "-1, --enable-dbus", gettext_noop("Enable the DBus interface for setting upstream servers, etc."), NULL },
|
||||
{ "-2, --no-dhcp-interface=interface", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },
|
||||
{ "-3, --bootp-dynamic", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* We hide metacharaters in quoted strings by mapping them into the ASCII control
|
||||
character space. Note that the \0, \t \a \b \r and \n characters are carefully placed in the
|
||||
@@ -187,7 +187,7 @@ static const char * const usage =
|
||||
The transformation gets undone by opt_canonicalise, atoi_check and safe_string_alloc, and a
|
||||
couple of other places. */
|
||||
|
||||
static char meta[] = "\000123456\a\b\t\n78\r90abcdefABCDEF:,.";
|
||||
static const char meta[] = "\000123456\a\b\t\n78\r90abcdefABCDEF:,.";
|
||||
|
||||
static char hide_meta(char c)
|
||||
{
|
||||
@@ -291,6 +291,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
char *p, *arg, *comma, *file_name_save = NULL, *conffile = CONFFILE;
|
||||
int hosts_index = 1, conffile_set = 0;
|
||||
int line_save = 0, lineno = 0;
|
||||
|
||||
opterr = 0;
|
||||
|
||||
memset(daemon, 0, sizeof(struct daemon));
|
||||
@@ -390,7 +391,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
lastquote = p - buff;
|
||||
}
|
||||
else
|
||||
complain("missing \"", lineno, conffile);
|
||||
complain(_("missing \""), lineno, conffile);
|
||||
}
|
||||
|
||||
if (white && *p == '#')
|
||||
@@ -419,7 +420,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
option = opts[i].val;
|
||||
if (!option)
|
||||
{
|
||||
complain("bad option", lineno, conffile);
|
||||
complain(_("bad option"), lineno, conffile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -436,23 +437,46 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (errno == ENOENT && !conffile_set)
|
||||
break; /* No conffile, all done. */
|
||||
else
|
||||
die("cannot read %s: %s", conffile);
|
||||
die(_("cannot read %s: %s"), conffile);
|
||||
}
|
||||
}
|
||||
|
||||
if (!f && option == 'w')
|
||||
{
|
||||
printf (usage, CACHESIZ, EDNS_PKTSZ, MAXLEASES);
|
||||
printf(_("Usage: dnsmasq [options]\n\n"));
|
||||
#ifndef HAVE_GETOPT_LONG
|
||||
printf(_("Use short options only on the command line.\n"));
|
||||
#endif
|
||||
printf(_("Valid options are :\n"));
|
||||
|
||||
for (i = 0; usage[i].flag; i++)
|
||||
{
|
||||
if (usage[i].arg)
|
||||
{
|
||||
if (strcmp(usage[i].arg, "$") == 0)
|
||||
sprintf(buff, "%d", CACHESIZ);
|
||||
else if (strcmp(usage[i].arg, "*") == 0)
|
||||
sprintf(buff, "%d", EDNS_PKTSZ);
|
||||
else if (strcmp(usage[i].arg, "&") == 0)
|
||||
sprintf(buff, "%d", MAXLEASES);
|
||||
else
|
||||
strcpy(buff, usage[i].arg);
|
||||
}
|
||||
printf("%-36.36s", usage[i].flag);
|
||||
printf(_(usage[i].desc), buff);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!f && option == 'v')
|
||||
{
|
||||
printf("Dnsmasq version %s %s\n", VERSION, COPYRIGHT);
|
||||
printf("Compile time options %s\n\n", compile_opts);
|
||||
printf("This software comes with ABSOLUTELY NO WARRANTY.\n");
|
||||
printf("Dnsmasq is free software, and you are welcome to redistribute it\n");
|
||||
printf("under the terms of the GNU General Public License, version 2.\n");
|
||||
printf(_("Dnsmasq version %s %s\n"), VERSION, COPYRIGHT);
|
||||
printf(_("Compile time options %s\n\n"), compile_opts);
|
||||
printf(_("This software comes with ABSOLUTELY NO WARRANTY.\n"));
|
||||
printf(_("Dnsmasq is free software, and you are welcome to redistribute it\n"));
|
||||
printf(_("under the terms of the GNU General Public License, version 2.\n"));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -462,7 +486,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
daemon->options |= optmap[i].flag;
|
||||
option = 0;
|
||||
if (f && arg)
|
||||
complain("extraneous parameter", lineno, conffile);
|
||||
complain(_("extraneous parameter"), lineno, conffile);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -470,7 +494,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
{
|
||||
if (f && !arg)
|
||||
{
|
||||
complain("missing parameter", lineno, conffile);
|
||||
complain(_("missing parameter"), lineno, conffile);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -487,7 +511,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
/* nest conffiles one deep */
|
||||
if (file_save)
|
||||
{
|
||||
complain("nested includes not allowed", lineno, conffile);
|
||||
complain(_("nested includes not allowed"), lineno, conffile);
|
||||
continue;
|
||||
}
|
||||
file_name_save = conffile;
|
||||
@@ -547,7 +571,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!atoi_check(prefstr, &pref))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad MX preference";
|
||||
problem = _("bad MX preference");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -556,7 +580,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!canonicalise_opt(arg) || (comma && !canonicalise_opt(comma)))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad MX name";
|
||||
problem = _("bad MX name");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -574,7 +598,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!canonicalise_opt(arg))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad MX target";
|
||||
problem = _("bad MX target");
|
||||
}
|
||||
else
|
||||
daemon->mxtarget = safe_string_alloc(arg);
|
||||
@@ -776,7 +800,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!atoi_check(portno+1, &source_port))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad port";
|
||||
problem = _("bad port");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -787,7 +811,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!atoi_check(portno+1, &serv_port))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad port";
|
||||
problem = _("bad port");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,7 +951,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
new->netid.net = NULL;
|
||||
new->flags = 0;
|
||||
|
||||
problem = "bad dhcp-range";
|
||||
problem = _("bad dhcp-range");
|
||||
|
||||
if (!arg)
|
||||
{
|
||||
@@ -987,7 +1011,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
leasepos = 3;
|
||||
if (!is_same_net(new->start, new->end, new->netmask))
|
||||
{
|
||||
problem = "inconsistent DHCP range";
|
||||
problem = _("inconsistent DHCP range");
|
||||
option = '?';
|
||||
}
|
||||
}
|
||||
@@ -1174,7 +1198,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
|
||||
if (option == '?')
|
||||
{
|
||||
problem = "bad dhcp-host";
|
||||
problem = _("bad dhcp-host");
|
||||
if (new->flags & CONFIG_NAME)
|
||||
free(new->hostname);
|
||||
if (new->flags & CONFIG_CLID)
|
||||
@@ -1234,7 +1258,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!arg || (new->opt = atoi(arg)) == 0)
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad dhcp-option";
|
||||
problem = _("bad dhcp-option");
|
||||
}
|
||||
else if (comma && new->opt == 119 && !new->vendor_class)
|
||||
{
|
||||
@@ -1252,12 +1276,12 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!canonicalise_opt(arg))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad domain in dhcp-option";
|
||||
problem = _("bad domain in dhcp-option");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(p = realloc(p, len + strlen(arg) + 2)))
|
||||
die("could not get memory", NULL);
|
||||
die(_("could not get memory"), NULL);
|
||||
q = p + len;
|
||||
|
||||
/* add string on the end in RFC1035 format */
|
||||
@@ -1398,7 +1422,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (new->len > 255)
|
||||
{
|
||||
option = '?';
|
||||
problem = "dhcp-option too long";
|
||||
problem = _("dhcp-option too long");
|
||||
}
|
||||
|
||||
if (option == '?')
|
||||
@@ -1578,7 +1602,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!canonicalise_opt(arg))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad TXT record";
|
||||
problem = _("bad TXT record");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1610,7 +1634,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
|
||||
if (option == '?')
|
||||
{
|
||||
problem = "TXT record string too long";
|
||||
problem = _("TXT record string too long");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1673,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!canonicalise_opt(arg))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad SRV record";
|
||||
problem = _("bad SRV record");
|
||||
break;
|
||||
}
|
||||
name = safe_string_alloc(arg);
|
||||
@@ -1662,7 +1686,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!canonicalise_opt(arg))
|
||||
{
|
||||
option = '?';
|
||||
problem = "bad SRV target";
|
||||
problem = _("bad SRV target");
|
||||
break;
|
||||
}
|
||||
target = safe_string_alloc(arg);
|
||||
@@ -1674,7 +1698,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!atoi_check(arg, &port))
|
||||
{
|
||||
option = '?';
|
||||
problem = "invalid port number";
|
||||
problem = _("invalid port number");
|
||||
break;
|
||||
}
|
||||
if (comma)
|
||||
@@ -1685,7 +1709,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!atoi_check(arg, &priority))
|
||||
{
|
||||
option = '?';
|
||||
problem = "invalid priority";
|
||||
problem = _("invalid priority");
|
||||
break;
|
||||
}
|
||||
if (comma)
|
||||
@@ -1696,7 +1720,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (!atoi_check(arg, &weight))
|
||||
{
|
||||
option = '?';
|
||||
problem = "invalid weight";
|
||||
problem = _("invalid weight");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1721,13 +1745,15 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
if (option == '?')
|
||||
{
|
||||
if (f)
|
||||
complain( problem ? problem : "error", lineno, conffile);
|
||||
complain( problem ? problem : _("error"), lineno, conffile);
|
||||
else
|
||||
die(_("bad command line options: %s."),
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
die("bad command line options: %s.", problem ? problem : "try --help");
|
||||
problem ? problem : "try --help"
|
||||
#else
|
||||
die("bad command line options: %s.", problem ? problem : "try -w");
|
||||
problem ? problem : "try -w"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1765,7 +1791,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
struct mx_srv_record *mx;
|
||||
|
||||
if (gethostname(buff, MAXDNAME) == -1)
|
||||
die("cannot get host-name: %s", NULL);
|
||||
die(_("cannot get host-name: %s"), NULL);
|
||||
|
||||
for (mx = daemon->mxnames; mx; mx = mx->next)
|
||||
if (!mx->issrv && hostname_isequal(mx->name, buff))
|
||||
@@ -1794,17 +1820,17 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
else if (daemon->resolv_files &&
|
||||
(daemon->resolv_files)->next &&
|
||||
(daemon->options & OPT_NO_POLL))
|
||||
die("only one resolv.conf file allowed in no-poll mode.", NULL);
|
||||
die(_("only one resolv.conf file allowed in no-poll mode."), NULL);
|
||||
|
||||
if (daemon->options & OPT_RESOLV_DOMAIN)
|
||||
{
|
||||
char *line;
|
||||
|
||||
if (!daemon->resolv_files || (daemon->resolv_files)->next)
|
||||
die("must have exactly one resolv.conf to read domain from.", NULL);
|
||||
die(_("must have exactly one resolv.conf to read domain from."), NULL);
|
||||
|
||||
if (!(f = fopen((daemon->resolv_files)->name, "r")))
|
||||
die("failed to read %s: %m", (daemon->resolv_files)->name);
|
||||
die(_("failed to read %s: %m"), (daemon->resolv_files)->name);
|
||||
|
||||
while ((line = fgets(buff, MAXDNAME, f)))
|
||||
{
|
||||
@@ -1822,7 +1848,7 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
|
||||
fclose(f);
|
||||
|
||||
if (!daemon->domain_suffix)
|
||||
die("no search directive found in %s", (daemon->resolv_files)->name);
|
||||
die(_("no search directive found in %s"), (daemon->resolv_files)->name);
|
||||
}
|
||||
|
||||
if (daemon->domain_suffix)
|
||||
|
||||
108
src/rfc2131.c
108
src/rfc2131.c
@@ -78,7 +78,8 @@ static unsigned char *do_req_options(struct dhcp_context *context,
|
||||
struct in_addr subnet_addr,
|
||||
unsigned char fqdn_flags);
|
||||
|
||||
int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, unsigned int sz, time_t now)
|
||||
int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name,
|
||||
unsigned int sz, time_t now, int unicast_dest)
|
||||
{
|
||||
unsigned char *opt, *clid = NULL;
|
||||
struct dhcp_lease *ltmp, *lease = NULL;
|
||||
@@ -89,6 +90,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
unsigned char *p = mess->options + sizeof(u32); /* skip cookie */
|
||||
unsigned char *end = (unsigned char *)(daemon->dhcp_packet + 1);
|
||||
char *hostname = NULL, *offer_hostname = NULL, *client_hostname = NULL;
|
||||
int hostname_auth = 0;
|
||||
unsigned char *req_options = NULL;
|
||||
char *message = NULL;
|
||||
unsigned int time;
|
||||
@@ -166,7 +168,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
if (mess->htype != ARPHRD_ETHER && mess->htype != ARPHRD_IEEE802)
|
||||
#endif
|
||||
{
|
||||
syslog(LOG_WARNING, "DHCP request for unsupported hardware type (%d) recieved on %s",
|
||||
syslog(LOG_WARNING, _("DHCP request for unsupported hardware type (%d) recieved on %s"),
|
||||
mess->htype, iface_name);
|
||||
return 0;
|
||||
}
|
||||
@@ -215,8 +217,8 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
|
||||
if (!context)
|
||||
{
|
||||
syslog(LOG_WARNING, "no address range available for DHCP request %s %s",
|
||||
subnet_addr.s_addr ? "with subnet selector" : "via",
|
||||
syslog(LOG_WARNING, _("no address range available for DHCP request %s %s"),
|
||||
subnet_addr.s_addr ? _("with subnet selector") : _("via"),
|
||||
subnet_addr.s_addr ? inet_ntoa(subnet_addr) : (mess->giaddr.s_addr ? inet_ntoa(mess->giaddr) : iface_name));
|
||||
return 0;
|
||||
}
|
||||
@@ -233,7 +235,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
struct in_addr *logaddr = NULL;
|
||||
|
||||
if (have_config(config, CONFIG_DISABLE))
|
||||
message = "disabled";
|
||||
message = _("disabled");
|
||||
|
||||
end = mess->options + 64; /* BOOTP vend area is only 64 bytes */
|
||||
|
||||
@@ -257,7 +259,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
|
||||
for (id_list = daemon->dhcp_ignore; id_list; id_list = id_list->next)
|
||||
if (match_netid(id_list->list, netid))
|
||||
message = "disabled";
|
||||
message = _("disabled");
|
||||
|
||||
if (!message)
|
||||
{
|
||||
@@ -267,20 +269,20 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
mess->yiaddr = config->addr;
|
||||
if ((lease = lease_find_by_addr(config->addr)) &&
|
||||
memcmp(lease->hwaddr, chaddr, ETHER_ADDR_LEN) != 0)
|
||||
message = "address in use";
|
||||
message = _("address in use");
|
||||
}
|
||||
else if (!(daemon->options & OPT_BOOTP_DYNAMIC))
|
||||
message = "no address configured";
|
||||
message = _("no address configured");
|
||||
else
|
||||
{
|
||||
if ((lease = lease_find_by_client(mess->chaddr, NULL, 0)))
|
||||
mess->yiaddr = lease->addr;
|
||||
else if (!address_allocate(context, daemon, &mess->yiaddr, chaddr, netid, now))
|
||||
message = "no address available";
|
||||
message = _("no address available");
|
||||
}
|
||||
|
||||
if (!message && !lease && (!(lease = lease_allocate(chaddr, NULL, 0, mess->yiaddr))))
|
||||
message = "no leases left";
|
||||
message = _("no leases left");
|
||||
|
||||
if (!message)
|
||||
{
|
||||
@@ -295,7 +297,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
|
||||
lease_set_hwaddr(lease, chaddr, NULL, 0);
|
||||
if (hostname)
|
||||
lease_set_hostname(lease, hostname, daemon->domain_suffix);
|
||||
lease_set_hostname(lease, hostname, daemon->domain_suffix, 1);
|
||||
lease_set_expires(lease, 0); /* infinite lease */
|
||||
|
||||
p = do_req_options(context, p, end, NULL, daemon,
|
||||
@@ -370,6 +372,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
if (have_config(config, CONFIG_NAME))
|
||||
{
|
||||
hostname = config->hostname;
|
||||
hostname_auth = 1;
|
||||
/* be careful not to send an OFFER with a hostname not
|
||||
matching the DISCOVER. */
|
||||
if (fqdn_flags != 0 || !client_hostname || hostname_isequal(hostname, client_hostname))
|
||||
@@ -475,7 +478,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
if (have_config(config, CONFIG_ADDR) &&
|
||||
config->addr.s_addr == option_addr(opt).s_addr)
|
||||
{
|
||||
syslog(LOG_WARNING, "disabling DHCP static address %s", inet_ntoa(config->addr));
|
||||
syslog(LOG_WARNING, _("disabling DHCP static address %s"), inet_ntoa(config->addr));
|
||||
config->flags &= ~CONFIG_ADDR ;
|
||||
}
|
||||
else
|
||||
@@ -493,7 +496,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
if (lease && lease->addr.s_addr == mess->ciaddr.s_addr)
|
||||
lease_prune(lease, now);
|
||||
else
|
||||
message = "unknown lease";
|
||||
message = _("unknown lease");
|
||||
|
||||
log_packet("RELEASE", &mess->ciaddr, chaddr, iface_name, message);
|
||||
|
||||
@@ -506,7 +509,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
if ((opt = option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ)))
|
||||
addr = option_addr(opt);
|
||||
if (ignore || have_config(config, CONFIG_DISABLE))
|
||||
message = "ignored";
|
||||
message = _("ignored");
|
||||
else if (have_config(config, CONFIG_ADDR) &&
|
||||
(!(ltmp = lease_find_by_addr(config->addr)) || ltmp == lease))
|
||||
mess->yiaddr = config->addr;
|
||||
@@ -516,7 +519,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
!config_find_by_address(daemon->dhcp_conf, addr))
|
||||
mess->yiaddr = addr;
|
||||
else if (!address_allocate(context, daemon, &mess->yiaddr, chaddr, netid, now))
|
||||
message = "no address available";
|
||||
message = _("no address available");
|
||||
log_packet("DISCOVER", opt ? &addr : NULL, chaddr, iface_name, message);
|
||||
}
|
||||
|
||||
@@ -586,7 +589,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
return 0;
|
||||
|
||||
if (lease && lease->addr.s_addr != mess->yiaddr.s_addr)
|
||||
message = "wrong address";
|
||||
message = _("wrong address");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -594,8 +597,11 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
/* RENEWING or REBINDING */
|
||||
/* Must exist a lease for this address */
|
||||
if (!lease || mess->ciaddr.s_addr != lease->addr.s_addr)
|
||||
message = "lease not found";
|
||||
|
||||
{
|
||||
message = _("lease not found");
|
||||
/* ensure we broadcast NAK */
|
||||
unicast_dest = 0;
|
||||
}
|
||||
/* desynchronise renewals */
|
||||
fuzz = rand16();
|
||||
mess->yiaddr = mess->ciaddr;
|
||||
@@ -609,12 +615,16 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
|
||||
/* If a machine moves networks whilst it has a lease, we catch that here. */
|
||||
if (!is_same_net(mess->yiaddr, context->start, context->netmask))
|
||||
message = "wrong network";
|
||||
|
||||
{
|
||||
message = _("wrong network");
|
||||
/* ensure we broadcast NAK */
|
||||
unicast_dest = 0;
|
||||
}
|
||||
|
||||
/* Check for renewal of a lease which is outside the allowed range. */
|
||||
else if (!address_available(context, mess->yiaddr) &&
|
||||
(!have_config(config, CONFIG_ADDR) || config->addr.s_addr != mess->yiaddr.s_addr))
|
||||
message = "address not available";
|
||||
message = _("address not available");
|
||||
|
||||
/* Check if a new static address has been configured. Be very sure that
|
||||
when the client does DISCOVER, it will get the static address, otherwise
|
||||
@@ -623,35 +633,45 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
else if (have_config(config, CONFIG_ADDR) &&
|
||||
config->addr.s_addr != mess->yiaddr.s_addr &&
|
||||
(!(ltmp = lease_find_by_addr(config->addr)) || ltmp == lease))
|
||||
message = "static lease available";
|
||||
message = _("static lease available");
|
||||
|
||||
/* Check to see if the address is reserved as a static address for another host */
|
||||
else if ((addr_config = config_find_by_address(daemon->dhcp_conf, mess->yiaddr)) && addr_config != config)
|
||||
message = "address reserved";
|
||||
message = _("address reserved");
|
||||
|
||||
else if ((ltmp = lease_find_by_addr(mess->yiaddr)) && ltmp != lease)
|
||||
message = "address in use";
|
||||
message = _("address in use");
|
||||
|
||||
else if (!lease && !(lease = lease_allocate(chaddr, clid, clid_len, mess->yiaddr)))
|
||||
message = "no leases left";
|
||||
message = _("no leases left");
|
||||
}
|
||||
|
||||
if (message)
|
||||
{
|
||||
log_packet("NAK", &mess->yiaddr, chaddr, iface_name, message);
|
||||
|
||||
mess->siaddr.s_addr = mess->yiaddr.s_addr = mess->ciaddr.s_addr = 0;
|
||||
mess->siaddr.s_addr = mess->yiaddr.s_addr = 0;
|
||||
bootp_option_put(mess, NULL, NULL);
|
||||
p = option_put(p, end, OPTION_MESSAGE_TYPE, 1, DHCPNAK);
|
||||
p = option_put(p, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(context->local.s_addr));
|
||||
p = option_put_string(p, end, OPTION_MESSAGE, message);
|
||||
mess->flags |= htons(0x8000); /* broadcast */
|
||||
/* This fixes a problem with the DHCP spec, broadcasting a NAK to a host on
|
||||
a distant subnet which unicast a REQ to us won't work. */
|
||||
if (!unicast_dest || mess->giaddr.s_addr != 0 ||
|
||||
mess->ciaddr.s_addr == 0 || is_same_net(context->local, mess->ciaddr, context->netmask))
|
||||
{
|
||||
mess->flags |= htons(0x8000); /* broadcast */
|
||||
mess->ciaddr.s_addr = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!hostname)
|
||||
hostname = host_from_dns(daemon, mess->yiaddr);
|
||||
|
||||
if (!hostname_auth && (client_hostname = host_from_dns(daemon, mess->yiaddr)))
|
||||
{
|
||||
hostname = client_hostname;
|
||||
hostname_auth = 1;
|
||||
}
|
||||
|
||||
log_packet("ACK", &mess->yiaddr, chaddr, iface_name, hostname);
|
||||
|
||||
context = narrow_context(context, mess->yiaddr);
|
||||
@@ -671,7 +691,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
|
||||
lease_set_hwaddr(lease, chaddr, clid, clid_len);
|
||||
if (hostname)
|
||||
lease_set_hostname(lease, hostname, daemon->domain_suffix);
|
||||
lease_set_hostname(lease, hostname, daemon->domain_suffix, hostname_auth);
|
||||
lease_set_expires(lease, time == 0xffffffff ? 0 : now + (time_t)time);
|
||||
|
||||
mess->siaddr = context->local;
|
||||
@@ -695,7 +715,7 @@ int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_
|
||||
|
||||
case DHCPINFORM:
|
||||
if (ignore || have_config(config, CONFIG_DISABLE))
|
||||
message = "ignored";
|
||||
message = _("ignored");
|
||||
|
||||
log_packet("INFORM", &mess->ciaddr, chaddr, iface_name, message);
|
||||
|
||||
@@ -809,12 +829,24 @@ static void bootp_option_put(struct dhcp_packet *mess,
|
||||
}
|
||||
}
|
||||
|
||||
static int check_space(unsigned char *p, unsigned char *end, int len, int opt)
|
||||
{
|
||||
/* always keep one octet space for the END option. */
|
||||
if (p + len + 3 >= end)
|
||||
{
|
||||
syslog(LOG_WARNING, _("cannot send DHCP option %d: no space left in packet"), opt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static unsigned char *option_put(unsigned char *p, unsigned char *end, int opt, int len, unsigned int val)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* always keep one octet space for the END option. */
|
||||
if (p + len + 3 < end)
|
||||
if (check_space(p, end, len, opt))
|
||||
{
|
||||
*(p++) = opt;
|
||||
*(p++) = len;
|
||||
@@ -838,7 +870,7 @@ static unsigned char *option_put_string(unsigned char *p, unsigned char *end, in
|
||||
{
|
||||
size_t len = strlen(string);
|
||||
|
||||
if (p + len + 3 < end)
|
||||
if (check_space(p, end, len, opt))
|
||||
{
|
||||
*(p++) = opt;
|
||||
*(p++) = len;
|
||||
@@ -941,9 +973,9 @@ static struct dhcp_opt *option_find2(struct dhcp_netid *netid, struct dhcp_opt *
|
||||
|
||||
static unsigned char *do_opt(struct dhcp_opt *opt, unsigned char *p, unsigned char *end, struct in_addr local)
|
||||
{
|
||||
if (p + opt->len + 3 >= end)
|
||||
if (!check_space(p, end, opt->len, opt->opt))
|
||||
return p;
|
||||
|
||||
|
||||
*(p++) = opt->opt;
|
||||
*(p++) = opt->len;
|
||||
|
||||
@@ -1097,7 +1129,7 @@ static unsigned char *do_req_options(struct dhcp_context *context,
|
||||
if (!opt->netid || match_netid(opt->netid, netid))
|
||||
{
|
||||
if (vendor_class && strcmp(vendor_class, (char *)opt->vendor_class) != 0)
|
||||
syslog(LOG_WARNING, "More than one vendor class matches, using %s", vendor_class);
|
||||
syslog(LOG_WARNING, _("More than one vendor class matches, using %s"), vendor_class);
|
||||
else
|
||||
vendor_class = (char *)opt->vendor_class;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ void *safe_malloc(size_t size)
|
||||
void *ret = malloc(size);
|
||||
|
||||
if (!ret)
|
||||
die("could not get memory", NULL);
|
||||
die(_("could not get memory"), NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -169,14 +169,14 @@ void complain(char *message, int lineno, char *file)
|
||||
{
|
||||
char buff[256];
|
||||
|
||||
sprintf(buff, "%s at line %d of %%s", message, lineno);
|
||||
sprintf(buff, _("%s at line %d of %%s"), message, lineno);
|
||||
log_err(buff, file);
|
||||
}
|
||||
|
||||
void die(char *message, char *arg1)
|
||||
{
|
||||
log_err(message, arg1);
|
||||
syslog(LOG_CRIT, "FAILED to start up");
|
||||
syslog(LOG_CRIT, _("FAILED to start up"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ int prettyprint_addr(union mysockaddr *addr, char *buf)
|
||||
void prettyprint_time(char *buf, unsigned int t)
|
||||
{
|
||||
if (t == 0xffffffff)
|
||||
sprintf(buf, "infinite");
|
||||
sprintf(buf, _("infinite"));
|
||||
else
|
||||
{
|
||||
unsigned int x, p = 0;
|
||||
|
||||
Reference in New Issue
Block a user