1 /* $NetBSD: xsasl_cyrus_log.c,v 1.1.1.1 2009/06/23 10:09:02 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* xsasl_cyrus_log 3 6 /* SUMMARY 7 /* Cyrus SASL logging call-back routine 8 /* SYNOPSIS 9 /* #include <xsasl_cyrus_common.h> 10 /* 11 /* int xsasl_cyrus_log(context, priority, text) 12 /* void *context; 13 /* int priority; 14 /* const char *text; 15 /* DESCRIPTION 16 /* xsasl_cyrus_log() logs a Cyrus message. 17 /* DIAGNOSTICS: 18 /* Fatal: out of memory. 19 /* LICENSE 20 /* .ad 21 /* .fi 22 /* The Secure Mailer license must be distributed with this software. 23 /* AUTHOR(S) 24 /* Wietse Venema 25 /* IBM T.J. Watson Research 26 /* P.O. Box 704 27 /* Yorktown Heights, NY 10598, USA 28 /*--*/ 29 30 /* System library. */ 31 32 #include <sys_defs.h> 33 34 /* Utility library. */ 35 36 #include <msg.h> 37 38 /* Application-specific */ 39 40 #include <xsasl_cyrus_common.h> 41 42 #if defined(USE_SASL_AUTH) && defined(USE_CYRUS_SASL) 43 44 #include <sasl.h> 45 #include <saslutil.h> 46 47 /* xsasl_cyrus_log - logging callback */ 48 49 int xsasl_cyrus_log(void *unused_context, int priority, 50 const char *message) 51 { 52 switch (priority) { 53 case SASL_LOG_ERR: /* unusual errors */ 54 #ifdef SASL_LOG_WARN /* non-fatal warnings (Cyrus-SASL v2) */ 55 case SASL_LOG_WARN: 56 #endif 57 #ifdef SASL_LOG_WARNING /* non-fatal warnings (Cyrus-SASL v1) */ 58 case SASL_LOG_WARNING: 59 #endif 60 msg_warn("SASL authentication problem: %s", message); 61 break; 62 #ifdef SASL_LOG_INFO 63 case SASL_LOG_INFO: /* other info (Cyrus-SASL v1) */ 64 if (msg_verbose) 65 msg_info("SASL authentication info: %s", message); 66 break; 67 #endif 68 #ifdef SASL_LOG_NOTE 69 case SASL_LOG_NOTE: /* other info (Cyrus-SASL v2) */ 70 if (msg_verbose) 71 msg_info("SASL authentication info: %s", message); 72 break; 73 #endif 74 #ifdef SASL_LOG_FAIL 75 case SASL_LOG_FAIL: /* authentication failures 76 * (Cyrus-SASL v2) */ 77 msg_warn("SASL authentication failure: %s", message); 78 break; 79 #endif 80 #ifdef SASL_LOG_DEBUG 81 case SASL_LOG_DEBUG: /* more verbose than LOG_NOTE 82 * (Cyrus-SASL v2) */ 83 if (msg_verbose > 1) 84 msg_info("SASL authentication debug: %s", message); 85 break; 86 #endif 87 #ifdef SASL_LOG_TRACE 88 case SASL_LOG_TRACE: /* traces of internal 89 * protocols (Cyrus-SASL v2) */ 90 if (msg_verbose > 1) 91 msg_info("SASL authentication trace: %s", message); 92 break; 93 #endif 94 #ifdef SASL_LOG_PASS 95 case SASL_LOG_PASS: /* traces of internal 96 * protocols, including 97 * passwords (Cyrus-SASL v2) */ 98 if (msg_verbose > 1) 99 msg_info("SASL authentication pass: %s", message); 100 break; 101 #endif 102 } 103 return (SASL_OK); 104 } 105 106 #endif 107