Commit a43ac115efcfbd0c350107de1bf4ebf0305c77d6

Authored by Perry Werneck
Committed by GitHub
2 parents c7a2159a 60431e48
Exists in master and in 1 other branch develop

Merge pull request #34 from PerryWerneck/develop

Updating to latest code.
@@ -182,7 +182,7 @@ Using jhbuild @@ -182,7 +182,7 @@ Using jhbuild
182 2. build 182 2. build
183 183
184 ```shell 184 ```shell
185 - jhbuild --moduleset=https://raw.githubusercontent.com/PerryWerneck/lib3270/macos/mac/lib3270.modules build lib3270 185 + jhbuild --moduleset=https://raw.githubusercontent.com/PerryWerneck/lib3270/master/mac/lib3270.modules build lib3270
186 ``` 186 ```
187 187
188 188
@@ -9,7 +9,7 @@ url="https://github.com/PerryWerneck/lib3270" @@ -9,7 +9,7 @@ url="https://github.com/PerryWerneck/lib3270"
9 arch=(i686 x86_64) 9 arch=(i686 x86_64)
10 license=(GPL) 10 license=(GPL)
11 depends=() 11 depends=()
12 -makedepends=(autoconf automake make openssl libtool) 12 +makedepends=(autoconf automake make openssl libtool gzip)
13 checkdepends=() 13 checkdepends=()
14 14
15 #groups=(gnome) 15 #groups=(gnome)
@@ -143,6 +143,9 @@ case "$host" in @@ -143,6 +143,9 @@ case "$host" in
143 143
144 app_cv_static='no' 144 app_cv_static='no'
145 145
  146 + AC_CONFIG_FILES(debian/control)
  147 + AC_CONFIG_FILES(debian/shlibs)
  148 +
146 esac 149 esac
147 150
148 AC_SUBST(OSNAME,$app_cv_osname) 151 AC_SUBST(OSNAME,$app_cv_osname)
@@ -388,6 +391,8 @@ dnl --------------------------------------------------------------------------- @@ -388,6 +391,8 @@ dnl ---------------------------------------------------------------------------
388 dnl SSL Security options 391 dnl SSL Security options
389 dnl --------------------------------------------------------------------------- 392 dnl ---------------------------------------------------------------------------
390 393
  394 +AC_CHECK_HEADER(openssl/fips.h, AC_DEFINE(HAVE_FIPS_H, 1, [FIPS Header is available]), AC_MSG_NOTICE(fips.h is not available))
  395 +
