From c9f82d522de116fdd274053ad9dfd6923a4a558e Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Thu, 5 Sep 2013 11:15:34 +0200 Subject: [PATCH] csprng: add portability fixes --- ...ils-fix-portability-of-error.h-usage.patch | 136 ++++++++++++++++++ ...-csprng-generate-to-include-limits.h.patch | 40 ++++++ ...tils-fix-csprngd-to-include-limits.h.patch | 40 ++++++ 3 files changed, 216 insertions(+) create mode 100644 security/csprng/0002-utils-fix-portability-of-error.h-usage.patch create mode 100644 security/csprng/0003-utils-fix-csprng-generate-to-include-limits.h.patch create mode 100644 security/csprng/0004-utils-fix-csprngd-to-include-limits.h.patch diff --git a/security/csprng/0002-utils-fix-portability-of-error.h-usage.patch b/security/csprng/0002-utils-fix-portability-of-error.h-usage.patch new file mode 100644 index 000000000..4c9e74160 --- /dev/null +++ b/security/csprng/0002-utils-fix-portability-of-error.h-usage.patch @@ -0,0 +1,136 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../csprng/0002-utils-fix-portability-of-error.h-usage.patch +# Copyright (C) 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From 0f4e04b4aa760e5a48f0ada3c19a3bf9e00666b8 Mon Sep 17 00:00:00 2001 +From: Christian Wiese +Date: Thu, 5 Sep 2013 09:57:46 +0200 +Subject: [PATCH] utils: fix portability of error.h usage + +error(3) is an non-portable gnu extension thus we need to handle the +case when it is not available, like in the case of musl libc which is +not providing this extension. + +From what I have tested so far error.h is only available in glibc and uclibc, +but not in musl libc. +--- + configure.ac | 1 + + utils/csprng-generate.c | 2 +- + utils/csprng_error.h | 19 +++++++++++++++++++ + utils/csprngd.c | 2 +- + utils/random_interface_linux.c | 2 +- + 5 files changed, 23 insertions(+), 3 deletions(-) + create mode 100644 utils/csprng_error.h + +diff --git a/configure.ac b/configure.ac +index 12fd277..bce1891 100755 +--- a/configure.ac ++++ b/configure.ac +@@ -91,6 +91,7 @@ AC_CHECK_HEADERS([openssl/err.h openssl/rand.h openssl/sha.h openssl/bn.h],[],[A + ## Checks for header files. + AC_HEADER_STDC + AC_HEADER_SYS_WAIT ++AC_CHECK_HEADERS([error.h]) + AC_CHECK_HEADERS([fcntl.h]) + AC_CHECK_HEADERS([stdlib.h]) + AC_CHECK_HEADERS([string.h]) +diff --git a/utils/csprng-generate.c b/utils/csprng-generate.c +index 7a1928a..9d6fa58 100644 +--- a/utils/csprng-generate.c ++++ b/utils/csprng-generate.c +@@ -58,7 +58,6 @@ along with CSRNG. If not, see . + #include + + +-#include + #include + #include + #include +@@ -74,6 +73,7 @@ along with CSRNG. If not, see . + + + #include "config.h" ++#include "csprng_error.h" + + /* Value added to key to get the key of the opposite option*/ + #define OPP 256 +diff --git a/utils/csprng_error.h b/utils/csprng_error.h +new file mode 100644 +index 0000000..2c18414 +--- /dev/null ++++ b/utils/csprng_error.h +@@ -0,0 +1,19 @@ ++#ifndef _CSPRNG_ERROR_H ++#define _CSPRNG_ERROR_H ++ ++#if defined(HAVE_ERROR_H) ++#include ++#else ++#include ++#include ++#define _csprng_error(S, E, F, ...) do { \ ++ if (E) \ ++ err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \ ++ else \ ++ err(S, F, ##__VA_ARGS__); \ ++} while(0) ++ ++#define error _csprng_error ++#endif ++ ++#endif +diff --git a/utils/csprngd.c b/utils/csprngd.c +index 8fd63be..31cf51e 100644 +--- a/utils/csprngd.c ++++ b/utils/csprngd.c +@@ -67,7 +67,6 @@ mpstat -P ALL 2 + #include + + +-#include + #include + #include + #include +@@ -90,6 +89,7 @@ mpstat -P ALL 2 + + #include "random_interface_linux.h" + #include "config.h" ++#include "csprng_error.h" + + //getrlimit + #include +diff --git a/utils/random_interface_linux.c b/utils/random_interface_linux.c +index 77552eb..46370fd 100644 +--- a/utils/random_interface_linux.c ++++ b/utils/random_interface_linux.c +@@ -30,7 +30,6 @@ along with CSRNG. If not, see . + #include //uname system call + #include + #include +-#include + #include + #include + +@@ -45,6 +44,7 @@ along with CSRNG. If not, see . + + #include + #include "random_interface_linux.h" ++#include "csprng_error.h" + + //{{{ kernel_mode_t get_kernel_version( void ) + //Get version of Linux kernel +-- +1.7.2.3 + diff --git a/security/csprng/0003-utils-fix-csprng-generate-to-include-limits.h.patch b/security/csprng/0003-utils-fix-csprng-generate-to-include-limits.h.patch new file mode 100644 index 000000000..5b183cf29 --- /dev/null +++ b/security/csprng/0003-utils-fix-csprng-generate-to-include-limits.h.patch @@ -0,0 +1,40 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../csprng/0003-utils-fix-csprng-generate-to-include-limits.h.patch +# Copyright (C) 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From f2af70814524601ef2c5b2bf347ee7751c062efd Mon Sep 17 00:00:00 2001 +From: Christian Wiese +Date: Thu, 5 Sep 2013 00:36:29 +0200 +Subject: [PATCH] utils: fix csprng-generate to include limits.h + +--- + utils/csprng-generate.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/utils/csprng-generate.c b/utils/csprng-generate.c +index 9d6fa58..c34b122 100644 +--- a/utils/csprng-generate.c ++++ b/utils/csprng-generate.c +@@ -53,6 +53,7 @@ along with CSRNG. If not, see . + + #include + #include ++#include /* for INT_MAX, LONG_MAX */ + + #include + #include +-- +1.7.2.3 + diff --git a/security/csprng/0004-utils-fix-csprngd-to-include-limits.h.patch b/security/csprng/0004-utils-fix-csprngd-to-include-limits.h.patch new file mode 100644 index 000000000..d21c23be4 --- /dev/null +++ b/security/csprng/0004-utils-fix-csprngd-to-include-limits.h.patch @@ -0,0 +1,40 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../csprng/0004-utils-fix-csprngd-to-include-limits.h.patch +# Copyright (C) 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From 169ca463e9819fa06d70730eb95e440bb1f6a2a0 Mon Sep 17 00:00:00 2001 +From: Christian Wiese +Date: Thu, 5 Sep 2013 02:08:09 +0200 +Subject: [PATCH] utils: fix csprngd to include limits.h + +--- + utils/csprngd.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/utils/csprngd.c b/utils/csprngd.c +index 31cf51e..4115566 100644 +--- a/utils/csprngd.c ++++ b/utils/csprngd.c +@@ -62,6 +62,7 @@ mpstat -P ALL 2 + #define _GNU_SOURCE + #include + #include ++#include /* for INT_MAX, LONG_MAX */ + + #include + #include +-- +1.7.2.3 +