summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio/bss_log.c
diff options
context:
space:
mode:
authortedu <>2014-04-16 19:42:24 +0000
committertedu <>2014-04-16 19:42:24 +0000
commit5fb0ca0ddf59f49b49200128095fb2d4a1577020 (patch)
tree83bea3615bf607b22ec4199424903c29c83f04d4 /src/lib/libcrypto/bio/bss_log.c
parent980353a54aa762841b1a8478c04a6c39759520b3 (diff)
downloadopenbsd-5fb0ca0ddf59f49b49200128095fb2d4a1577020.tar.gz
openbsd-5fb0ca0ddf59f49b49200128095fb2d4a1577020.tar.bz2
openbsd-5fb0ca0ddf59f49b49200128095fb2d4a1577020.zip
> As I walk through the valley of the shadow of death
> I take a look at my life and realize there's nothin' left > Cause I've been blasting and laughing so long, > That even my mama thinks that my mind is gone Remove even more unspeakable evil being perpetuated in the name of VMS. (and lesser evils done in the name of others.) ok miod
Diffstat (limited to 'src/lib/libcrypto/bio/bss_log.c')
-rw-r--r--src/lib/libcrypto/bio/bss_log.c199
1 files changed, 1 insertions, 198 deletions
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 9225af4df2..5a79f72673 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -68,59 +68,13 @@
68 68
69#include "cryptlib.h" 69#include "cryptlib.h"
70 70
71#if defined(OPENSSL_SYS_WINCE) 71#include <syslog.h>
72#elif defined(OPENSSL_SYS_WIN32)
73#elif defined(OPENSSL_SYS_VMS)
74# include <opcdef.h>
75# include <descrip.h>
76# include <lib$routines.h>
77# include <starlet.h>
78/* Some compiler options may mask the declaration of "_malloc32". */
79# if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
80# if __INITIAL_POINTER_SIZE == 64
81# pragma pointer_size save
82# pragma pointer_size 32
83void * _malloc32 (__size_t);
84# pragma pointer_size restore
85# endif /* __INITIAL_POINTER_SIZE == 64 */
86# endif /* __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE */
87#elif defined(__ultrix)
88# include <sys/syslog.h>
89#elif defined(OPENSSL_SYS_NETWARE)
90# define NO_SYSLOG
91#elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG)
92# include <syslog.h>
93#endif
94 72
95#include <openssl/buffer.h> 73#include <openssl/buffer.h>
96#include <openssl/err.h> 74#include <openssl/err.h>
97 75
98#ifndef NO_SYSLOG 76#ifndef NO_SYSLOG
99 77
100#if defined(OPENSSL_SYS_WIN32)
101#define LOG_EMERG 0
102#define LOG_ALERT 1
103#define LOG_CRIT 2
104#define LOG_ERR 3
105#define LOG_WARNING 4
106#define LOG_NOTICE 5
107#define LOG_INFO 6
108#define LOG_DEBUG 7
109
110#define LOG_DAEMON (3<<3)
111#elif defined(OPENSSL_SYS_VMS)
112/* On VMS, we don't really care about these, but we need them to compile */
113#define LOG_EMERG 0
114#define LOG_ALERT 1
115#define LOG_CRIT 2
116#define LOG_ERR 3
117#define LOG_WARNING 4
118#define LOG_NOTICE 5
119#define LOG_INFO 6
120#define LOG_DEBUG 7
121
122#define LOG_DAEMON OPC$M_NM_NTWORK
123#endif
124 78
125static int slg_write(BIO *h, const char *buf, int num); 79static int slg_write(BIO *h, const char *buf, int num);
126static int slg_puts(BIO *h, const char *str); 80static int slg_puts(BIO *h, const char *str);
@@ -245,161 +199,11 @@ slg_puts(BIO *bp, const char *str)
245 return (ret); 199 return (ret);
246} 200}
247 201
248#if defined(OPENSSL_SYS_WIN32)
249
250static void
251xopenlog(BIO* bp, char* name, int level)
252{
253 if (check_winnt())
254 bp->ptr = RegisterEventSourceA(NULL, name);
255 else
256 bp->ptr = NULL;
257}
258
259static void
260xsyslog(BIO *bp, int priority, const char *string)
261{
262 LPCSTR lpszStrings[2];
263 WORD evtype = EVENTLOG_ERROR_TYPE;
264 char pidbuf[DECIMAL_SIZE(DWORD) + 4];
265
266 if (bp->ptr == NULL)
267 return;
268
269 switch (priority) {
270 case LOG_EMERG:
271 case LOG_ALERT:
272 case LOG_CRIT:
273 case LOG_ERR:
274 evtype = EVENTLOG_ERROR_TYPE;
275 break;
276 case LOG_WARNING:
277 evtype = EVENTLOG_WARNING_TYPE;
278 break;
279 case LOG_NOTICE:
280 case LOG_INFO:
281 case LOG_DEBUG:
282 evtype = EVENTLOG_INFORMATION_TYPE;
283 break;
284 default: /* Should never happen, but set it
285 as error anyway. */
286 evtype = EVENTLOG_ERROR_TYPE;
287 break;
288 }
289
290 sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
291 lpszStrings[0] = pidbuf;
292 lpszStrings[1] = string;
293
294 ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
295 lpszStrings, NULL);
296}
297
298static void
299xcloselog(BIO* bp)
300{
301 if (bp->ptr)
302 DeregisterEventSource((HANDLE)(bp->ptr));
303 bp->ptr = NULL;
304}
305
306#elif defined(OPENSSL_SYS_VMS)
307
308static int VMS_OPC_target = LOG_DAEMON;
309
310static void
311xopenlog(BIO* bp, char* name, int level)
312{
313 VMS_OPC_target = level;
314
315}
316
317static void
318xsyslog(BIO *bp, int priority, const char *string)
319{
320 struct dsc$descriptor_s opc_dsc;
321
322/* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */
323#if __INITIAL_POINTER_SIZE == 64
324# pragma pointer_size save
325# pragma pointer_size 32
326# define OPCDEF_TYPE __char_ptr32
327# define OPCDEF_MALLOC _malloc32
328#else /* __INITIAL_POINTER_SIZE == 64 */
329# define OPCDEF_TYPE char *
330# define OPCDEF_MALLOC OPENSSL_malloc
331#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
332
333 struct opcdef *opcdef_p;
334
335#if __INITIAL_POINTER_SIZE == 64
336# pragma pointer_size restore
337#endif /* __INITIAL_POINTER_SIZE == 64 */
338
339 char buf[10240];
340 unsigned int len;
341 struct dsc$descriptor_s buf_dsc;
342 $DESCRIPTOR(fao_cmd, "!AZ: !AZ");
343 char *priority_tag;
344
345 switch (priority) {
346 case LOG_EMERG:
347 priority_tag = "Emergency"; break;
348 case LOG_ALERT:
349 priority_tag = "Alert"; break;
350 case LOG_CRIT:
351 priority_tag = "Critical"; break;
352 case LOG_ERR:
353 priority_tag = "Error"; break;
354 case LOG_WARNING:
355 priority_tag = "Warning"; break;
356 case LOG_NOTICE:
357 priority_tag = "Notice"; break;
358 case LOG_INFO:
359 priority_tag = "Info"; break;
360 case LOG_DEBUG:
361 priority_tag = "DEBUG"; break;
362 }
363
364 buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
365 buf_dsc.dsc$b_class = DSC$K_CLASS_S;
366 buf_dsc.dsc$a_pointer = buf;
367 buf_dsc.dsc$w_length = sizeof(buf) - 1;
368
369 lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
370
371 /* We know there's an 8-byte header. That's documented. */
372 opcdef_p = OPCDEF_MALLOC( 8 + len);
373 opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
374 memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
375 opcdef_p->opc$l_ms_rqstid = 0;
376 memcpy(&opcdef_p->opc$l_ms_text, buf, len);
377
378 opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
379 opc_dsc.dsc$b_class = DSC$K_CLASS_S;
380 opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p;
381 opc_dsc.dsc$w_length = len + 8;
382
383 sys$sndopr(opc_dsc, 0);
384
385 OPENSSL_free(opcdef_p);
386}
387
388static void
389xcloselog(BIO* bp)
390{
391}
392
393#else /* Unix/Watt32 */
394 202
395static void 203static void
396xopenlog(BIO* bp, char* name, int level) 204xopenlog(BIO* bp, char* name, int level)
397{ 205{
398#ifdef WATT32 /* djgpp/DOS */
399 openlog(name, LOG_PID|LOG_CONS|LOG_NDELAY, level);
400#else
401 openlog(name, LOG_PID|LOG_CONS, level); 206 openlog(name, LOG_PID|LOG_CONS, level);
402#endif
403} 207}
404 208
405static void 209static void
@@ -414,6 +218,5 @@ xcloselog(BIO* bp)
414 closelog(); 218 closelog();
415} 219}
416 220
417#endif /* Unix */
418 221
419#endif /* NO_SYSLOG */ 222#endif /* NO_SYSLOG */