delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2016/01/04/09:43:44

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <568A77AE.8090801@gmx.de>
Date: Mon, 04 Jan 2016 14:46:22 +0100
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: rt AT openssl DOT org, djgpp AT delorie DOT com
Subject: Fixing DJGPP port of openssl master branch.
X-Provags-ID: V03:K0:6iRkG2c775eXgOOerfvZD115woZYb2qd5U6FUejb9adyhroE2EL
UY0HAWL9VZ0TaNnmsV9Wx20E0ZZ8gZAieIE5CKqM4/YfWAOHQlhNL6XYpT0tStBKFtBhGIi
c01qq1h9z5B7T58F4/wzkQ7rNoWohbM12VWXPTDZOs53o1pFIjML5QMsVfznL79C61igSvU
1gOt76mXgA7tiqKJQmyjw==
X-UI-Out-Filterresults: notjunk:1;V01:K0:DOYkV8JCJDg=:wNY/B3V5uuMTd3isJvSXzV
p6rW9TJjx5z8E7GRCj19tEcwOUF0lb3KYSUwoweSDyKQcjthtTwM/Mv63wWsYdm5PMuCZq8Xg
LqjEiIx50Pz9kQfCduuS/Zla7wvqBjydRJXTgd1OKax8B7frIU743U15S5UswQsQ26RGcEnIY
ARlYlXR5JiObizy7U3YxlJTy0QRn6CBHn4jVSXOL9imsBWPh8B0HUpNp/j2bBw38Krf5bzZS3
7kb8XKHRDJGnY6ehOOwba07MvJhpcmoGm+wPPdX10hF02r9389g9qCUW0OGiGdJSREXE0Z83G
AIhCdN2qZlOmCSlrnMZGFmmjZIMOLICxFod9oAY5KPc4zUKxxk74bI0AkFKDLhcOpSslafG0/
3Kou0g7FeACTxftiFN3S3WLUx0vWjXmmoT5uPq0/M2JmxhqvSKDQ+QxCFqHBV0urslHgqTMaq
4hKIKzfNfMqi4/5KV+9Qs8xsSBjMJV4BHklKqujjO3kY4wUuBIBccv5HvTF8D0eTQ/iaUNPBY
ujT9MG5aOZJ4OVT2z+QyhSODdJ/V9zn334E54POltFxr8m3mIae0fnMGWrEDBHFmqCExyEzpz
TBPZak33L/VjitXolZqYgO8nw0PJTIYXluMkQOQdhgMpTAaQaU3R27p0vGaN8L7C2eaOhUZqH
dQxX9rkB4JpB40iWWOXTRTLEcfJJrZdAecrNK162sQOp3WQvgKpgk+Ksq7UGfDeo6Q7EtUVkH
0Y/fNp7j5nwbRP4ejMG5kWPmugqFCJc5x3Z+RklZTfKNvihq74m9mTqUA4I=
Reply-To: djgpp AT delorie DOT com

This is a multi-part message in MIME format.
--------------080700080504010008070106
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Unfortunately the DJGPP port is badly brocken in the master branch.
The provided patch shall fix the issues.

Both patches will fix/improve the following issues:
1) In Configure:
       For some reason -DTERMIO is set but DJGPP has never offered TERMIO making
       the build fail.  I have changed this to -DTERMIOS as is used to be.
2) In crypto/bio/bss_dgram.c:
       The superflous macro definitions of sock_write, sock_read and sock_puts
       enclosed by WATT32 have been removed.
3) In crypto/bio/bss_sock.c:
       Here the existing macro definitions for sock_write, sock_read and sock_puts
       are necessary and must be kept but they must be undefined before they can
       be defined.  This is because newer versions of Watt-32 also redefine them.
