iputils-20121221-openssl.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From b57d77dcfa5cb363b7eba5b331324669a8505ac4 Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Thu, 24 Jan 2013 23:32:39 -0500
  4. Subject: [PATCH [iputils]] ping6: allow disabling of openssl support
  5. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  6. ---
  7. Makefile | 5 ++++-
  8. ping6.c | 14 +++++++++++++-
  9. 2 files changed, 17 insertions(+), 2 deletions(-)
  10. diff --git a/Makefile b/Makefile
  11. index 89249f5..2c49940 100644
  12. --- a/Makefile
  13. +++ b/Makefile
  14. @@ -36,7 +36,7 @@ ARPING_DEFAULT_DEVICE=
  15. # GNU TLS library for ping6 [yes|no|static]
  16. USE_GNUTLS=yes
  17. -# Crypto library for ping6 [shared|static]
  18. +# Crypto library for ping6 [shared|static|no]
  19. USE_CRYPTO=shared
  20. # Resolv library for ping6 [yes|static]
  21. USE_RESOLV=yes
  22. @@ -63,7 +63,10 @@ ifneq ($(USE_GNUTLS),no)
  23. LIB_CRYPTO = $(call FUNC_LIB,$(USE_GNUTLS),$(LDFLAG_GNUTLS))
  24. DEF_CRYPTO = -DUSE_GNUTLS
  25. else
  26. +ifneq ($(USE_CRYPTO),no)
  27. LIB_CRYPTO = $(call FUNC_LIB,$(USE_CRYPTO),$(LDFLAG_CRYPTO))
  28. + DEF_CRYPTO = -DUSE_OPENSSL
  29. +endif
  30. endif
  31. # USE_RESOLV: LIB_RESOLV
  32. diff --git a/ping6.c b/ping6.c
  33. index c39864d..f2f90af 100644
  34. --- a/ping6.c
  35. +++ b/ping6.c
  36. @@ -168,8 +168,10 @@ static int icmp_sock;
  37. #ifdef USE_GNUTLS
  38. # include <gnutls/openssl.h>
  39. -#else
  40. +# define USE_CRYPTO
  41. +#elif defined USE_OPENSSL
  42. # include <openssl/md5.h>
  43. +# define USE_CRYPTO
  44. #endif
  45. /* Node Information query */
  46. @@ -326,6 +328,7 @@ static void niquery_init_nonce(void)
  47. #if !PING6_NONCE_MEMORY
  48. static int niquery_nonce(__u8 *nonce, int fill)
  49. {
  50. +# ifdef USE_CRYPTO
  51. static __u8 digest[MD5_DIGEST_LENGTH];
  52. static int seq = -1;
  53. @@ -348,6 +351,10 @@ static int niquery_nonce(__u8 *nonce, int fill)
  54. return -1;
  55. return ntohsp((__u16 *)nonce);
  56. }
  57. +# else
  58. + fprintf(stderr, "ping6: function not available; crypto disabled\n");
  59. + exit(3);
  60. +# endif
  61. }
  62. #endif
  63. @@ -502,6 +509,7 @@ static int niquery_option_subject_addr_handler(int index, const char *arg)
  64. static int niquery_option_subject_name_handler(int index, const char *arg)
  65. {
  66. +#ifdef USE_CRYPTO
  67. static char nigroup_buf[INET6_ADDRSTRLEN + 1 + IFNAMSIZ];
  68. unsigned char *dnptrs[2], **dpp, **lastdnptr;
  69. int n;
  70. @@ -627,6 +635,10 @@ errexit:
  71. free(idn);
  72. free(name);
  73. exit(1);
  74. +#else
  75. + fprintf(stderr, "ping6: function not available; crypto disabled\n");
  76. + exit(3);
  77. +#endif
  78. }
  79. int niquery_option_help_handler(int index, const char *arg)
  80. --
  81. 1.8.0.2