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.

173 lines
4.5 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. --- a/client.c
  14. +++ b/client.c
  15. @@ -122,22 +122,17 @@ isns_client_get_local_address(const isns
  16. /*
  17. * Create a security context
  18. */
  19. +#ifdef WITH_SECURITY
  20. static isns_security_t *
  21. __create_security_context(const char *name, const char *auth_key,
  22. const char *server_key)
  23. {
  24. -#ifdef WITH_SECURITY
  25. isns_security_t *ctx;
  26. isns_principal_t *princ;
  27. -#endif /* WITH_SECURITY */
  28. if (!isns_config.ic_security)
  29. return NULL;
  30. -#ifndef WITH_SECURITY
  31. - isns_error("Cannot create security context: security disabled at build time\n");
  32. - return NULL;
  33. -#else /* WITH_SECURITY */
  34. ctx = isns_create_dsa_context();
  35. if (ctx == NULL)
  36. isns_fatal("Unable to create security context\n");
  37. @@ -174,8 +169,19 @@ __create_security_context(const char *na
  38. }
  39. return ctx;
  40. -#endif /* WITH_SECURITY */
  41. }
  42. +#else /* WITH_SECURITY */
  43. +static isns_security_t *
  44. +__create_security_context(__attribute__((unused))const char *name,
  45. + __attribute__((unused))const char *auth_key,
  46. + __attribute__((unused))const char *server_key)
  47. +{
  48. + if (!isns_config.ic_security)
  49. + return NULL;
  50. + isns_error("Cannot create security context: security disabled at build time\n");
  51. + return NULL;
  52. +}
  53. +#endif /* WITH_SECURITY */
  54. /*
  55. * Create the default security context
  56. --- a/db-policy.c
  57. +++ b/db-policy.c
  58. @@ -52,11 +52,11 @@ __isns_db_keystore_lookup(isns_db_keysto
  59. /*
  60. * Load a DSA key from the DB store
  61. */
  62. +#ifdef WITH_SECURITY
  63. static EVP_PKEY *
  64. __isns_db_keystore_find(isns_keystore_t *store_base,
  65. const char *name, size_t namelen)
  66. {
  67. -#ifdef WITH_SECURITY
  68. isns_db_keystore_t *store = (isns_db_keystore_t *) store_base;
  69. isns_object_t *obj;
  70. const void *key_data;
  71. @@ -71,10 +71,16 @@ __isns_db_keystore_find(isns_keystore_t
  72. return NULL;
  73. return isns_dsa_decode_public(key_data, key_size);
  74. -#else
  75. +}
  76. +#else /* WITH_SECURITY */
  77. +static EVP_PKEY *
  78. +__isns_db_keystore_find(__attribute__((unused))isns_keystore_t *store_base,
  79. + __attribute__((unused))const char *name,
  80. + __attribute__((unused))size_t namelen)
  81. +{
  82. return NULL;
  83. -#endif
  84. }
  85. +#endif /* WITH_SECURITY */
  86. /*
  87. * Retrieve policy from database
  88. --- a/include/libisns/util.h
  89. +++ b/include/libisns/util.h
  90. @@ -14,6 +14,7 @@
  91. #include <string.h> // for strdup
  92. #include <signal.h>
  93. #include <libisns/types.h>
  94. +#include <stdlib.h>
  95. #define array_num_elements(a) (sizeof(a) / sizeof((a)[0]))
  96. --- a/isnsadm.c
  97. +++ b/isnsadm.c
  98. @@ -1162,7 +1162,7 @@ generate_key_callback(void)
  99. }
  100. isns_attr_t *
  101. -load_key_callback(const char *pathname)
  102. +load_key_callback(__attribute__((unused))const char *pathname)
  103. {
  104. isns_fatal("Authentication disabled in this build\n");
  105. return NULL;
  106. --- a/security.c
  107. +++ b/security.c
  108. @@ -408,32 +408,34 @@ isns_security_init(void)
  109. }
  110. isns_keystore_t *
  111. -isns_create_keystore(const char *spec)
  112. +isns_create_keystore(__attribute__((unused))const char *spec)
  113. {
  114. isns_no_security();
  115. return NULL;
  116. }
  117. void
  118. -isns_security_set_keystore(isns_security_t *ctx,
  119. - isns_keystore_t *ks)
  120. +isns_security_set_keystore(__attribute__((unused))isns_security_t *ctx,
  121. + __attribute__((unused))isns_keystore_t *ks)
  122. {
  123. isns_no_security();
  124. }
  125. void
  126. -isns_principal_free(isns_principal_t *peer)
  127. +isns_principal_free(__attribute__((unused))isns_principal_t *peer)
  128. {
  129. }
  130. isns_principal_t *
  131. -isns_get_principal(isns_security_t *ctx, const char *spi, size_t spi_len)
  132. +isns_get_principal(__attribute__((unused))isns_security_t *ctx,
  133. + __attribute__((unused))const char *spi,
  134. + __attribute__((unused))size_t spi_len)
  135. {
  136. return NULL;
  137. }
  138. const char *
  139. -isns_principal_name(const isns_principal_t *princ)
  140. +isns_principal_name(__attribute__((unused))const isns_principal_t *princ)
  141. {
  142. return NULL;
  143. }
  144. --- a/socket.c
  145. +++ b/socket.c
  146. @@ -322,8 +322,9 @@ failed:
  147. }
  148. #else /* WITH_SECURITY */
  149. static int
  150. -isns_pdu_authenticate(isns_security_t *sec,
  151. - struct isns_partial_msg *msg, buf_t *bp)
  152. +isns_pdu_authenticate(__attribute__((unused))isns_security_t *sec,
  153. + __attribute__((unused))struct isns_partial_msg *msg,
  154. + __attribute__((unused))buf_t *bp)
  155. {
  156. return 0;
  157. }