4) In crypto/conf/conf_def.c:
       If this port is used on MS-DOS or FreeDOS it becomes necessary to check if
       the underlying file system supports long file names (aka LFN) or not.  If
       it does not then file names with a leading dot like ".rnd" or ".ca_certs"
       are ilicit.  In function def_load_bio, the macros IS_RANDFILE and IS_CERT_DIR
       are used to check if the file system offers LFN support so that the file
       names with leading dots are licit and can be used.  If the tests fail
       then the new function dosify_filename is called and will substitute
       invalid characters in the file name by valid ones before using them.
       This check and the call of dosify_filename is enclosed by OPENSSL_SYS_MSDOS.
5) In e_os.h:
       In the DJGPP section the macros IS_RANDFILE and IS_CERT_DIR are defined.
       Also some auxiliar macros like HAS_LFN_SUPPORT and FILE_EXISTS are defined.
       Because neither MS-DOS nor FreeDOS provide 'egd' sockets, the DEVRANDOM_EGD
       macro is undefined.  This shall inhibit the compilation of code that does
       not work on MS-DOS/FreeDOS.
6) In INSTALL.DJGPP:
       Update URL of WATT-32 library.

I have checked the modified version of the master branch works on linux and
Cygwin.  They are no issues.  This is no surprise because the changes are
either enclosed by the __DJGPP__ or OPENSSL_SYS_MSDOS macros.
If more informaton is required please mail me.  I have attached the patch
as gzip'ed file too.


Regards,
Juan M. Guerrero






2016-01-04  Juan Manuel Guerrero  <juan DOT guerrero AT gmx DOT de>

	* Configurations/10-main.conf:  Replaced -DTERMIO by -DTERMIOS in CFLAGS.

	* crypto/bio/bss_dgram.c [WATT32]:  Remove obsolete redefinition of
	function names: sock_write, sock_read and sock_puts.

	* crypto/bio/bss_sock.c [WATT32]:  For Watt-32 2.2.11 sock_write,
	sock_read and sock_puts are redefined to their private names so their
	names must be undefined first before they can be redefined again.

	* crypto/conf/conf_def.c (def_load_bio) [OPENSSL_SYS_MSDOS]:  Call
	dosify_filename to replace leading dot if file system does not support
	it.
	(dosify_filename):  Replace leading dot in passed file name if file
	system does not support LFN.

	* e_os.h [__DJGPP__]:  Undefine macro DEVRANDOM_EGD.  Neither MS-DOS
	nor FreeDOS provides 'egd' sockets.
	New macros IS_RANDFILE and IS_CERT_DIR are defined to identify the
	RANDFILE entry in openssl.cnf and the cert_dir entry in ssleay.conf.
	New macro RFILE that is defined either to ".rnd" or "_rnd" depending
	on if LFN support is available or not.

	* INSTALL.DJGPP:  Update URL of WATT-32 library.




diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index a82b95d..fad57a9 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -1299,7 +1299,7 @@
      "DJGPP" => {
          inherit_from     => [ asm("x86_asm") ],
          cc               => "gcc",
-        cflags           => "-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall",
+        cflags           => "-I/dev/env/WATT_ROOT/inc -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O2 -Wall",
          sys_id           => "MSDOS",
          lflags           => "-L/dev/env/WATT_ROOT/lib -lwatt",
          bn_ops           => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
diff --git a/INSTALL.DJGPP b/INSTALL.DJGPP
index 1047ec9..23aed6a 100644
--- a/INSTALL.DJGPP
+++ b/INSTALL.DJGPP
@@ -18,7 +18,7 @@
   files to download, see the DJGPP "ZIP PICKER" page at
   "http://www.delorie.com/djgpp/zip-picker.html". You also need to have
   the WATT-32 networking package installed before you try to compile
- OpenSSL. This can be obtained from "http://www.bgnett.no/~giva/".
+ OpenSSL. This can be obtained from "http://www.watt-32.net/".
   The Makefile assumes that the WATT-32 code is in the directory
   specified by the environment variable WATT_ROOT. If you have watt-32
   in directory "watt32" under your main DJGPP directory, specify
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index 5e934ce..ca318cf 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -97,12 +97,6 @@
           ((a)->s6_addr32[2] == htonl(0x0000ffff)))
  # endif

