You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.0 KiB

  1. From 0543f1d02ee733d34ee109d00e7d0efd432bb37b Mon Sep 17 00:00:00 2001
  2. From: Lee Duncan <lduncan@suse.com>
  3. Date: Tue, 28 Jan 2020 11:49:55 -0800
  4. Subject: [PATCH] Fix compiler issue when not in security mode
  5. ---
  6. client.c | 20 +++++++++++++-------
  7. db-policy.c | 12 +++++++++---
  8. include/libisns/util.h | 1 +
  9. isnsadm.c | 2 +-
  10. security.c | 14 ++++++++------
  11. socket.c | 5 +++--
  12. 6 files changed, 35 insertions(+), 19 deletions(-)
  13. diff --git a/client.c b/client.c
  14. index 8487877..fda26be 100644
  15. --- a/client.c
  16. +++ b/client.c
  17. @@ -122,22 +122,17 @@ isns_client_get_local_address(const isns_client_t *clnt,
  18. /*
  19. * Create a security context
  20. */
  21. +#ifdef WITH_SECURITY
  22. static isns_security_t *
  23. __create_security_context(const char *name, const char *auth_key,
  24. const char *server_key)
  25. {
  26. -#ifdef WITH_SECURITY
  27. isns_security_t *ctx;
  28. isns_principal_t *princ;
  29. -#endif /* WITH_SECURITY */
  30. if (!isns_config.ic_security)
  31. return NULL;
  32. -#ifndef WITH_SECURITY
  33. - isns_error("Cannot create security context: security disabled at build time\n");
  34. - return NULL;
  35. -#else /* WITH_SECURITY */
  36. ctx = isns_create_dsa_context();
  37. if (ctx == NULL)
  38. isns_fatal("Unable to create security context\n");
  39. @@ -174,8 +169,19 @@ __create_security_context(const char *name, const char *auth_key,
  40. }
  41. return ctx;
  42. -#endif /* WITH_SECURITY */
  43. }
  44. +#else /* WITH_SECURITY */
  45. +static isns_security_t *
  46. +__create_security_context(__attribute__((unused))const char *name,
  47. + __attribute__((unused))const char *auth_key,
  48. + __attribute__((unused))const char *server_key)
  49. +{
  50. + if (!isns_config.ic_security)
  51. + return NULL;
  52. + isns_error("Cannot create security context: security disabled at build time\n");
  53. + return NULL;
  54. +}
  55. +#endif /* WITH_SECURITY */
  56. /*
  57. * Create the default security context
  58. diff --git a/db-policy.c b/db-policy.c
  59. index b1c46e2..d4a0cba 100644
  60. --- a/db-policy.c
  61. +++ b/db-policy.c
  62. @@ -52,11 +52,11 @@ __isns_db_keystore_lookup(isns_db_keystore_t *store,
  63. /*
  64. * Load a DSA key from the DB store
  65. */
  66. +#ifdef WITH_SECURITY
  67. static EVP_PKEY *
  68. __isns_db_keystore_find(isns_keystore_t *store_base,
  69. const char *name, size_t namelen)
  70. {
  71. -#ifdef WITH_SECURITY
  72. isns_db_keystore_t *store = (isns_db_keystore_t *) store_base;
  73. isns_object_t *obj;
  74. const void *key_data;
  75. @@ -71,10 +71,16 @@ __isns_db_keystore_find(isns_keystore_t *store_base,
  76. return NULL;
  77. return isns_dsa_decode_public(key_data, key_size);
  78. -#else
  79. +}
  80. +#else /* WITH_SECURITY */
  81. +static EVP_PKEY *
  82. +__isns_db_keystore_find(__attribute__((unused))isns_keystore_t *store_base,
  83. + __attribute__((unused))const char *name,
  84. + __attribute__((unused))size_t namelen)
  85. +{
  86. return NULL;
  87. -#endif
  88. }
  89. +#endif /* WITH_SECURITY */
  90. /*
  91. * Retrieve policy from database
  92. diff --git a/include/libisns/util.h b/include/libisns/util.h
  93. index 4174480..e5ed037 100644
  94. --- a/include/libisns/util.h
  95. +++ b/include/libisns/util.h
  96. @@ -14,6 +14,7 @@
  97. #include <string.h> // for strdup
  98. #include <signal.h>
  99. #include <libisns/types.h>
  100. +#include <stdlib.h>
  101. #define array_num_elements(a) (sizeof(a) / sizeof((a)[0]))
  102. diff --git a/isnsadm.c b/isnsadm.c
  103. index 7a96007..94c705e 100644
  104. --- a/isnsadm.c
  105. +++ b/isnsadm.c
  106. @@ -1162,7 +1162,7 @@ generate_key_callback(void)
  107. }
  108. isns_attr_t *
  109. -load_key_callback(const char *pathname)
  110. +load_key_callback(__attribute__((unused))const char *pathname)
  111. {
  112. isns_fatal("Authentication disabled in this build\n");
  113. return NULL;
  114. diff --git a/security.c b/security.c
  115. index 673a26e..68eb779 100644
  116. --- a/security.c
  117. +++ b/security.c
  118. @@ -408,32 +408,34 @@ isns_security_init(void)
  119. }
  120. isns_keystore_t *
  121. -isns_create_keystore(const char *spec)
  122. +isns_create_keystore(__attribute__((unused))const char *spec)
  123. {
  124. isns_no_security();
  125. return NULL;
  126. }
  127. void
  128. -isns_security_set_keystore(isns_security_t *ctx,
  129. - isns_keystore_t *ks)
  130. +isns_security_set_keystore(__attribute__((unused))isns_security_t *ctx,
  131. + __attribute__((unused))isns_keystore_t *ks)
  132. {
  133. isns_no_security();
  134. }
  135. void
  136. -isns_principal_free(isns_principal_t *peer)
  137. +isns_principal_free(__attribute__((unused))isns_principal_t *peer)
  138. {
  139. }
  140. isns_principal_t *
  141. -isns_get_principal(isns_security_t *ctx, const char *spi, size_t spi_len)
  142. +isns_get_principal(__attribute__((unused))isns_security_t *ctx,
  143. + __attribute__((unused))const char *spi,
  144. + __attribute__((unused))size_t spi_len)
  145. {
  146. return NULL;
  147. }
  148. const char *
  149. -isns_principal_name(const isns_principal_t *princ)
  150. +isns_principal_name(__attribute__((unused))const isns_principal_t *princ)
  151. {
  152. return NULL;
  153. }
  154. diff --git a/socket.c b/socket.c
  155. index da9f5dc..a76d593 100644
  156. --- a/socket.c
  157. +++ b/socket.c
  158. @@ -322,8 +322,9 @@ isns_pdu_authenticate(isns_security_t *sec,
  159. }
  160. #else /* WITH_SECURITY */
  161. static int
  162. -isns_pdu_authenticate(isns_security_t *sec,
  163. - struct isns_partial_msg *msg, buf_t *bp)
  164. +isns_pdu_authenticate(__attribute__((unused))isns_security_t *sec,
  165. + __attribute__((unused))struct isns_partial_msg *msg,
  166. + __attribute__((unused))buf_t *bp)
  167. {
  168. return 0;
  169. }