Re: [ANNOUNCE] haproxy-1.4.0

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 3 Mar 2010 23:12:13 +0100


On Wed, Mar 03, 2010 at 01:02:16AM +0100, Krzysztof Ol??dzki wrote:
> On 2010-03-03 00:47, Willy Tarreau wrote:
> >On Wed, Mar 03, 2010 at 12:39:48AM +0100, Willy Tarreau wrote:
> >>>Finally, encryption was only tested on Linux and FreeBSD so it could be
> >>>nice to verify if it works on Solaris in the same way (with -lcrypt) and
> >>>to add USE_LIBCRYPT for "ifeq ($(TARGET),solaris)".
> >>
> >>OK I'm testing it now then and will keep you informed.
> >
> >it builds with the same warning as we had on linux, despite the
> >man not mentioning anything specific.
>
> :( Did you include unistd.h? If so, could you try defining _XOPEN_SOURCE
> to 600?

Yes unistd.h is included as indicated in the man page, but still the warning. I've tried with _XOPEN_SOURCE set to 600 and it reported even more errors than with 500. In fact, any value other than 500 reports a huge number of errors in many includes files.

So in the end I've added a new build option USE_CRYPT_H which for now I only set by default for solaris (though it works on linux, various toolchains except dietlibc). It will make it easy to enable it for other systems if required.

Using the following patch I can build it everywhere here without a warning. Could you please test on your various FreeBSD versions, I see no reason why it should change anything, it's just for the sake of completeness.

Thanks !
Willy

diff --git a/Makefile b/Makefile
index 022731d..4c13355 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,8 @@

 #   USE_TPROXY           : enable transparent proxy. Automatic.
 #   USE_LINUX_TPROXY     : enable full transparent proxy (need kernel patch).
 #   USE_LINUX_SPLICE     : enable kernel 2.6 splicing (broken on old kernels)
+#   USE_LIBCRYPT         : enable crypted passwords using -lcrypt
+#   USE_CRYPT_H          : set it if your system requires including crypt.h
 #
 # Options can be forced by specifying "USE_xxx=1" or can be disabled by using
 # "USE_xxx=" (empty string).

@@ -208,6 +210,8 @@ ifeq ($(TARGET),solaris)
   TARGET_CFLAGS  = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT
   TARGET_LDFLAGS = -lnsl -lsocket
   USE_TPROXY     = implicit
+  USE_LIBCRYPT    = implicit
+  USE_CRYPT_H     = implicit

 else
 ifeq ($(TARGET),freebsd)
   # This is for FreeBSD
@@ -336,6 +340,11 @@ BUILD_OPTIONS += $(call ignore_implicit,USE_LIBCRYPT)  OPTIONS_LDFLAGS += -lcrypt
 endif  
+ifneq ($(USE_CRYPT_H),)
+OPTIONS_CFLAGS  += -DNEED_CRYPT_H
+BUILD_OPTIONS   += $(call ignore_implicit,USE_CRYPT_H)
+endif
+

 ifneq ($(USE_POLL),)
 OPTIONS_CFLAGS += -DENABLE_POLL
 OPTIONS_OBJS += src/ev_poll.o
diff --git a/src/auth.c b/src/auth.c
index 93af8d6..5fecca5 100644
--- a/src/auth.c
+++ b/src/auth.c

@@ -10,7 +10,12 @@
  *
  */  

-#define _XOPEN_SOURCE 500

+/* This is to have crypt() defined on Linux */
+#define _GNU_SOURCE
+
+#ifdef NEED_CRYPT_H
+#include <crypt.h>
+#endif
 

 #include <stdio.h>
 #include <stdlib.h> Received on 2010/03/03 23:12

This archive was generated by hypermail 2.2.0 : 2010/03/03 23:15 CET