-# ifdef WATT32
-#  define sock_write SockWrite  /* Watt-32 uses same names */
-#  define sock_read  SockRead
-#  define sock_puts  SockPuts
-# endif
-
  static int dgram_write(BIO *h, const char *buf, int num);
  static int dgram_read(BIO *h, char *buf, int size);
  static int dgram_puts(BIO *h, const char *str);
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c
index 1673b32..5cef4f3 100644
--- a/crypto/bio/bss_sock.c
+++ b/crypto/bio/bss_sock.c
@@ -66,7 +66,11 @@
  # include <openssl/bio.h>

  # ifdef WATT32
-#  define sock_write SockWrite  /* Watt-32 uses same names */
+/* Watt-32 uses same names */
+#  undef sock_write
+#  undef sock_read
+#  undef sock_puts
+#  define sock_write SockWrite
  #  define sock_read  SockRead
  #  define sock_puts  SockPuts
  # endif
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index ac07405..7d33a28 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -87,6 +87,9 @@ static int def_load_bio(CONF *conf, BIO *bp, long *eline);
  static int def_dump(const CONF *conf, BIO *bp);
  static int def_is_number(const CONF *conf, char c);
  static int def_to_int(const CONF *conf, char c);
+#ifdef OPENSSL_SYS_MSDOS
+static void dosify_filename(char *filename);
+#endif

  static CONF_METHOD default_method = {
      "OpenSSL default",
@@ -370,6 +373,10 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
              if (!str_copy(conf, psection, &(v->value), start))
                  goto err;

+#ifdef OPENSSL_SYS_MSDOS
+            if (IS_RANDFILE(v->name) || IS_CERT_DIR(v->name))
+                dosify_filename(v->value);
+#endif
              if (strcmp(psection, section) != 0) {
                  if ((tv = _CONF_get_section(conf, psection))
                      == NULL)
@@ -678,3 +685,24 @@ static int def_to_int(const CONF *conf, char c)
  {
      return c - '0';
  }
+
+#ifdef OPENSSL_SYS_MSDOS
+static void dosify_filename(char *filename)
+{
+  if (filename && *filename && !HAS_LFN_SUPPORT(filename))
+  {
+    char *slash;
+    int length;
+    for (length = 0; filename[length]; length++)
+      ;
+    for (slash = filename + length - 1; slash > filename && *slash != '/'; slash--)
+      ;
+
+    /* Leading dot not allowed on plain DOS.  */
+    if (slash[0] == '.')
+      slash[0] = '_';
+    else if (slash[1] == '.')
+      slash[1] = '_';
+  }
+}
+#endif
diff --git a/e_os.h b/e_os.h
index 5ab4c89..9a5f812 100644
--- a/e_os.h
+++ b/e_os.h
@@ -141,6 +141,7 @@ extern "C" {
  #  define writesocket(s,b,n)      send((s),(b),(n),0)
  # elif defined(__DJGPP__)
  #  define WATT32
+#  define WATT32_NO_OLDIES
  #  define get_last_socket_error() errno
  #  define clear_socket_error()    errno=0
  #  define closesocket(s)          close_s(s)
@@ -194,13 +195,33 @@ extern "C" {
  #   include <unistd.h>
  #   include <sys/stat.h>
  #   include <sys/socket.h>
+#   include <sys/un.h>
  #   include <tcp.h>
  #   include <netdb.h>
  #   define _setmode setmode
  #   define _O_TEXT O_TEXT
  #   define _O_BINARY O_BINARY
+#   if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#    define __gnuc_extension__  __extension__
+#   else
+#    define __gnuc_extension__
+#   endif
+#   define FILE_EXISTS(name)      (access((name), R_OK) == 0)
+#   define HAS_LFN_SUPPORT(name)  (pathconf((name), _PC_NAME_MAX) > 12)
+#   define RFILE                                                                        \
+    (__gnuc_extension__                                                                 \
+      ({                                                                                \
+         char *rnd = HAS_LFN_SUPPORT(".rnd") && FILE_EXISTS(".rnd") ? ".rnd" : "_rnd";  \
+         rnd;                                                                           \
+      })                                                                                \
+    )
+#   undef DEVRANDOM_EGD  /*  Neither MS-DOS nor FreeDOS provide 'egd' sockets.  */
  #   undef DEVRANDOM
  #   define DEVRANDOM "/dev/urandom\x24"
+#   define IS_RANDFILE(n)  ((n)[0] == 'R' && (n)[1] == 'A' && (n)[2] == 'N' && (n)[3] == 'D' && \
+                            (n)[4] == 'F' && (n)[5] == 'I' && (n)[6] == 'L' && (n)[7] == 'E')
+#   define IS_CERT_DIR(n)  ((n)[0] == 'c' && (n)[1] == 'e' && (n)[2] == 'r' && (n)[3] == 't' && \
+                            (n)[4] == '_' && (n)[5] == 'd' && (n)[6] == 'i' && (n)[7] == 'r')
  #  endif                        /* __DJGPP__ */

  #  ifndef S_IFDIR
@@ -327,7 +348,9 @@ extern FILE *_imp___iob;
  #  endif
  #  define OPENSSL_CONF  "openssl.cnf"
  #  define NUL_DEV       "nul"
-#  define RFILE         ".rnd"
+#  ifndef RFILE
+#   define RFILE        ".rnd"
+#  endif
  #  ifdef OPENSSL_SYS_WINCE
  #   define DEFAULT_HOME  ""
  #  else

--------------080700080504010008070106
Content-Type: application/x-gzip;
 name="djgpp-openssl-master.patch.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="djgpp-openssl-master.patch.gz"

H4sICJd7ilYCA2RqZ3BwLW9wZW5zc2wtbWFzdGVyLnBhdGNoALUYa3PaSPI7v6KjXAXJSOJp
A+tzLo7BCbcYXEAuySWpKSGNQGchqaTBjjeb++3XMyOEJGOnUpdVFTDq6e7pd/fgeK4LhrHy
GFj1izBwvdU2tpgXBkm92TA2lheYNoJh+dRuxQsc+hWsXmvZP3ZM07Wc467Vh2ajcdLpVAzD
eJp7pVar/eCEV6/AaLb6fb0LtfT31asK8EcZ/PPN9bUCZy/hm4TwxwvWNPYYceNwIwC4/Qms
ZKMqX3snBBeKBl/0PYFtQ/FBAmVl24peMTIc17dWSQnHGNUdelunwW39/fliQWbT6aLuBTYY
g8VwdjWa4mJMhpPB6HwChhtuPGa4sbWhRhR6AaMxGNMWGO8t38ezav/fWfOfOizjndwnxHNK
h13NB9N5Hss/KNL4gEi+twTDv7MYy9MvAxJGZfrXEzIeTydv4G/fuGPQ4sShyffcaxix5Dvy
cfLBOprMF+fjsSmcj8FTeE8DstnodKndN81W26LOiVUMyCKFDMEiTARdT4RcbxdwrufTBFgI
TngX+KHl6JBQCmxNQYqi/Ht0Ddeji9+HMwUia0XBYkinrBmLfqvX7+7uTIf6YexRjOxN3fnP
Korqf3iREXn2DY3NNdv4igkfwy1YfhJCQKnDz1tbtxT58IO4nY12C7fYXRjfeMEKD7Jv+Fle
kDD0LZIsqRvGFO6RD4vvOQc8LkLpMZynEQ3m87EJi7WXgG0FiA3hkmG6IaVImby8yxWexMwg
rP935d1adcXEMP1JHjwWUGYTOXF6QDIKV9YN5QbFvEy2G27XtcUKKtqhg0olqJcAO15MbRbG
98ggiajtuR5X9V5sYgh6cRhsaMDg1oo9a+lLRiImTRi5whrckJCKU+GFYs8VFA5vtxTYYgDF
HD0GXoRS32aIenr6fTEo7fg+YmF96eEnSYizwswzbYyrwxtpmB7TfrtjU9O0rXazZ7vFMH2E
VM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--------------080700080504010008070106--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019