aboutsummaryrefslogtreecommitdiff
path: root/src/dns
diff options
context:
space:
mode:
authorBertrand Marc <beberking@gmail.com>2012-06-06 20:47:48 +0200
committerBertrand Marc <beberking@gmail.com>2012-06-06 20:47:48 +0200
commit740b30688bd745a527f96f9116c19acb3480971a (patch)
tree2709a3f4dba11c174aa9e1ba3612e30c578e76a9 /src/dns
parent2b81464a43485fcc8ce079fafdee7b7a171835f4 (diff)
Imported Upstream version 0.9.3upstream/0.9.3
Diffstat (limited to 'src/dns')
-rw-r--r--src/dns/Makefile.am5
-rw-r--r--src/dns/Makefile.in8
-rw-r--r--src/dns/dns.h4
-rw-r--r--src/dns/dns_api.c2
-rw-r--r--src/dns/gnunet-service-dns.c54
-rw-r--r--src/dns/plugin_block_dns.c2
6 files changed, 46 insertions, 29 deletions
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am
index 5bc8709..ed000aa 100644
--- a/src/dns/Makefile.am
+++ b/src/dns/Makefile.am
@@ -21,7 +21,7 @@ install-exec-hook:
$(SUDO_BINARY) chown root $(bindir)/gnunet-helper-dns || true
$(SUDO_BINARY) chgrp $(GNUNETDNS_GROUP) $(bindir)/gnunet-helper-dns || true
$(SUDO_BINARY) chmod 4750 $(bindir)/gnunet-helper-dns || true
- $(SUDO_BINARY) chgrp $(GNUNETDNS_GROUP) $(bindir)/gnunet-service-dns || true
+ $(SUDO_BINARY) chown gnunet:$(GNUNETDNS_GROUP) $(bindir)/gnunet-service-dns || true
$(SUDO_BINARY) chmod 2750 $(bindir)/gnunet-service-dns || true
else
install-exec-hook:
@@ -40,9 +40,10 @@ noinst_PROGRAMS = \
plugin_LTLIBRARIES = \
libgnunet_plugin_block_dns.la
+if LINUX
check_SCRIPTS = \
test_gnunet_dns.sh
-
+endif
gnunet_helper_dns_SOURCES = \
gnunet-helper-dns.c
diff --git a/src/dns/Makefile.in b/src/dns/Makefile.in
index ee45c56..3a717ab 100644
--- a/src/dns/Makefile.in
+++ b/src/dns/Makefile.in
@@ -228,6 +228,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+JAVAPORT = @JAVAPORT@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
@@ -261,6 +262,7 @@ LT_DLLOADERS = @LT_DLLOADERS@
LT_DLPREOPEN = @LT_DLPREOPEN@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
+MONKEYPREFIX = @MONKEYPREFIX@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
@@ -393,8 +395,8 @@ lib_LTLIBRARIES = \
plugin_LTLIBRARIES = \
libgnunet_plugin_block_dns.la
-check_SCRIPTS = \
- test_gnunet_dns.sh
+@LINUX_TRUE@check_SCRIPTS = \
+@LINUX_TRUE@ test_gnunet_dns.sh
gnunet_helper_dns_SOURCES = \
gnunet-helper-dns.c
@@ -1008,7 +1010,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \
@LINUX_TRUE@ $(SUDO_BINARY) chown root $(bindir)/gnunet-helper-dns || true
@LINUX_TRUE@ $(SUDO_BINARY) chgrp $(GNUNETDNS_GROUP) $(bindir)/gnunet-helper-dns || true
@LINUX_TRUE@ $(SUDO_BINARY) chmod 4750 $(bindir)/gnunet-helper-dns || true
-@LINUX_TRUE@ $(SUDO_BINARY) chgrp $(GNUNETDNS_GROUP) $(bindir)/gnunet-service-dns || true
+@LINUX_TRUE@ $(SUDO_BINARY) chown gnunet:$(GNUNETDNS_GROUP) $(bindir)/gnunet-service-dns || true
@LINUX_TRUE@ $(SUDO_BINARY) chmod 2750 $(bindir)/gnunet-service-dns || true
@LINUX_FALSE@install-exec-hook:
diff --git a/src/dns/dns.h b/src/dns/dns.h
index 2b0ad03..ee95d9c 100644
--- a/src/dns/dns.h
+++ b/src/dns/dns.h
@@ -23,8 +23,8 @@
* @brief IPC messages between DNS API and DNS service
* @author Christian Grothoff
*/
-#ifndef DNS_NEW_H
-#define DNS_NEW_H
+#ifndef DNS_H
+#define DNS_H
GNUNET_NETWORK_STRUCT_BEGIN
diff --git a/src/dns/dns_api.c b/src/dns/dns_api.c
index a280265..e006993 100644
--- a/src/dns/dns_api.c
+++ b/src/dns/dns_api.c
@@ -202,7 +202,7 @@ disconnect (struct GNUNET_DNS_Handle *dh)
}
if (NULL != dh->dns_connection)
{
- GNUNET_CLIENT_disconnect (dh->dns_connection, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (dh->dns_connection);
dh->dns_connection = NULL;
}
while (NULL != (qe = dh->rq_head))
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index 1f48b10..6337538 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -290,6 +290,11 @@ struct TunnelState
/**
+ * Global return value from 'main'.
+ */
+static int global_ret;
+
+/**
* The configuration to use
*/
static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -535,7 +540,7 @@ request_done (struct RequestRecord *rr)
return;
}
{
- char buf[reply_len];
+ char buf[reply_len] GNUNET_ALIGN;
size_t off;
struct GNUNET_TUN_IPv4Header ip4;
struct GNUNET_TUN_IPv6Header ip6;
@@ -626,10 +631,10 @@ request_done (struct RequestRecord *rr)
}
/* final checks & sending */
GNUNET_assert (off == reply_len);
- GNUNET_HELPER_send (hijacker,
- hdr,
- GNUNET_YES,
- NULL, NULL);
+ (void) GNUNET_HELPER_send (hijacker,
+ hdr,
+ GNUNET_YES,
+ NULL, NULL);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# DNS requests answered via TUN interface"),
1, GNUNET_NO);
@@ -650,7 +655,7 @@ static void
send_request_to_client (struct RequestRecord *rr,
struct GNUNET_SERVER_Client *client)
{
- char buf[sizeof (struct GNUNET_DNS_Request) + rr->payload_length];
+ char buf[sizeof (struct GNUNET_DNS_Request) + rr->payload_length] GNUNET_ALIGN;
struct GNUNET_DNS_Request *req;
if (sizeof (buf) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -729,7 +734,6 @@ get_request_socket (int af)
if (NULL != rs->dnsout6)
GNUNET_NETWORK_fdset_set (rset, rs->dnsout6);
rs->read_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
REQUEST_TIMEOUT,
rset,
NULL,
@@ -982,7 +986,7 @@ do_dns_read (struct GNUNET_NETWORK_Handle *dnsout)
#endif
{
- unsigned char buf[len];
+ unsigned char buf[len] GNUNET_ALIGN;
addrlen = sizeof (addr);
memset (&addr, 0, sizeof (addr));
@@ -1095,7 +1099,6 @@ read_response (void *cls,
if (NULL != rs->dnsout6)
GNUNET_NETWORK_fdset_set (rset, rs->dnsout6);
rs->read_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
GNUNET_TIME_absolute_get_remaining (rs->timeout),
rset,
NULL,
@@ -1193,10 +1196,8 @@ handle_client_response (void *cls GNUNET_UNUSED,
return;
}
GNUNET_free_non_null (rr->payload);
-#if DEBUG_DNS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Changing DNS reply according to client specifications\n"));
-#endif
+ "Changing DNS reply according to client specifications\n");
rr->payload = GNUNET_malloc (msize);
rr->payload_length = msize;
memcpy (rr->payload, &resp[1], msize);
@@ -1238,7 +1239,7 @@ handle_client_response (void *cls GNUNET_UNUSED,
* @param client identification of the client
* @param message the actual message, a DNS request we should handle
*/
-static void
+static int
process_helper_messages (void *cls GNUNET_UNUSED, void *client,
const struct GNUNET_MessageHeader *message)
{
@@ -1259,7 +1260,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
{
/* non-IP packet received on TUN!? */
GNUNET_break (0);
- return;
+ return GNUNET_OK;
}
msize -= sizeof (struct GNUNET_MessageHeader);
tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1];
@@ -1268,6 +1269,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
{
case ETH_P_IPV4:
ip4 = (const struct GNUNET_TUN_IPv4Header *) &tun[1];
+ ip6 = NULL; /* make compiler happy */
if ( (msize < sizeof (struct GNUNET_TUN_IPv4Header)) ||
(ip4->version != 4) ||
(ip4->header_length != sizeof (struct GNUNET_TUN_IPv4Header) / 4) ||
@@ -1277,12 +1279,13 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
/* non-IP/UDP packet received on TUN (or with options) */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Received malformed IPv4-UDP packet on TUN interface.\n"));
- return;
+ return GNUNET_OK;
}
udp = (const struct GNUNET_TUN_UdpHeader*) &ip4[1];
msize -= sizeof (struct GNUNET_TUN_IPv4Header);
break;
case ETH_P_IPV6:
+ ip4 = NULL; /* make compiler happy */
ip6 = (const struct GNUNET_TUN_IPv6Header *) &tun[1];
if ( (msize < sizeof (struct GNUNET_TUN_IPv6Header)) ||
(ip6->version != 6) ||
@@ -1292,7 +1295,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
/* non-IP/UDP packet received on TUN (or with extensions) */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Received malformed IPv6-UDP packet on TUN interface.\n"));
- return;
+ return GNUNET_OK;
}
udp = (const struct GNUNET_TUN_UdpHeader*) &ip6[1];
msize -= sizeof (struct GNUNET_TUN_IPv6Header);
@@ -1303,7 +1306,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
_("Got non-IP packet with %u bytes and protocol %u from TUN\n"),
(unsigned int) msize,
ntohs (tun->proto));
- return;
+ return GNUNET_OK;
}
if (msize <= sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_TUN_DnsHeader))
{
@@ -1311,7 +1314,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Non-DNS UDP packet received via TUN interface"),
1, GNUNET_NO);
- return;
+ return GNUNET_OK;
}
msize -= sizeof (struct GNUNET_TUN_UdpHeader);
dns = (const struct GNUNET_TUN_DnsHeader*) &udp[1];
@@ -1378,6 +1381,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
1, GNUNET_NO);
/* start request processing state machine */
next_phase (rr);
+ return GNUNET_OK;
}
@@ -1404,7 +1408,7 @@ receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_TUN_DnsHeader *dns;
size_t mlen = ntohs (message->size);
size_t dlen = mlen - sizeof (struct GNUNET_MessageHeader);
- char buf[dlen];
+ char buf[dlen] GNUNET_ALIGN;
struct GNUNET_TUN_DnsHeader *dout;
struct sockaddr_in v4;
struct sockaddr_in6 v6;
@@ -1550,6 +1554,16 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
struct in6_addr dns_exit6;
cfg = cfg_;
+ if (GNUNET_YES !=
+ GNUNET_OS_check_helper_binary ("gnunet-helper-dns"))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("`%s' must be installed SUID, refusing to run\n"),
+ "gnunet-helper-dns");
+ global_ret = 1;
+ return;
+ }
+
stats = GNUNET_STATISTICS_create ("dns", cfg);
nc = GNUNET_SERVER_notification_context_create (server, 1);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
@@ -1660,7 +1674,7 @@ main (int argc, char *const *argv)
{
return (GNUNET_OK ==
GNUNET_SERVICE_run (argc, argv, "dns", GNUNET_SERVICE_OPTION_NONE,
- &run, NULL)) ? 0 : 1;
+ &run, NULL)) ? global_ret : 1;
}
diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c
index 96a4dc0..da8add5 100644
--- a/src/dns/plugin_block_dns.c
+++ b/src/dns/plugin_block_dns.c
@@ -85,7 +85,7 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
- if (GNUNET_TIME_relative_get_zero ().rel_value ==
+ if (0 ==
GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
(rec->expiration_time)).rel_value)
{