Commit ed85745ba265d3c5acaf4ecca9c5e931f9f36b66
Exists in
master
and in
3 other branches
Merge branch 'develop' of https://github.com/PerryWerneck/lib3270 into develop
Showing
4 changed files
with
78 additions
and
51 deletions
Show diff stats
src/include/internals.h
src/ssl/notify.c
... | ... | @@ -59,14 +59,16 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, |
59 | 59 | |
60 | 60 | printf("\n\nMSG-CODE=%d\n\n",msg->code); |
61 | 61 | |
62 | + const char *body = (msg->body ? msg->body : msg->popup->body); | |
63 | + | |
62 | 64 | if(msg->code) |
63 | 65 | { |
64 | - if(msg->popup->body) | |
66 | + if(body) | |
65 | 67 | { |
66 | 68 | popup = lib3270_popup_clone_printf( |
67 | 69 | msg->popup, |
68 | 70 | _( "%s\nThe SSL error message was \"%s\"(%d)" ), |
69 | - dgettext(GETTEXT_PACKAGE,msg->popup->body), | |
71 | + dgettext(GETTEXT_PACKAGE,body), | |
70 | 72 | ERR_reason_error_string(msg->code), |
71 | 73 | msg->code |
72 | 74 | ); |
... | ... | @@ -87,12 +89,12 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, |
87 | 89 | { |
88 | 90 | lib3270_autoptr(char) windows_error = lib3270_win32_translate_error_code(msg->lasterror); |
89 | 91 | |
90 | - if(msg->popup->body) | |
92 | + if(body) | |
91 | 93 | { |
92 | 94 | popup = lib3270_popup_clone_printf( |
93 | 95 | msg->popup, |
94 | 96 | _( "%s\nThe windows error was \"%s\" (%u)" ), |
95 | - dgettext(GETTEXT_PACKAGE,msg->popup->body), | |
97 | + dgettext(GETTEXT_PACKAGE,body), | |
96 | 98 | windows_error, |
97 | 99 | (unsigned int) msg->lasterror |
98 | 100 | ); |
... | ... | @@ -111,12 +113,12 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, |
111 | 113 | #endif // _WIN32 |
112 | 114 | else if(rc) |
113 | 115 | { |
114 | - if(msg->popup->body) | |
116 | + if(body) | |
115 | 117 | { |
116 | 118 | popup = lib3270_popup_clone_printf( |
117 | 119 | msg->popup, |
118 | 120 | _( "%s\nThe operating system error was \"%s\" (%u)" ), |
119 | - dgettext(GETTEXT_PACKAGE,msg->popup->body), | |
121 | + dgettext(GETTEXT_PACKAGE,body), | |
120 | 122 | strerror(rc), |
121 | 123 | rc |
122 | 124 | ); |
... | ... | @@ -137,8 +139,8 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, |
137 | 139 | popup = lib3270_malloc(sizeof(LIB3270_POPUP)); |
138 | 140 | *popup = *msg->popup; |
139 | 141 | |
140 | - if(msg->popup->body) | |
141 | - popup->body = dgettext(GETTEXT_PACKAGE,msg->popup->body); | |
142 | + if(body) | |
143 | + popup->body = dgettext(GETTEXT_PACKAGE,body); | |
142 | 144 | |
143 | 145 | } |
144 | 146 | ... | ... |
src/ssl/windows/http.c
... | ... | @@ -59,7 +59,7 @@ X509_CRL * get_crl_using_http(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
59 | 59 | }; |
60 | 60 | |
61 | 61 | popup.body = error_message; |
62 | - message->popup = error_message; | |
62 | + message->popup = &popup; | |
63 | 63 | message->code = hSession->ssl.error = 0; |
64 | 64 | trace_ssl( |
65 | 65 | hSession,"Can't get %s: %s\n", | ... | ... |
src/ssl/windows/ldap.c
... | ... | @@ -104,11 +104,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
104 | 104 | |
105 | 105 | if(!base) |
106 | 106 | { |
107 | - message->error = hSession->ssl.error = 0; | |
108 | - message->title = _( "Security error" ); | |
109 | - message->text = _( "No DN of the entry at which to start the search on the URL" ); | |
110 | - message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ); | |
111 | - debug("%s",message->text); | |
107 | + static const LIB3270_POPUP popup = { | |
108 | + .summary = N_( "No DN of the entry at which to start the search on the URL" ), | |
109 | + .body = N_( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ) | |
110 | + }; | |
111 | + | |
112 | + message->code = hSession->ssl.error = 0; | |
113 | + message->popup = &popup; | |
114 | + debug("%s",message->popup->summary); | |
112 | 115 | errno = EINVAL; |
113 | 116 | return NULL; |
114 | 117 | } |
... | ... | @@ -118,11 +121,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
118 | 121 | |
119 | 122 | if(!base) |
120 | 123 | { |
121 | - message->error = hSession->ssl.error = 0; | |
122 | - message->title = _( "Security error" ); | |
123 | - message->text = _( "No LDAP attribute on the URL" ); | |
124 | - message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ); | |
125 | - debug("%s",message->text); | |
124 | + static const LIB3270_POPUP popup = { | |
125 | + .summary = N_( "No LDAP attribute on the URL" ), | |
126 | + .body = N_( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ) | |
127 | + }; | |
128 | + | |
129 | + message->code = hSession->ssl.error = 0; | |
130 | + message->popup = &popup; | |
131 | + debug("%s",message->popup->summary); | |
126 | 132 | errno = EINVAL; |
127 | 133 | return NULL; |
128 | 134 | } |
... | ... | @@ -147,12 +153,15 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
147 | 153 | |
148 | 154 | if(!ld) |
149 | 155 | { |
150 | - message->error = hSession->ssl.error = 0; | |
151 | - message->title = _( "Security error" ); | |
152 | - message->text = _( "Can't initialize LDAP" ); | |
153 | - debug("%s",message->text); | |
156 | + static const LIB3270_POPUP popup = { | |
157 | + .summary = N_( "Can't initialize LDAP" ) | |
158 | + }; | |
159 | + | |
160 | + message->code = hSession->ssl.error = 0; | |
161 | + message->popup = &popup; | |
162 | + | |
163 | + debug("%s",message->popup->summary); | |
154 | 164 | message->lasterror = GetLastError(); |
155 | - message->description = NULL; | |
156 | 165 | errno = EINVAL; |
157 | 166 | return NULL; |
158 | 167 | } |
... | ... | @@ -161,11 +170,13 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
161 | 170 | rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); |
162 | 171 | if(rc != LDAP_SUCCESS) |
163 | 172 | { |
164 | - message->error = hSession->ssl.error = 0; | |
165 | - message->title = _( "Security error" ); | |
166 | - message->text = _( "Can't set LDAP protocol version" ); | |
173 | + static const LIB3270_POPUP popup = { | |
174 | + .summary = N_( "Can't set LDAP protocol version" ) | |
175 | + }; | |
176 | + | |
177 | + message->code = hSession->ssl.error = 0; | |
178 | + message->popup = &popup; | |
167 | 179 | message->lasterror = LdapMapErrorToWin32(rc); |
168 | - message->description = NULL; | |
169 | 180 | |
170 | 181 | debug("%s (rc=%u, lasterror=%d)",ldap_err2string(rc),rc,(unsigned int) message->lasterror); |
171 | 182 | |
... | ... | @@ -176,11 +187,13 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
176 | 187 | rc = ldap_simple_bind_s(ld, NULL, NULL); |
177 | 188 | if(rc != LDAP_SUCCESS) |
178 | 189 | { |
179 | - message->error = hSession->ssl.error = 0; | |
180 | - message->title = _( "Security error" ); | |
181 | - message->text = _( "Can't bind to LDAP server" ); | |
190 | + static const LIB3270_POPUP popup = { | |
191 | + .summary = N_( "Can't bind to LDAP server" ) | |
192 | + }; | |
193 | + | |
194 | + message->code = hSession->ssl.error = 0; | |
195 | + message->popup = &popup; | |
182 | 196 | message->lasterror = LdapMapErrorToWin32(rc); |
183 | - message->description = NULL; | |
184 | 197 | |
185 | 198 | debug("%s (rc=%u, lasterror=%d)",ldap_err2string(rc),rc,(unsigned int) message->lasterror); |
186 | 199 | |
... | ... | @@ -206,11 +219,12 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
206 | 219 | |
207 | 220 | if(rc != LDAP_SUCCESS) |
208 | 221 | { |
209 | - message->error = hSession->ssl.error = 0; | |
210 | - message->title = _( "Security error" ); | |
211 | - message->text = _( "Can't search LDAP server" ); | |
212 | - message->description = ldap_err2string(rc); | |
213 | - lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); | |
222 | + static const LIB3270_POPUP popup = { | |
223 | + .summary = N_( "Can't search LDAP server" ) | |
224 | + }; | |
225 | + message->body = ldap_err2string(rc); | |
226 | + message->popup = &popup; | |
227 | + lib3270_write_log(hSession,"ssl","%s: %s",url, message->body); | |
214 | 228 | return NULL; |
215 | 229 | } |
216 | 230 | |
... | ... | @@ -218,11 +232,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
218 | 232 | char __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_LDAPPTR))) *attr = ldap_first_attribute(ld, results, &ber); |
219 | 233 | if(!attr) |
220 | 234 | { |
221 | - message->error = hSession->ssl.error = 0; | |
222 | - message->title = _( "Security error" ); | |
223 | - message->text = _( "Can't get LDAP attribute" ); | |
224 | - message->description = _("Search did not produce any attributes."); | |
225 | - lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); | |
235 | + static const LIB3270_POPUP popup = { | |
236 | + .summary = N_( "Can't get LDAP attribute" ), | |
237 | + .body = N_("Search did not produce any attributes.") | |
238 | + }; | |
239 | + | |
240 | + message->code = hSession->ssl.error = 0; | |
241 | + message->popup = &popup; | |
242 | + lib3270_write_log(hSession,"ssl","%s: %s",url, message->popup->body); | |
226 | 243 | errno = ENOENT; |
227 | 244 | return NULL; |
228 | 245 | } |
... | ... | @@ -230,11 +247,13 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
230 | 247 | struct berval ** value = ldap_get_values_len(ld, results, attr); |
231 | 248 | if(!value) |
232 | 249 | { |
233 | - message->error = hSession->ssl.error = 0; | |
234 | - message->title = _( "Security error" ); | |
235 | - message->text = _( "Can't get LDAP attribute" ); | |
236 | - message->description = _("Search did not produce any values."); | |
237 | - lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); | |
250 | + static const LIB3270_POPUP popup = { | |
251 | + .summary = N_( "Can't get LDAP attribute" ), | |
252 | + .body = N_("Search did not produce any values.") | |
253 | + }; | |
254 | + message->code = hSession->ssl.error = 0; | |
255 | + message->popup = &popup; | |
256 | + lib3270_write_log(hSession,"ssl","%s: %s",url, message->popup->body); | |
238 | 257 | errno = ENOENT; |
239 | 258 | return NULL; |
240 | 259 | } |
... | ... | @@ -254,10 +273,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons |
254 | 273 | |
255 | 274 | if(!d2i_X509_CRL(&x509_crl, &crl_data, value[0]->bv_len)) |
256 | 275 | { |
257 | - message->error = hSession->ssl.error = ERR_get_error(); | |
258 | - message->title = _( "Security error" ); | |
259 | - message->text = _( "Can't decode certificate revocation list" ); | |
260 | - lib3270_write_log(hSession,"ssl","%s: %s",url, message->text); | |
276 | + static const LIB3270_POPUP popup = { | |
277 | + .summary = N_( "Can't decode certificate revocation list" ) | |
278 | + }; | |
279 | + | |
280 | + message->code = hSession->ssl.error = ERR_get_error(); | |
281 | + message->popup = &popup; | |
282 | + | |
283 | + lib3270_write_log(hSession,"ssl","%s: %s",url, message->popup->summary); | |
261 | 284 | ldap_value_free_len(value); |
262 | 285 | return NULL; |
263 | 286 | } | ... | ... |