| 
									
										
										
										
											2016-05-18 02:52:22 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2018-01-19 17:49:22 +08:00
										 |  |  |  * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-12-06 20:20:10 +08:00
										 |  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 02:52:22 +08:00
										 |  |  |  * this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  |  * in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  |  * https://www.openssl.org/source/license.html
 | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |  * Why BIO_s_log? | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * BIO_s_log is useful for system daemons (or services under NT). It is | 
					
						
							|  |  |  |  * one-way BIO, it sends all stuff to syslogd (on system that commonly use | 
					
						
							|  |  |  |  * that), or event log (on NT), or OPCOM (on OpenVMS). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											1999-03-03 10:01:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <errno.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-28 06:45:40 +08:00
										 |  |  | #include "bio_local.h"
 | 
					
						
							| 
									
										
										
										
											2015-05-14 22:56:48 +08:00
										 |  |  | #include "internal/cryptlib.h"
 | 
					
						
							| 
									
										
										
										
											2001-02-20 16:13:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-16 06:37:18 +08:00
										 |  |  | #if defined(OPENSSL_SYS_WINCE)
 | 
					
						
							|  |  |  | #elif defined(OPENSSL_SYS_WIN32)
 | 
					
						
							| 
									
										
										
										
											2001-02-20 16:13:47 +08:00
										 |  |  | #elif defined(OPENSSL_SYS_VMS)
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # include <opcdef.h>
 | 
					
						
							|  |  |  | # include <descrip.h>
 | 
					
						
							|  |  |  | # include <lib$routines.h>
 | 
					
						
							|  |  |  | # include <starlet.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-19 18:58:14 +08:00
										 |  |  | /* Some compiler options may mask the declaration of "_malloc32". */ | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
 | 
					
						
							|  |  |  | #  if __INITIAL_POINTER_SIZE == 64
 | 
					
						
							|  |  |  | #   pragma pointer_size save
 | 
					
						
							|  |  |  | #   pragma pointer_size 32
 | 
					
						
							|  |  |  | void *_malloc32(__size_t); | 
					
						
							|  |  |  | #   pragma pointer_size restore
 | 
					
						
							|  |  |  | #  endif                        /* __INITIAL_POINTER_SIZE == 64 */
 | 
					
						
							|  |  |  | # endif                         /* __INITIAL_POINTER_SIZE && defined
 | 
					
						
							|  |  |  |                                  * _ANSI_C_SOURCE */ | 
					
						
							| 
									
										
										
										
											2018-03-21 18:19:49 +08:00
										 |  |  | #elif defined(__DJGPP__) && defined(OPENSSL_NO_SOCK)
 | 
					
						
							|  |  |  | # define NO_SYSLOG
 | 
					
						
							| 
									
										
										
										
											2014-08-09 20:02:20 +08:00
										 |  |  | #elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG)
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # include <syslog.h>
 | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-04-24 06:13:45 +08:00
										 |  |  | #include <openssl/buffer.h>
 | 
					
						
							|  |  |  | #include <openssl/err.h>
 | 
					
						
							| 
									
										
										
										
											2000-03-11 01:01:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-03-09 02:41:15 +08:00
										 |  |  | #ifndef NO_SYSLOG
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # if defined(OPENSSL_SYS_WIN32)
 | 
					
						
							|  |  |  | #  define LOG_EMERG       0
 | 
					
						
							|  |  |  | #  define LOG_ALERT       1
 | 
					
						
							|  |  |  | #  define LOG_CRIT        2
 | 
					
						
							|  |  |  | #  define LOG_ERR         3
 | 
					
						
							|  |  |  | #  define LOG_WARNING     4
 | 
					
						
							|  |  |  | #  define LOG_NOTICE      5
 | 
					
						
							|  |  |  | #  define LOG_INFO        6
 | 
					
						
							|  |  |  | #  define LOG_DEBUG       7
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #  define LOG_DAEMON      (3<<3)
 | 
					
						
							|  |  |  | # elif defined(OPENSSL_SYS_VMS)
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | /* On VMS, we don't really care about these, but we need them to compile */ | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | #  define LOG_EMERG       0
 | 
					
						
							|  |  |  | #  define LOG_ALERT       1
 | 
					
						
							|  |  |  | #  define LOG_CRIT        2
 | 
					
						
							|  |  |  | #  define LOG_ERR         3
 | 
					
						
							|  |  |  | #  define LOG_WARNING     4
 | 
					
						
							|  |  |  | #  define LOG_NOTICE      5
 | 
					
						
							|  |  |  | #  define LOG_INFO        6
 | 
					
						
							|  |  |  | #  define LOG_DEBUG       7
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #  define LOG_DAEMON      OPC$M_NM_NTWORK
 | 
					
						
							|  |  |  | # endif
 | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 06:29:26 +08:00
										 |  |  | static int slg_write(BIO *h, const char *buf, int num); | 
					
						
							|  |  |  | static int slg_puts(BIO *h, const char *str); | 
					
						
							|  |  |  | static long slg_ctrl(BIO *h, int cmd, long arg1, void *arg2); | 
					
						
							|  |  |  | static int slg_new(BIO *h); | 
					
						
							|  |  |  | static int slg_free(BIO *data); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static void xopenlog(BIO *bp, char *name, int level); | 
					
						
							|  |  |  | static void xsyslog(BIO *bp, int priority, const char *string); | 
					
						
							|  |  |  | static void xcloselog(BIO *bp); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-20 00:32:14 +08:00
										 |  |  | static const BIO_METHOD methods_slg = { | 
					
						
							| 
									
										
										
										
											2017-12-08 15:20:10 +08:00
										 |  |  |     BIO_TYPE_MEM, | 
					
						
							|  |  |  |     "syslog", | 
					
						
							| 
									
										
										
										
											2016-10-20 22:18:39 +08:00
										 |  |  |     /* TODO: Convert to new style write function */ | 
					
						
							|  |  |  |     bwrite_conv, | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     slg_write, | 
					
						
							| 
									
										
										
										
											2017-12-18 05:04:48 +08:00
										 |  |  |     NULL,                      /* slg_write_old,    */ | 
					
						
							|  |  |  |     NULL,                      /* slg_read,         */ | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     slg_puts, | 
					
						
							|  |  |  |     NULL, | 
					
						
							|  |  |  |     slg_ctrl, | 
					
						
							|  |  |  |     slg_new, | 
					
						
							|  |  |  |     slg_free, | 
					
						
							| 
									
										
										
										
											2017-12-18 05:04:48 +08:00
										 |  |  |     NULL,                      /* slg_callback_ctrl */ | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-20 00:32:14 +08:00
										 |  |  | const BIO_METHOD *BIO_s_log(void) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return &methods_slg; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 06:29:26 +08:00
										 |  |  | static int slg_new(BIO *bi) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     bi->init = 1; | 
					
						
							|  |  |  |     bi->num = 0; | 
					
						
							|  |  |  |     bi->ptr = NULL; | 
					
						
							|  |  |  |     xopenlog(bi, "application", LOG_DAEMON); | 
					
						
							| 
									
										
										
										
											2017-10-09 19:05:58 +08:00
										 |  |  |     return 1; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 06:29:26 +08:00
										 |  |  | static int slg_free(BIO *a) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     if (a == NULL) | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     xcloselog(a); | 
					
						
							| 
									
										
										
										
											2017-10-09 19:05:58 +08:00
										 |  |  |     return 1; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 06:29:26 +08:00
										 |  |  | static int slg_write(BIO *b, const char *in, int inl) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     int ret = inl; | 
					
						
							|  |  |  |     char *buf; | 
					
						
							|  |  |  |     char *pp; | 
					
						
							|  |  |  |     int priority, i; | 
					
						
							|  |  |  |     static const struct { | 
					
						
							|  |  |  |         int strl; | 
					
						
							|  |  |  |         char str[10]; | 
					
						
							|  |  |  |         int log_level; | 
					
						
							|  |  |  |     } mapping[] = { | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             6, "PANIC ", LOG_EMERG | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             6, "EMERG ", LOG_EMERG | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "EMR ", LOG_EMERG | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             6, "ALERT ", LOG_ALERT | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "ALR ", LOG_ALERT | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             5, "CRIT ", LOG_CRIT | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "CRI ", LOG_CRIT | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             6, "ERROR ", LOG_ERR | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "ERR ", LOG_ERR | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             8, "WARNING ", LOG_WARNING | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             5, "WARN ", LOG_WARNING | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "WAR ", LOG_WARNING | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             7, "NOTICE ", LOG_NOTICE | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             5, "NOTE ", LOG_NOTICE | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "NOT ", LOG_NOTICE | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             5, "INFO ", LOG_INFO | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "INF ", LOG_INFO | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             6, "DEBUG ", LOG_DEBUG | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             4, "DBG ", LOG_DEBUG | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             0, "", LOG_ERR | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         /* The default */ | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 03:28:14 +08:00
										 |  |  |     if ((buf = OPENSSL_malloc(inl + 1)) == NULL) { | 
					
						
							| 
									
										
										
										
											2018-04-27 00:06:17 +08:00
										 |  |  |         BIOerr(BIO_F_SLG_WRITE, ERR_R_MALLOC_FAILURE); | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-06-24 04:17:19 +08:00
										 |  |  |     memcpy(buf, in, inl); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     buf[inl] = '\0'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     i = 0; | 
					
						
							|  |  |  |     while (strncmp(buf, mapping[i].str, mapping[i].strl) != 0) | 
					
						
							|  |  |  |         i++; | 
					
						
							|  |  |  |     priority = mapping[i].log_level; | 
					
						
							|  |  |  |     pp = buf + mapping[i].strl; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     xsyslog(b, priority, pp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     OPENSSL_free(buf); | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 06:29:26 +08:00
										 |  |  | static long slg_ctrl(BIO *b, int cmd, long num, void *ptr) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     switch (cmd) { | 
					
						
							|  |  |  |     case BIO_CTRL_SET: | 
					
						
							|  |  |  |         xcloselog(b); | 
					
						
							|  |  |  |         xopenlog(b, ptr, num); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-13 06:29:26 +08:00
										 |  |  | static int slg_puts(BIO *bp, const char *str) | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     int n, ret; | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     n = strlen(str); | 
					
						
							|  |  |  |     ret = slg_write(bp, str, n); | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # if defined(OPENSSL_SYS_WIN32)
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static void xopenlog(BIO *bp, char *name, int level) | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     if (check_winnt()) | 
					
						
							|  |  |  |         bp->ptr = RegisterEventSourceA(NULL, name); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         bp->ptr = NULL; | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | static void xsyslog(BIO *bp, int priority, const char *string) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     LPCSTR lpszStrings[2]; | 
					
						
							|  |  |  |     WORD evtype = EVENTLOG_ERROR_TYPE; | 
					
						
							|  |  |  |     char pidbuf[DECIMAL_SIZE(DWORD) + 4]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (bp->ptr == NULL) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     switch (priority) { | 
					
						
							|  |  |  |     case LOG_EMERG: | 
					
						
							|  |  |  |     case LOG_ALERT: | 
					
						
							|  |  |  |     case LOG_CRIT: | 
					
						
							|  |  |  |     case LOG_ERR: | 
					
						
							|  |  |  |         evtype = EVENTLOG_ERROR_TYPE; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_WARNING: | 
					
						
							|  |  |  |         evtype = EVENTLOG_WARNING_TYPE; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_NOTICE: | 
					
						
							|  |  |  |     case LOG_INFO: | 
					
						
							|  |  |  |     case LOG_DEBUG: | 
					
						
							|  |  |  |         evtype = EVENTLOG_INFORMATION_TYPE; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         /*
 | 
					
						
							|  |  |  |          * Should never happen, but set it | 
					
						
							|  |  |  |          * as error anyway. | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         evtype = EVENTLOG_ERROR_TYPE; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-30 16:28:14 +08:00
										 |  |  |     sprintf(pidbuf, "[%lu] ", GetCurrentProcessId()); | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     lpszStrings[0] = pidbuf; | 
					
						
							|  |  |  |     lpszStrings[1] = string; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ReportEventA(bp->ptr, evtype, 0, 1024, NULL, 2, 0, lpszStrings, NULL); | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void xcloselog(BIO *bp) | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     if (bp->ptr) | 
					
						
							|  |  |  |         DeregisterEventSource((HANDLE) (bp->ptr)); | 
					
						
							|  |  |  |     bp->ptr = NULL; | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # elif defined(OPENSSL_SYS_VMS)
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-03-17 18:02:16 +08:00
										 |  |  | static int VMS_OPC_target = LOG_DAEMON; | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static void xopenlog(BIO *bp, char *name, int level) | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     VMS_OPC_target = level; | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-03-14 12:16:10 +08:00
										 |  |  | static void xsyslog(BIO *bp, int priority, const char *string) | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     struct dsc$descriptor_s opc_dsc; | 
					
						
							| 
									
										
										
										
											2011-03-19 18:58:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */ | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | #  if __INITIAL_POINTER_SIZE == 64
 | 
					
						
							|  |  |  | #   pragma pointer_size save
 | 
					
						
							|  |  |  | #   pragma pointer_size 32
 | 
					
						
							|  |  |  | #   define OPCDEF_TYPE __char_ptr32
 | 
					
						
							|  |  |  | #   define OPCDEF_MALLOC _malloc32
 | 
					
						
							|  |  |  | #  else                         /* __INITIAL_POINTER_SIZE == 64 */
 | 
					
						
							|  |  |  | #   define OPCDEF_TYPE char *
 | 
					
						
							|  |  |  | #   define OPCDEF_MALLOC OPENSSL_malloc
 | 
					
						
							|  |  |  | #  endif                        /* __INITIAL_POINTER_SIZE == 64 [else] */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct opcdef *opcdef_p; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #  if __INITIAL_POINTER_SIZE == 64
 | 
					
						
							|  |  |  | #   pragma pointer_size restore
 | 
					
						
							|  |  |  | #  endif                        /* __INITIAL_POINTER_SIZE == 64 */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     char buf[10240]; | 
					
						
							|  |  |  |     unsigned int len; | 
					
						
							|  |  |  |     struct dsc$descriptor_s buf_dsc; | 
					
						
							|  |  |  |     $DESCRIPTOR(fao_cmd, "!AZ: !AZ"); | 
					
						
							|  |  |  |     char *priority_tag; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     switch (priority) { | 
					
						
							|  |  |  |     case LOG_EMERG: | 
					
						
							|  |  |  |         priority_tag = "Emergency"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_ALERT: | 
					
						
							|  |  |  |         priority_tag = "Alert"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_CRIT: | 
					
						
							|  |  |  |         priority_tag = "Critical"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_ERR: | 
					
						
							|  |  |  |         priority_tag = "Error"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_WARNING: | 
					
						
							|  |  |  |         priority_tag = "Warning"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_NOTICE: | 
					
						
							|  |  |  |         priority_tag = "Notice"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_INFO: | 
					
						
							|  |  |  |         priority_tag = "Info"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case LOG_DEBUG: | 
					
						
							|  |  |  |         priority_tag = "DEBUG"; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | 
					
						
							|  |  |  |     buf_dsc.dsc$b_class = DSC$K_CLASS_S; | 
					
						
							|  |  |  |     buf_dsc.dsc$a_pointer = buf; | 
					
						
							|  |  |  |     buf_dsc.dsc$w_length = sizeof(buf) - 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* We know there's an 8-byte header.  That's documented. */ | 
					
						
							|  |  |  |     opcdef_p = OPCDEF_MALLOC(8 + len); | 
					
						
							|  |  |  |     opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; | 
					
						
							|  |  |  |     memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); | 
					
						
							|  |  |  |     opcdef_p->opc$l_ms_rqstid = 0; | 
					
						
							|  |  |  |     memcpy(&opcdef_p->opc$l_ms_text, buf, len); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | 
					
						
							|  |  |  |     opc_dsc.dsc$b_class = DSC$K_CLASS_S; | 
					
						
							|  |  |  |     opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p; | 
					
						
							|  |  |  |     opc_dsc.dsc$w_length = len + 8; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     sys$sndopr(opc_dsc, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     OPENSSL_free(opcdef_p); | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static void xcloselog(BIO *bp) | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # else                          /* Unix/Watt32 */
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static void xopenlog(BIO *bp, char *name, int level) | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | #  ifdef WATT32                 /* djgpp/DOS */
 | 
					
						
							|  |  |  |     openlog(name, LOG_PID | LOG_CONS | LOG_NDELAY, level); | 
					
						
							|  |  |  | #  else
 | 
					
						
							|  |  |  |     openlog(name, LOG_PID | LOG_CONS, level); | 
					
						
							|  |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void xsyslog(BIO *bp, int priority, const char *string) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     syslog(priority, "%s", string); | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | static void xcloselog(BIO *bp) | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  |     closelog(); | 
					
						
							| 
									
										
										
										
											1999-02-23 05:21:08 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | # endif                         /* Unix */
 | 
					
						
							| 
									
										
										
										
											2000-03-02 15:45:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-30 07:59:11 +08:00
										 |  |  | #else                           /* NO_SYSLOG */
 | 
					
						
							|  |  |  | const BIO_METHOD *BIO_s_log(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-01-22 11:40:55 +08:00
										 |  |  | #endif                          /* NO_SYSLOG */
 |