OpenSDE Packages Database (without history before r20070)
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.

237 lines
6.9 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../csprng/0002-utils-fix-portability-of-error.h-usage.patch
  5. # Copyright (C) 2013 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 752194d531bd7f8bdd49b51b32c11b95503d109f Mon Sep 17 00:00:00 2001
  17. From: Christian Wiese <chris@opensde.org>
  18. Date: Thu, 5 Sep 2013 09:57:46 +0200
  19. Subject: [PATCH] utils: fix portability of error.h usage
  20. error(3) is an non-portable gnu extension thus we need to handle the
  21. case when it is not available, like in the case of musl libc which is
  22. not providing this extension.
  23. From what I have tested so far error.h is only available in glibc and uclibc,
  24. but not in musl libc.
  25. Signed-off-by: Christian Wiese <chris@opensde.org>
  26. ---
  27. configure.ac | 1 +
  28. include/internal/csprng_error.h | 19 +++++++++++++++++++
  29. test/Makefile.am | 1 +
  30. test/havege_main.c | 2 +-
  31. test/http_main.c | 2 +-
  32. test/memt_main.c | 2 +-
  33. test/openssl-rand_main.c | 2 +-
  34. test/qrbg_main.c | 2 +-
  35. test/sha1_main.c | 2 +-
  36. utils/csprng-generate.c | 2 +-
  37. utils/csprngd.c | 3 ++-
  38. utils/random_interface_linux.c | 3 ++-
  39. 12 files changed, 32 insertions(+), 9 deletions(-)
  40. create mode 100644 include/internal/csprng_error.h
  41. diff --git a/configure.ac b/configure.ac
  42. index 12fd277..bce1891 100755
  43. --- a/configure.ac
  44. +++ b/configure.ac
  45. @@ -91,6 +91,7 @@ AC_CHECK_HEADERS([openssl/err.h openssl/rand.h openssl/sha.h openssl/bn.h],[],[A
  46. ## Checks for header files.
  47. AC_HEADER_STDC
  48. AC_HEADER_SYS_WAIT
  49. +AC_CHECK_HEADERS([error.h])
  50. AC_CHECK_HEADERS([fcntl.h])
  51. AC_CHECK_HEADERS([stdlib.h])
  52. AC_CHECK_HEADERS([string.h])
  53. diff --git a/include/internal/csprng_error.h b/include/internal/csprng_error.h
  54. new file mode 100644
  55. index 0000000..2c18414
  56. --- /dev/null
  57. +++ b/include/internal/csprng_error.h
  58. @@ -0,0 +1,19 @@
  59. +#ifndef _CSPRNG_ERROR_H
  60. +#define _CSPRNG_ERROR_H
  61. +
  62. +#if defined(HAVE_ERROR_H)
  63. +#include <error.h>
  64. +#else
  65. +#include <err.h>
  66. +#include <string.h>
  67. +#define _csprng_error(S, E, F, ...) do { \
  68. + if (E) \
  69. + err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \
  70. + else \
  71. + err(S, F, ##__VA_ARGS__); \
  72. +} while(0)
  73. +
  74. +#define error _csprng_error
  75. +#endif
  76. +
  77. +#endif
  78. diff --git a/test/Makefile.am b/test/Makefile.am
  79. index 023ded7..409ab54 100644
  80. --- a/test/Makefile.am
  81. +++ b/test/Makefile.am
  82. @@ -12,6 +12,7 @@ if HAVE_LIBTESTU01
  83. bin_PROGRAMS += TestU01_raw_stdin_input_with_log
  84. endif
  85. +openssl_rand_main_CPPFLAGS = -I$(top_srcdir)/include
  86. openssl_rand_main_SOURCES = openssl-rand_main.c
  87. openssl_rand_main_LDADD = -lcrypto
  88. diff --git a/test/havege_main.c b/test/havege_main.c
  89. index 181a997..1a03c18 100644
  90. --- a/test/havege_main.c
  91. +++ b/test/havege_main.c
  92. @@ -34,7 +34,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  93. #include <assert.h>
  94. #include <string.h>
  95. #include <errno.h>
  96. -#include <error.h>
  97. +#include <internal/csprng_error.h>
  98. #include <csprng/havege.h>
  99. #include <openssl/sha.h>
  100. diff --git a/test/http_main.c b/test/http_main.c
  101. index 9b10034..d3c14a0 100644
  102. --- a/test/http_main.c
  103. +++ b/test/http_main.c
  104. @@ -33,7 +33,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  105. #include <csprng/http_rng.h>
  106. #include <time.h>
  107. #include <errno.h>
  108. -#include <error.h>
  109. +#include <internal/csprng_error.h>
  110. #include <string.h>
  111. diff --git a/test/memt_main.c b/test/memt_main.c
  112. index 29ddfca..6037596 100644
  113. --- a/test/memt_main.c
  114. +++ b/test/memt_main.c
  115. @@ -38,7 +38,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  116. #include <inttypes.h>
  117. #include <assert.h>
  118. #include <errno.h>
  119. -#include <error.h>
  120. +#include <internal/csprng_error.h>
  121. int main(void)
  122. {
  123. diff --git a/test/openssl-rand_main.c b/test/openssl-rand_main.c
  124. index 5a4e5b6..78ec057 100644
  125. --- a/test/openssl-rand_main.c
  126. +++ b/test/openssl-rand_main.c
  127. @@ -31,7 +31,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  128. #include <stdlib.h>
  129. #include <inttypes.h>
  130. #include <errno.h>
  131. -#include <error.h>
  132. +#include <internal/csprng_error.h>
  133. #include <openssl/rand.h>
  134. diff --git a/test/qrbg_main.c b/test/qrbg_main.c
  135. index 4cf3a35..5dd1492 100644
  136. --- a/test/qrbg_main.c
  137. +++ b/test/qrbg_main.c
  138. @@ -32,7 +32,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  139. #include <errno.h>
  140. #include <string.h>
  141. #include <errno.h>
  142. -#include <error.h>
  143. +#include <internal/csprng_error.h>
  144. #include <csprng/qrbg-c.h>
  145. diff --git a/test/sha1_main.c b/test/sha1_main.c
  146. index 9b5753b..0a2349d 100644
  147. --- a/test/sha1_main.c
  148. +++ b/test/sha1_main.c
  149. @@ -31,7 +31,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  150. #include <stdlib.h>
  151. #include <inttypes.h>
  152. #include <errno.h>
  153. -#include <error.h>
  154. +#include <internal/csprng_error.h>
  155. #include <csprng/sha1_rng.h>
  156. diff --git a/utils/csprng-generate.c b/utils/csprng-generate.c
  157. index 7a1928a..cffffcd 100644
  158. --- a/utils/csprng-generate.c
  159. +++ b/utils/csprng-generate.c
  160. @@ -58,7 +58,6 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  161. #include <csprng/helper_utils.h>
  162. -#include <error.h>
  163. #include <argp.h>
  164. #include <string.h>
  165. #include <math.h>
  166. @@ -72,6 +71,7 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  167. #include <sys/stat.h>
  168. #include <unistd.h>
  169. +#include <internal/csprng_error.h>
  170. #include "config.h"
  171. diff --git a/utils/csprngd.c b/utils/csprngd.c
  172. index 8fd63be..9ddbe27 100644
  173. --- a/utils/csprngd.c
  174. +++ b/utils/csprngd.c
  175. @@ -67,7 +67,6 @@ mpstat -P ALL 2
  176. #include <csprng/helper_utils.h>
  177. -#include <error.h>
  178. #include <argp.h>
  179. #include <string.h>
  180. #include <assert.h>
  181. @@ -88,6 +87,8 @@ mpstat -P ALL 2
  182. #include <sys/mman.h> //mlock
  183. #include <sys/file.h> //flock
  184. +#include <internal/csprng_error.h>
  185. +
  186. #include "random_interface_linux.h"
  187. #include "config.h"
  188. diff --git a/utils/random_interface_linux.c b/utils/random_interface_linux.c
  189. index 77552eb..ebe79b2 100644
  190. --- a/utils/random_interface_linux.c
  191. +++ b/utils/random_interface_linux.c
  192. @@ -30,7 +30,6 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  193. #include <sys/utsname.h> //uname system call
  194. #include <stdarg.h>
  195. #include <errno.h>
  196. -#include <error.h>
  197. #include <time.h>
  198. #include <signal.h>
  199. @@ -43,6 +42,8 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
  200. //
  201. #include <linux/random.h>
  202. +#include <internal/csprng_error.h>
  203. +
  204. #include <csprng/helper_utils.h>
  205. #include "random_interface_linux.h"
  206. --
  207. 1.7.2.3