391 AC_ARG_ENABLE([self-signed-cert-check], 396 AC_ARG_ENABLE([self-signed-cert-check],
392 [AS_HELP_STRING([--enable-self-signed-cert-check], [Emit Warning when host presents a self signed certificate])], 397 [AS_HELP_STRING([--enable-self-signed-cert-check], [Emit Warning when host presents a self signed certificate])],
393 [ 398 [
debian/control
@@ -8,7 +8,7 @@ Package: lib3270 @@ -8,7 +8,7 @@ Package: lib3270
8 Architecture: any 8 Architecture: any
9 Section: libs 9 Section: libs
10 Depends: ${misc:Depends}, ${shlibs:Depends} 10 Depends: ${misc:Depends}, ${shlibs:Depends}
11 -Provides: lib3270 (= ${binary:Version}) 11 +Provides: lib3270 (= ${binary:Version}), lib3270 (= 5.4)
12 Description: TN3270 Access library. 12 Description: TN3270 Access library.
13 TN3270 access library originally designed as part of the pw3270 application. 13 TN3270 access library originally designed as part of the pw3270 application.
14 14
debian/control.in 0 → 100644
@@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
  1 +Source: lib3270
  2 +Section: unknown
  3 +Priority: optional
  4 +Maintainer: Perry Werneck <perry.werneck@gmail.com>
  5 +Build-Depends: debhelper (>= 7), autotools-dev, autoconf, automake, pkg-config, gettext, libssl-dev, libcurl4-openssl-dev
  6 +
  7 +Package: lib3270
  8 +Architecture: any
  9 +Section: libs
  10 +Depends: ${misc:Depends}, ${shlibs:Depends}
  11 +Provides: lib3270 (= ${binary:Version}), @PACKAGE_NAME@ (= @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@)
  12 +Description: TN3270 Access library.
  13 + TN3270 access library originally designed as part of the pw3270 application.
  14 +
  15 +Package: lib3270-dev
  16 +Architecture: any
  17 +Provides: lib3270-dev (= ${binary:Version})
  18 +Section: libdevel
  19 +Depends: ${misc:Depends}, pkg-config, lib3270 (= ${binary:Version})
  20 +Description: TN3270 Access library development files.
  21 + TN3270 access library originally designed as part of the pw3270 application.
  22 +
  23 +Package: lib3270-dbg
  24 +Architecture: any
  25 +Depends: lib3270 (= ${binary:Version})
  26 +Description: Debugging symbols for lib3270
  27 + This package contains the debugging symbols for lib3270.
  28 +
debian/shlibs.in 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +lib3270 @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ lib3270 (>= @PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@)
  2 +
  3 +
@@ -31,11 +31,11 @@ @@ -31,11 +31,11 @@
31 <param name="files">*/debian/*.dsc</param> 31 <param name="files">*/debian/*.dsc</param>
32 </service> 32 </service>
33 33
34 - <service name="extract_file"> 34 + <!-- service name="extract_file">
35 <param name="archive">*.tar</param> 35 <param name="archive">*.tar</param>
36 <param name="files">*/debian/control</param> 36 <param name="files">*/debian/control</param>
37 <param name="outfilename">debian.control</param> 37 <param name="outfilename">debian.control</param>
38 - </service> 38 + </service -->
39 39
40 <!-- service name="extract_file"> 40 <!-- service name="extract_file">
41 <param name="archive">*.tar</param> 41 <param name="archive">*.tar</param>
src/core/connect.c
@@ -134,6 +134,9 @@ void lib3270_notify_tls(H3270 *hSession) { @@ -134,6 +134,9 @@ void lib3270_notify_tls(H3270 *hSession) {
134 } 134 }
135 135
136 int lib3270_start_tls(H3270 *hSession) { 136 int lib3270_start_tls(H3270 *hSession) {
  137 +
  138 + debug("%s",__FUNCTION__);
  139 +
137 hSession->ssl.message = NULL; // Reset message. 140 hSession->ssl.message = NULL; // Reset message.
138 set_ssl_state(hSession,LIB3270_SSL_NEGOTIATING); 141 set_ssl_state(hSession,LIB3270_SSL_NEGOTIATING);
139 142
src/core/host.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 /* 3 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes. 4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 * 5 *
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA 6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
20 * 10 *
21 - * Este programa está nomeado como host.c e possui 1078 linhas de código. 11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
22 * 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18 + */
  19 +
  20 +/*
23 * Contatos: 21 * Contatos:
24 * 22 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 23 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) 24 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)  
30 * 25 *
31 */ 26 */
32 27
33 -  
34 /** 28 /**
35 * @brief Handle connect and disconnect from hosts, and state changes on the host connection. 29 * @brief Handle connect and disconnect from hosts, and state changes on the host connection.
36 */ 30 */
@@ -306,7 +300,7 @@ LIB3270_EXPORT const char * lib3270_get_url(const H3270 *hSession) { @@ -306,7 +300,7 @@ LIB3270_EXPORT const char * lib3270_get_url(const H3270 *hSession) {
306 LIB3270_EXPORT const char * lib3270_get_default_host(const H3270 GNUC_UNUSED(*hSession)) { 300 LIB3270_EXPORT const char * lib3270_get_default_host(const H3270 GNUC_UNUSED(*hSession)) {
307 #ifdef _WIN32 301 #ifdef _WIN32
308 { 302 {
309 - lib3270_auto_cleanup(HKEY) hKey; 303 + lib3270_auto_cleanup(HKEY) hKey = 0;
310 DWORD disp = 0; 304 DWORD disp = 0;
311 LSTATUS rc = RegCreateKeyEx( 305 LSTATUS rc = RegCreateKeyEx(
312 HKEY_LOCAL_MACHINE, 306 HKEY_LOCAL_MACHINE,
src/core/init.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 /* 3 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes. 4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 * 5 *
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA 6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
20 * 10 *
21 - * Este programa está nomeado como - e possui - linhas de código. 11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
22 * 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18 + */
  19 +
  20 +/*
23 * Contatos: 21 * Contatos:
24 * 22 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 23 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
@@ -27,7 +25,6 @@ @@ -27,7 +25,6 @@
27 * 25 *
28 */ 26 */
29 27
30 -  
31 /** 28 /**
32 * @brief Init/Deinit lib3270 internals. 29 * @brief Init/Deinit lib3270 internals.
33 */ 30 */
src/core/linkedlist.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 /* 3 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes. 4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 * 5 *
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA 6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
20 * 10 *
21 - * Este programa está nomeado como linkedlist.c e possui - linhas de código. 11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
22 * 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18 + */
  19 +
  20 +/*
23 * Contatos: 21 * Contatos:
24 * 22 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 23 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
@@ -27,7 +25,6 @@ @@ -27,7 +25,6 @@
27 * 25 *
28 */ 26 */
29 27
30 -  
31 /** 28 /**
32 * @brief Handle linked lists. 29 * @brief Handle linked lists.
33 */ 30 */
@@ -36,6 +33,7 @@ @@ -36,6 +33,7 @@
36 #include <lib3270/log.h> 33 #include <lib3270/log.h>
37 #include <linkedlist.h> 34 #include <linkedlist.h>
38 #include <string.h> 35 #include <string.h>
  36 +#include <errno.h>
39 37
40 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ 38 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
41 39
src/core/session.c
@@ -17,6 +17,14 @@ @@ -17,6 +17,14 @@
17 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */ 18 */
19 19
  20 +/*
  21 + * Contatos:
  22 + *
  23 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  24 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  25 + *
  26 + */
  27 +
20 #ifndef ANDROID 28 #ifndef ANDROID
21 #include <stdlib.h> 29 #include <stdlib.h>
22 #endif // !ANDROID 30 #endif // !ANDROID
@@ -99,7 +107,7 @@ void lib3270_session_free(H3270 *h) { @@ -99,7 +107,7 @@ void lib3270_session_free(H3270 *h) {
99 107
100 108
101 // Release memory 109 // Release memory
102 -#define release_pointer(x) lib3270_free(x); x = NULL; 110 + #define release_pointer(x) lib3270_free(x); x = NULL;
103 111
104 // release_pointer(h->charset.display); 112 // release_pointer(h->charset.display);
105 release_pointer(h->paste_buffer); 113 release_pointer(h->paste_buffer);
@@ -151,43 +159,6 @@ static int default_action(H3270 GNUC_UNUSED(*hSession), const char GNUC_UNUSED(* @@ -151,43 +159,6 @@ static int default_action(H3270 GNUC_UNUSED(*hSession), const char GNUC_UNUSED(*
151 return errno = ENOENT; 159 return errno = ENOENT;
152 } 160 }
153 161
154 -  
155 -/*  
156 -static void update_char(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(addr), unsigned char GNUC_UNUSED(chr), unsigned short GNUC_UNUSED(attr), unsigned char GNUC_UNUSED(cursor)) {  
157 -}  
158 -  
159 -static void update_model(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name), int GNUC_UNUSED(model), int GNUC_UNUSED(rows), int GNUC_UNUSED(cols)) {  
160 -}  
161 -  
162 -static void changed(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(bstart), int GNUC_UNUSED(bend)) {  
163 -}  
164 -  
165 -static void update_cursor(H3270 GNUC_UNUSED(*session), unsigned short GNUC_UNUSED(row), unsigned short GNUC_UNUSED(col), unsigned char GNUC_UNUSED(c), unsigned short GNUC_UNUSED(attr)) {  
166 -}  
167 -  
168 -static void update_oia(H3270 GNUC_UNUSED(*session), LIB3270_FLAG GNUC_UNUSED(id), unsigned char GNUC_UNUSED(on)) {  
169 -}  
170 -  
171 -static void update_selection(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(start), int GNUC_UNUSED(end)) {  
172 -}  
173 -  
174 -static void set_cursor(H3270 GNUC_UNUSED(*session), LIB3270_POINTER GNUC_UNUSED(id)) {  
175 -}  
176 -  
177 -static void update_ssl(H3270 GNUC_UNUSED(*session), LIB3270_SSL_STATE GNUC_UNUSED(state)) {  
178 -}  
179 -  
180 -static void set_timer(H3270 GNUC_UNUSED(*session), unsigned char GNUC_UNUSED(on)) {  
181 -}  
182 -  
183 -static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name)) {  
184 -}  
185 -  
186 -static void default_update_url(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*url)) {  
187 -}  
188 -  
189 -*/  
190 -  
191 static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) { 162 static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) {
192 lib3270_write_log(session, "print", "%s", "Printing is unavailable"); 163 lib3270_write_log(session, "print", "%s", "Printing is unavailable");
193 lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't print" ), _( "Unable to print" ), "%s", strerror(ENOTSUP)); 164 lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't print" ), _( "Unable to print" ), "%s", strerror(ENOTSUP));
src/core/windows/registry.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 /* 3 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob  
5 - * o nome G3270.  
6 - *  
7 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
8 - *  
9 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
10 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
11 - * Free Software Foundation.  
12 - *  
13 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
14 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
15 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
16 - * obter mais detalhes. 4 + * Copyright (C) 2008 Banco do Brasil S.A.
17 * 5 *
18 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
19 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
20 - * St, Fifth Floor, Boston, MA 02110-1301 USA 6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
21 * 10 *
22 - * Este programa está nomeado como - e possui - linhas de código. 11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
23 * 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18 + */
  19 +
  20 +/*
24 * Contatos: 21 * Contatos:
25 * 22 *
26 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 23 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
src/include/config.h.in
@@ -70,6 +70,7 @@ @@ -70,6 +70,7 @@
70 /* Security options */ 70 /* Security options */
71 #undef HAVE_LDAP 71 #undef HAVE_LDAP
72 #undef HAVE_LIBSSL 72 #undef HAVE_LIBSSL
  73 + #undef HAVE_FIPS_H
73 74
74 #undef SSL_ENABLE_SELF_SIGNED_CERT_CHECK 75 #undef SSL_ENABLE_SELF_SIGNED_CERT_CHECK
75 76
src/include/windows/lib3270/win32.h
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 /* 3 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes. 4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 * 5 *
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA 6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
20 * 10 *
21 - * Este programa está nomeado como lib3270.h e possui - linhas de código. 11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
22 * 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18 + */
  19 +
  20 +/*
23 * Contatos: 21 * Contatos:
24 * 22 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 23 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
@@ -28,7 +26,7 @@ @@ -28,7 +26,7 @@
28 */ 26 */
29 27
30 /** 28 /**
31 - * @brief TN3270 API windows definitions. 29 + * @brief TN3270 WIN32 API definitions.
32 * 30 *
33 * @author perry.werneck@gmail.com 31 * @author perry.werneck@gmail.com
34 * 32 *
src/network_modules/openssl/context.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 /* 3 /*
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes. 4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 * 5 *
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA 6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
20 * 10 *
21 - * Este programa está nomeado como - e possui - linhas de código. 11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
22 * 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18 + */
  19 +
  20 +/*
23 * Contatos: 21 * Contatos:
24 * 22 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 23 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) 24 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 * 25 *
28 - *  
29 * References: 26 * References:
30 * 27 *
31 * http://www.openssl.org/docs/ssl/ 28 * http://www.openssl.org/docs/ssl/
@@ -37,15 +34,22 @@ @@ -37,15 +34,22 @@
37 * @brief OpenSSL initialization for linux. 34 * @brief OpenSSL initialization for linux.
38 */ 35 */
39 36
40 -#include "private.h"  
41 - 37 +#include <config.h>
42 #ifdef _WIN32 38 #ifdef _WIN32
43 -#include <lib3270/win32.h> 39 + #include <winsock2.h>
  40 + #include <windows.h>
  41 + #include <lib3270/win32.h>
44 #endif // _WIN32 42 #endif // _WIN32
45 43
  44 +#include "private.h"
  45 +
46 #include <openssl/err.h> 46 #include <openssl/err.h>
47 #include <openssl/x509_vfy.h> 47 #include <openssl/x509_vfy.h>
48 48
  49 +#ifdef HAVE_FIPS_H
  50 + #include <openssl/fips.h>
  51 +#endif // HAVE_FIPS_H
  52 +
49 #ifndef SSL_ST_OK 53 #ifndef SSL_ST_OK
50 #define SSL_ST_OK 3 54 #define SSL_ST_OK 3
51 #endif // !SSL_ST_OK 55 #endif // !SSL_ST_OK
@@ -151,9 +155,81 @@ SSL_CTX * lib3270_openssl_get_context(H3270 *hSession) { @@ -151,9 +155,81 @@ SSL_CTX * lib3270_openssl_get_context(H3270 *hSession) {
151 if(context) 155 if(context)
152 return context; 156 return context;
153 157
154 - trace_ssl(hSession,"Initializing SSL context.\n");  
155 -  
156 SSL_load_error_strings(); 158 SSL_load_error_strings();
  159 +
  160 +#if !defined(OPENSSL_FIPS)
  161 +
  162 + lib3270_write_log(
  163 + hSession,
  164 + "openssl",
  165 + "Initializing %s\n",
  166 + SSLeay_version(SSLEAY_VERSION)
  167 + );
  168 +
  169 +#elif defined(_WIN32)
  170 + {
  171 + lib3270_auto_cleanup(HKEY) hKey = 0;
  172 + DWORD disp = 0;
  173 + LSTATUS rc = RegCreateKeyEx(
  174 + HKEY_LOCAL_MACHINE,
  175 + "Software\\" LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME) "\\tweaks",
  176 + 0,
  177 + NULL,
  178 + REG_OPTION_NON_VOLATILE,
  179 + KEY_QUERY_VALUE|KEY_READ,
  180 + NULL,
  181 + &hKey,
  182 + &disp);
  183 +
  184 + if(rc == ERROR_SUCCESS) {
  185 + DWORD mode = lib3270_win32_get_dword(hKey, "fips_mode", FIPS_mode());
  186 + if(FIPS_mode_set(mode) != 1) {
  187 +
  188 + SSL_load_error_strings();
  189 +
  190 + char err_buff[1024];
  191 + memset(err_buff,0,sizeof(err_buff));
  192 + (void) ERR_error_string_n(ERR_get_error(), err_buff, 1023);
  193 +
  194 + lib3270_write_log(
  195 + hSession,
  196 + "openssl",
  197 + "Cant set FIPS mode to %u: %s\n",
  198 + (unsigned int) mode,
  199 + err_buff
  200 + );
  201 +
  202 + } else {
  203 + lib3270_write_log(
  204 + hSession,
  205 + "openssl",
  206 + "FIPS mode set to %u\n",
  207 + (unsigned int) mode
  208 + );
  209 + }
  210 + }
  211 +
  212 + lib3270_write_log(
  213 + hSession,
  214 + "openssl",
  215 + "Initializing windows %s using fips mode %u.\n",
  216 + SSLeay_version(SSLEAY_VERSION),
  217 + FIPS_mode()
  218 + );
  219 +
  220 + }
  221 +#else
  222 +
  223 + lib3270_write_log(
  224 + hSession,
  225 + "openssl",
  226 + "Initializing %s %s FIPS.\n",
  227 + SSLeay_version(SSLEAY_VERSION),
  228 + (FIPS_mode() ? "with" : "without" )
  229 + );
  230 +
  231 +#endif
  232 +
157 SSL_library_init(); 233 SSL_library_init();
158 234
159 context = SSL_CTX_new(SSLv23_method()); 235 context = SSL_CTX_new(SSLv23_method());
src/network_modules/openssl/main.c
@@ -264,6 +264,8 @@ static char * openssl_network_getcrl(const H3270 *hSession) { @@ -264,6 +264,8 @@ static char * openssl_network_getcrl(const H3270 *hSession) {
264 264
265 static int openssl_network_init(H3270 *hSession) { 265 static int openssl_network_init(H3270 *hSession) {
266 266
  267 + debug("%s",__FUNCTION__);
  268 +
267 set_ssl_state(hSession,LIB3270_SSL_UNDEFINED); 269 set_ssl_state(hSession,LIB3270_SSL_UNDEFINED);
268 270
269 SSL_CTX * ctx_context = (SSL_CTX *) lib3270_openssl_get_context(hSession); 271 SSL_CTX * ctx_context = (SSL_CTX *) lib3270_openssl_get_context(hSession);
@@ -349,7 +351,12 @@ void lib3270_set_libssl_network_module(H3270 *hSession) { @@ -349,7 +351,12 @@ void lib3270_set_libssl_network_module(H3270 *hSession) {
349 .reset = openssl_network_reset 351 .reset = openssl_network_reset
350 }; 352 };
351 353
352 - debug("%s",__FUNCTION__); 354 + if(hSession->network.module == &module) {
  355 + debug("%s - Network module is already set",__FUNCTION__);
  356 + return;
  357 + }
  358 +
  359 + debug("%s - Setting network module",__FUNCTION__);
353 360
354 if(hSession->network.context) { 361 if(hSession->network.context) {
355 // Has context, finalize it. 362 // Has context, finalize it.
src/testprogram/testprogram.c
@@ -41,9 +41,14 @@ @@ -41,9 +41,14 @@
41 #include <lib3270/log.h> 41 #include <lib3270/log.h>
42 #include <lib3270/properties.h> 42 #include <lib3270/properties.h>
43 #include <lib3270/charset.h> 43 #include <lib3270/charset.h>
  44 +#include <stdio.h>
  45 +
  46 +#ifdef HAVE_FIPS_H
  47 + #include <openssl/fips.h>
  48 +#endif // HAVE_FIPS_H
44 49
45 #ifdef _WIN32 50 #ifdef _WIN32
46 -#include <lib3270/win32.h> 51 + #include <lib3270/win32.h>
47 #endif // _WIN32 52 #endif // _WIN32
48 53
49 #define MAX_ARGS 10 54 #define MAX_ARGS 10