Skip to contentSkip to conversation

package/libwebsock: fix build when openssl is disabled

PATCH New Samuel Martin 2 participants 3 messages Jan 2, 2015 – Jan 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libwebsock: fix build when openssl is disabled

Fixes:
http://autobuild.buildroot.org/results/951/95109c7e37aa21228bc71c69e9c66a6821f3174a/

---
 ...c-fully-disable-ssl-support-when-not-enab.patch | 88 ++++++++++++++++++++++
 package/libwebsock/libwebsock.mk                   |  7 ++
 2 files changed, 95 insertions(+)
 create mode 100644 package/libwebsock/0002-configure.ac-fully-disable-ssl-support-when-not-enab.patch
package/libwebsock/0002-configure.ac-fully-disable-ssl-support-when-not-enab.patch new file +88 -0
new file mode 100644
index 0000000..753fb4f
@@ -0,0 +1,88 @@
+From 608297a6c6abdfb3677ddd35ed5b20a085f02a44 Mon Sep 17 00:00:00 2001
+From: Samuel Martin <[email protected]>
+Date: Fri, 2 Jan 2015 23:58:16 +0100
+Subject: [PATCH] configure.ac: fully disable ssl support when not enabled
+
+Signed-off-by: Samuel Martin <[email protected]>
+---
+ configure.ac  | 4 ++++
+ src/api.h     | 2 +-
+ src/types.h   | 4 ++--
+ src/websock.h | 4 ++--
+ 4 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index fc1cadc..dacd4f4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -48,6 +48,10 @@ AS_IF([test "x$have_ssl" = "xyes"],
+ 	[AS_IF([test "x$with_ssl" = "xyes"],
+ 		[AC_MSG_ERROR([SSL support requested but not found])
+ 	])])
++AS_IF([test "x$have_ssl" != "xyes"],
++	[
++		AC_DEFINE([WEBSOCK_HAVE_SSL], [0], [Disable SSL support])
++	])
+ 
+ AM_CONDITIONAL([HAVE_SSL], [test "x$have_ssl" = "xyes"])
+ 
+diff --git a/src/api.h b/src/api.h
+index d3e8e7c..6324b3d 100644
+--- a/src/api.h
++++ b/src/api.h
+@@ -37,7 +37,7 @@ libwebsock_context *libwebsock_init(void);
+ libwebsock_context *libwebsock_init_flags(int flags);
+ libwebsock_context *libwebsock_init_base(struct event_base *base, int flags);
+ 
+-#ifdef WEBSOCK_HAVE_SSL
++#if defined(WEBSOCK_HAVE_SSL) && WEBSOCK_HAVE_SSL
+ void libwebsock_bind_ssl(libwebsock_context *ctx, char *listen_host, char *port, char *keyfile, char *certfile);
+ void libwebsock_bind_ssl_real(libwebsock_context *ctx, char *listen_host, char *port, char *keyfile, char *certfile, char *chainfile);
+ #endif
+diff --git a/src/types.h b/src/types.h
+index 9c19795..6d4f1c5 100644
+--- a/src/types.h
++++ b/src/types.h
+@@ -90,7 +90,7 @@ typedef struct _libwebsock_client_state {
+         int (*onopen)(struct _libwebsock_client_state *);
+         int (*onclose)(struct _libwebsock_client_state *);
+         int (*onpong)(struct _libwebsock_client_state *);
+-#ifdef WEBSOCK_HAVE_SSL
++#if defined(WEBSOCK_HAVE_SSL) && WEBSOCK_HAVE_SSL
+         SSL *ssl;
+ #endif
+         libwebsock_close_info *close_info;
+@@ -132,7 +132,7 @@ typedef struct _libwebsock_fragmented {
+         struct _libwebsock_client_state *state;
+ } libwebsock_fragmented;
+ 
+-#ifdef WEBSOCK_HAVE_SSL
++#if defined(WEBSOCK_HAVE_SSL) && WEBSOCK_HAVE_SSL
+ typedef struct _libwebsock_ssl_event_data {
+         SSL_CTX *ssl_ctx;
+         libwebsock_context *ctx;
+diff --git a/src/websock.h b/src/websock.h
+index 1bbd410..83ac9dc 100644
+--- a/src/websock.h
++++ b/src/websock.h
+@@ -58,7 +58,7 @@
+ #include <event2/thread.h>
+ #include <wchar.h>
+ #include <errno.h>
+-#ifdef WEBSOCK_HAVE_SSL
++#if defined(WEBSOCK_HAVE_SSL) && WEBSOCK_HAVE_SSL
+ #include <openssl/ssl.h>
+ #include <openssl/err.h>
+ #include <event2/bufferevent_ssl.h>
+@@ -149,7 +149,7 @@ void libwebsock_fragmented_add(libwebsock_fragmented *frag, char *buf, unsigned
+ void libwebsock_fragmented_finish(libwebsock_fragmented *frag);
+ libwebsock_fragmented *libwebsock_fragmented_new(libwebsock_client_state *state);
+ 
+-#ifdef WEBSOCK_HAVE_SSL
++#if defined(WEBSOCK_HAVE_SSL) && WEBSOCK_HAVE_SSL
+ void libwebsock_handle_accept_ssl(evutil_socket_t listener, short event, void *arg);
+ #endif
+ 
+-- 
+2.2.1
+
package/libwebsock/libwebsock.mk +7 -0
index 8458883..e57e3ea 100644
@@ -12,4 +12,11 @@ LIBWEBSOCK_INSTALL_STAGING = YES
 LIBWEBSOCK_LICENSE = LGPLv3
 LIBWEBSOCK_LICENSE_FILES = COPYING.lesser
 
+ifeq ($(BR2_PACKAGE_OPENSSL),y)
+LIBWEBSOCK_CONF_OPTS += --with-ssl
+LIBWEBSOCK_DEPENDENCIES += openssl
+else
+LIBWEBSOCK_CONF_OPTS += --without-ssl
+endif
+
 $(eval $(autotools-package))
Signature · 1 line
2.2.1
#1 lore raw

PATCH 1/1 package/libwebsock: fix build when openssl is disabled

Dear Samuel Martin,

Review

Quoted 12 lines · Samuel Martin
(quoted diff) +12 -0
+diff --git a/configure.ac b/configure.ac
+index fc1cadc..dacd4f4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -48,6 +48,10 @@ AS_IF([test "x$have_ssl" = "xyes"],
+ 	[AS_IF([test "x$with_ssl" = "xyes"],
+ 		[AC_MSG_ERROR([SSL support requested but not found])
+ 	])])
++AS_IF([test "x$have_ssl" != "xyes"],
++	[
++		AC_DEFINE([WEBSOCK_HAVE_SSL], [0], [Disable SSL support])
++	])

I'm sorry but this is not the right fix. Autoconf always uses undefined vs. defined as a way of testing whether a feature is available.

The right fix seems rather to be something like:

src/websock.h +1 -0
index 1bbd410..690c41d 100644
@@ -17,6 +17,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+#include "config.h"
 #include "websock_config.h"
 
 //this bit hides differences between systems on big-endian conversions
src/websock_config.h.in +0 -1
index a25472b..eba8f31 100644
@@ -4,6 +4,5 @@
 #define WEBSOCK_PACKAGE_STRING @WEBSOCK_PACKAGE_STRING@
 #define WEBSOCK_PACKAGE_VERSION @WEBSOCK_PACKAGE_VERSION@
 #define WEBSOCK_PACKAGE_NAME @WEBSOCK_PACKAGE_NAME@
-#define WEBSOCK_HAVE_SSL @WEBSOCK_HAVE_SSL@
 
 #endif

Basically, the problem is that websock_config.h.in defines WEBSOCK_HAVE_SSL unconditionally. When SSL is not available, it remains defined to @WEBSOCK_HAVE_SSL@ in the resulting websock_config.h, which means that for the rest of the code, WEBSOCK_HAVE_SSL is indeed defined.

The fix is to get rid of this stupid line in websock_config.h.in, and instead make the code use config.h, which properly defines WEBSOCK_HAVE_SSL only when SSL is available.

Could you do some testing with the above patch (I did some minimal amount of testing, and it seemed to work), and resubmit a new version?

In the mean time, I'll mark your patch as Changes Requested in patchwork.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/libwebsock: fix build when openssl is disabled

Quoted 55 lines · Thomas Petazzoni

Dear Samuel Martin,

Review

Quoted 12 lines · Samuel Martin
(quoted diff) +12 -0
+diff --git a/configure.ac b/configure.ac
+index fc1cadc..dacd4f4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -48,6 +48,10 @@ AS_IF([test "x$have_ssl" = "xyes"],
+     [AS_IF([test "x$with_ssl" = "xyes"],
+             [AC_MSG_ERROR([SSL support requested but not found])
+     ])])
++AS_IF([test "x$have_ssl" != "xyes"],
++    [
++            AC_DEFINE([WEBSOCK_HAVE_SSL], [0], [Disable SSL support])
++    ])

I'm sorry but this is not the right fix. Autoconf always uses undefined vs. defined as a way of testing whether a feature is available.

The right fix seems rather to be something like:

src/websock.h +1 -0
index 1bbd410..690c41d 100644
@@ -17,6 +17,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
+#include "config.h"
 #include "websock_config.h"
 
 //this bit hides differences between systems on big-endian conversions
src/websock_config.h.in +0 -1
index a25472b..eba8f31 100644
@@ -4,6 +4,5 @@
 #define WEBSOCK_PACKAGE_STRING @WEBSOCK_PACKAGE_STRING@
 #define WEBSOCK_PACKAGE_VERSION @WEBSOCK_PACKAGE_VERSION@
 #define WEBSOCK_PACKAGE_NAME @WEBSOCK_PACKAGE_NAME@
-#define WEBSOCK_HAVE_SSL @WEBSOCK_HAVE_SSL@
 
 #endif

Basically, the problem is that websock_config.h.in defines WEBSOCK_HAVE_SSL unconditionally. When SSL is not available, it remains defined to @WEBSOCK_HAVE_SSL@ in the resulting websock_config.h, which means that for the rest of the code, WEBSOCK_HAVE_SSL is indeed defined.

The fix is to get rid of this stupid line in websock_config.h.in, and instead make the code use config.h, which properly defines WEBSOCK_HAVE_SSL only when SSL is available.

Quoted 6 lines

Could you do some testing with the above patch (I did some minimal amount of testing, and it seemed to work), and resubmit a new version?

In the mean time, I'll mark your patch as Changes Requested in patchwork.

Thanks!

Thanks a lot Thomas.
I was not sure about the way I did the fixed. I'll work on it.

Regards,

Signature · 1 line
Samuel