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