From 29f76b6fe373cd5ca7504be2ffdaad5500406b8b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 18 Jul 2017 22:55:09 +0200 Subject: [PATCH] simplify installation of nss plugins in build system, require user(s) to move plugins into place manually (#5078) --- configure.ac | 47 ---------------- src/gns/Makefile.am | 2 - src/gns/nss/Makefile.am | 26 +-------- src/gns/nss/install-nss-plugin.sh | 8 --- src/gns/nss/uninstall-nss-plugin.sh | 8 --- src/util/Makefile.am | 8 +-- src/util/resolver_api.c | 85 ++++++++++++++++++----------- 7 files changed, 60 insertions(+), 124 deletions(-) delete mode 100755 src/gns/nss/install-nss-plugin.sh delete mode 100755 src/gns/nss/uninstall-nss-plugin.sh diff --git a/configure.ac b/configure.ac index c16fbdcba..101fc77cb 100644 --- a/configure.ac +++ b/configure.ac @@ -1116,45 +1116,6 @@ AC_SUBST(SUDO_BINARY) AM_CONDITIONAL([HAVE_SUDO], [test "x$SUDO_BINARY" != "x" -o -w /]) -# test for nssdir -AC_MSG_CHECKING(with nssdir) -AC_ARG_WITH(nssdir, - [ --with-nssdir=PATH where to install NSS plugins], - [AC_MSG_RESULT("$with_nssdir") - case $with_nssdir in - no) - NSS_DIR= - install_nss=0 - ;; - yes) - NSS_DIR="/lib" - install_nss=1 - ;; - *) - NSS_DIR=$with_nssdir - install_nss=1 - ;; - esac - ], - [ -# This test is inappropriate when installation with DESTDIR is -# run much later and uid will be root when needed. Enabling this -# code breaks the gnunet.ebuild for gentoo. -# -# if test "x$SUDO_BINARY" != "x" -o -w / -# then - NSS_DIR="/lib" - install_nss=1 - AC_MSG_RESULT([yes, to /lib]) -# else -# NSS_DIR= -# install_nss=0 -# AC_MSG_RESULT([no]) -# fi - ]) -AC_SUBST(NSS_DIR) -AM_CONDITIONAL([INSTALL_NSS], [test "x$install_nss" != "x0"]) - # test for gnunetdns group name GNUNETDNS_GROUP=gnunetdns AC_MSG_CHECKING(for gnunetdns group name) @@ -1793,14 +1754,6 @@ then AC_MSG_NOTICE([Mac OS X framework build enabled.]) fi -if test "x$install_nss" = "x0" -then - AC_MSG_NOTICE([WARNING: Will not install GNS NSS library]) -else - AC_MSG_NOTICE([NOTICE: Will install GNS NSS library to $NSS_DIR]) -fi - - AC_MSG_NOTICE([******************************************** Please make sure NOW that you have created a user and group 'gnunet' and additionally a group 'gnunetdns'. On Debian and Ubuntu GNU/Linux, type: diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 464bbbca1..977eb87e3 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -2,10 +2,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include if HAVE_GLIBCNSS -if INSTALL_NSS NSS_SUBDIR = nss endif -endif SUBDIRS = . $(NSS_SUBDIR) diff --git a/src/gns/nss/Makefile.am b/src/gns/nss/Makefile.am index 2551b9562..5d42f777f 100644 --- a/src/gns/nss/Makefile.am +++ b/src/gns/nss/Makefile.am @@ -18,28 +18,17 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 # USA. -EXTRA_DIST = map-file \ - install-nss-plugin.sh \ - uninstall-nss-plugin.sh +EXTRA_DIST = map-file AM_LDFLAGS=-avoid-version -module -export-dynamic -nssdir = $(NSS_DIR) - -LIBTOOL = $(LIBTOOL_SUDO_BINARY) $(SHELL) $(top_builddir)/libtool +nssdir = $(libdir)/gnunet/nss if !MINGW -if INSTALL_NSS nss_LTLIBRARIES = \ libnss_gns.la \ libnss_gns4.la \ libnss_gns6.la - -install-nssLTLIBRARIES: - LIBTOOL_SUDO_BINARY=$(SUDO_BINARY) -uninstall-nssLTLIBRARIES: - LIBTOOL_SUDO_BINARY=$(SUDO_BINARY) -endif endif sources = nss_gns_query.h nss_gns_query.c @@ -57,14 +46,3 @@ libnss_gns6_la_SOURCES=$(libnss_gns_la_SOURCES) libnss_gns6_la_CFLAGS=$(libnss_gns_la_CFLAGS) -DNSS_IPV6_ONLY=1 libnss_gns6_la_LDFLAGS=$(libnss_gns_la_LDFLAGS) -if INSTALL_NSS -if !MINGW -install-data-hook: - $(top_srcdir)/src/gns/nss/install-nss-plugin.sh $(SHELL) $(top_builddir) $(DESTDIR)$(nssdir) $(SUDO_BINARY) - -uninstall-hook: - $(top_srcdir)/src/gns/nss/uninstall-nss-plugin.sh $(SHELL) $(top_builddir) "rm -f $(nssdir)/libnss_gns.so.2" $(SUDO_BINARY) - $(top_srcdir)/src/gns/nss/uninstall-nss-plugin.sh $(SHELL) $(top_builddir) "rm -f $(nssdir)/libnss_gns4.so.2" $(SUDO_BINARY) - $(top_srcdir)/src/gns/nss/uninstall-nss-plugin.sh $(SHELL) $(top_builddir) "rm -f $(nssdir)/libnss_gns6.so.2" $(SUDO_BINARY) -endif -endif diff --git a/src/gns/nss/install-nss-plugin.sh b/src/gns/nss/install-nss-plugin.sh deleted file mode 100755 index 1aab8ca69..000000000 --- a/src/gns/nss/install-nss-plugin.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# $1 - shell -# $2 - top_builddir -# $3 - nssdir -# $4 - sudo binary (empty if root) -$4 $1 $2/libtool --mode=finish $3 -echo LTINST: $4 $1 $2/libtool --mode=finish $3 -$4 rm -f $3/libnss_gns.la $3/libnss_gns4.la $3/libnss_gns6.la diff --git a/src/gns/nss/uninstall-nss-plugin.sh b/src/gns/nss/uninstall-nss-plugin.sh deleted file mode 100755 index 3d8cec110..000000000 --- a/src/gns/nss/uninstall-nss-plugin.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# $1 - shell -# $2 - top_builddir -# $3 - nssdir+path of library to remove -# $4 - sudo binary (empty if root) -$4 $1 $2/libtool --mode=uninstall $3 - - diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 9be572bb6..c26e3e84b 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -336,10 +336,10 @@ test_client_unix_nc_SOURCES = \ test_client_unix_nc_LDADD = \ libgnunetutil.la -test_socks_nc_SOURCES = \ - test_socks.c -test_socks_nc_LDADD = \ - libgnunetutil.la +#test_socks_nc_SOURCES = \ +# test_socks.c +#test_socks_nc_LDADD = \ +# libgnunetutil.la test_common_allocation_SOURCES = \ test_common_allocation.c diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index e7bba3000..33a340729 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c @@ -179,7 +179,6 @@ static int check_config () { char *hostname; - unsigned int i; struct sockaddr_in v4; struct sockaddr_in6 v6; @@ -206,15 +205,16 @@ check_config () "resolver"); return GNUNET_SYSERR; } - if ((1 == inet_pton (AF_INET, hostname, &v4)) || - (1 == inet_pton (AF_INET6, hostname, &v6))) + if ( (1 == inet_pton (AF_INET, hostname, &v4)) || + (1 == inet_pton (AF_INET6, hostname, &v6)) ) { GNUNET_free (hostname); return GNUNET_OK; } - i = 0; - while (NULL != loopback[i]) - if (0 == strcasecmp (loopback[i++], hostname)) + for (unsigned int i = 0; + NULL != loopback[i]; + i++) + if (0 == strcasecmp (loopback[i], hostname)) { GNUNET_free (hostname); return GNUNET_OK; @@ -297,9 +297,9 @@ shutdown_task (void *cls) static void check_disconnect () { - struct GNUNET_RESOLVER_RequestHandle *rh; - - for (rh = req_head; NULL != rh; rh = rh->next) + for (struct GNUNET_RESOLVER_RequestHandle *rh = req_head; + NULL != rh; + rh = rh->next) if (GNUNET_SYSERR != rh->was_transmitted) return; if (NULL != r_task) @@ -336,7 +336,10 @@ no_resolve (int af, if (ip_len != sizeof (struct in_addr)) return NULL; if (NULL == - inet_ntop (AF_INET, ip, buf, sizeof (buf))) + inet_ntop (AF_INET, + ip, + buf, + sizeof (buf))) { LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); @@ -347,7 +350,10 @@ no_resolve (int af, if (ip_len != sizeof (struct in6_addr)) return NULL; if (NULL == - inet_ntop (AF_INET6, ip, buf, sizeof (buf))) + inet_ntop (AF_INET6, + ip, + buf, + sizeof (buf))) { LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); @@ -422,8 +428,8 @@ process_requests () msg->direction = htonl (rh->direction); msg->af = htonl (rh->af); GNUNET_memcpy (&msg[1], - &rh[1], - rh->data_len); + &rh[1], + rh->data_len); LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting DNS resolution request to DNS service\n"); GNUNET_MQ_send (mq, @@ -611,14 +617,19 @@ numeric_resolution (void *cls) v6.sin6_len = sizeof (v6); #endif hostname = (const char *) &rh[1]; - if (((rh->af == AF_UNSPEC) || (rh->af == AF_INET)) && - (1 == inet_pton (AF_INET, hostname, &v4.sin_addr))) + if ( ( (rh->af == AF_UNSPEC) || + (rh->af == AF_INET) ) && + (1 == inet_pton (AF_INET, + hostname, + &v4.sin_addr)) ) { rh->addr_callback (rh->cls, (const struct sockaddr *) &v4, sizeof (v4)); - if ((rh->af == AF_UNSPEC) && - (1 == inet_pton (AF_INET6, hostname, &v6.sin6_addr))) + if ( (rh->af == AF_UNSPEC) && + (1 == inet_pton (AF_INET6, + hostname, + &v6.sin6_addr)) ) { /* this can happen on some systems IF "hostname" is "localhost" */ rh->addr_callback (rh->cls, @@ -872,7 +883,6 @@ GNUNET_RESOLVER_ip_get (const char *hostname, { struct GNUNET_RESOLVER_RequestHandle *rh; size_t slen; - unsigned int i; struct in_addr v4; struct in6_addr v6; @@ -897,19 +907,26 @@ GNUNET_RESOLVER_ip_get (const char *hostname, rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); rh->direction = GNUNET_NO; /* first, check if this is a numeric address */ - if (((1 == inet_pton (AF_INET, hostname, &v4)) && - ((af == AF_INET) || (af == AF_UNSPEC))) || - ((1 == inet_pton (AF_INET6, hostname, &v6)) && - ((af == AF_INET6) || (af == AF_UNSPEC)))) + if ( ( (1 == inet_pton (AF_INET, + hostname, + &v4)) && + ( (af == AF_INET) || + (af == AF_UNSPEC) ) ) || + ( (1 == inet_pton (AF_INET6, + hostname, + &v6)) && + ( (af == AF_INET6) || + (af == AF_UNSPEC)) ) ) { rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh); return rh; } /* then, check if this is a loopback address */ - i = 0; - while (NULL != loopback[i]) - if (0 == strcasecmp (loopback[i++], + for (unsigned int i = 0; + NULL != loopback[i]; + i++) + if (0 == strcasecmp (loopback[i], hostname)) { rh->task = GNUNET_SCHEDULER_add_now (&loopback_resolution, @@ -1029,8 +1046,8 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, rh->af = sa->sa_family; rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); GNUNET_memcpy (&rh[1], - ip, - ip_len); + ip, + ip_len); rh->data_len = ip_len; rh->direction = GNUNET_YES; rh->received_response = GNUNET_NO; @@ -1067,7 +1084,8 @@ GNUNET_RESOLVER_local_fqdn_get () { char hostname[GNUNET_OS_get_hostname_max_length () + 1]; - if (0 != gethostname (hostname, sizeof (hostname) - 1)) + if (0 != gethostname (hostname, + sizeof (hostname) - 1)) { LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "gethostname"); @@ -1082,7 +1100,10 @@ GNUNET_RESOLVER_local_fqdn_get () int ret; char *rval; - if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai))) + if (0 != (ret = getaddrinfo (hostname, + NULL, + NULL, + &ai))) { LOG (GNUNET_ERROR_TYPE_ERROR, _("Could not resolve our FQDN: %s\n"), @@ -1100,9 +1121,11 @@ GNUNET_RESOLVER_local_fqdn_get () { struct hostent *host; - host = gethostbyname2 (hostname, AF_INET); + host = gethostbyname2 (hostname, + AF_INET); if (NULL == host) - host = gethostbyname2 (hostname, AF_INET6); + host = gethostbyname2 (hostname, + AF_INET6); if (NULL == host) { LOG (GNUNET_ERROR_TYPE_ERROR, -- 2.25.1