openpam_log.c (91094) | openpam_log.c (91097) |
---|---|
1/*- 2 * Copyright (c) 2002 Networks Associates Technologies, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by ThinkSec AS and 6 * NAI Labs, the Security Research Division of Network Associates, Inc. 7 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 8 * DARPA CHATS research program. --- 20 unchanged lines hidden (view full) --- 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $Id$ 35 */ 36 | 1/*- 2 * Copyright (c) 2002 Networks Associates Technologies, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by ThinkSec AS and 6 * NAI Labs, the Security Research Division of Network Associates, Inc. 7 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 8 * DARPA CHATS research program. --- 20 unchanged lines hidden (view full) --- 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $Id$ 35 */ 36 |
37#include <ctype.h> |
|
37#include <stdarg.h> 38#include <stdio.h> 39#include <stdlib.h> 40#include <syslog.h> 41 42#include <security/pam_appl.h> 43 44#include "openpam_impl.h" --- 4 unchanged lines hidden (view full) --- 49 * Log a message through syslog(3) 50 */ 51 52void 53_openpam_log(int level, const char *func, const char *fmt, ...) 54{ 55 va_list ap; 56 char *format; | 38#include <stdarg.h> 39#include <stdio.h> 40#include <stdlib.h> 41#include <syslog.h> 42 43#include <security/pam_appl.h> 44 45#include "openpam_impl.h" --- 4 unchanged lines hidden (view full) --- 50 * Log a message through syslog(3) 51 */ 52 53void 54_openpam_log(int level, const char *func, const char *fmt, ...) 55{ 56 va_list ap; 57 char *format; |
57 int priority; | 58 int len, priority; |
58 59 switch (level) { 60 case PAM_LOG_DEBUG: 61 priority = LOG_DEBUG; 62 break; 63 case PAM_LOG_VERBOSE: 64 priority = LOG_INFO; 65 break; 66 case PAM_LOG_NOTICE: 67 priority = LOG_NOTICE; 68 break; 69 case PAM_LOG_ERROR: 70 priority = LOG_ERR; 71 break; 72 } 73 va_start(ap, fmt); | 59 60 switch (level) { 61 case PAM_LOG_DEBUG: 62 priority = LOG_DEBUG; 63 break; 64 case PAM_LOG_VERBOSE: 65 priority = LOG_INFO; 66 break; 67 case PAM_LOG_NOTICE: 68 priority = LOG_NOTICE; 69 break; 70 case PAM_LOG_ERROR: 71 priority = LOG_ERR; 72 break; 73 } 74 va_start(ap, fmt); |
74 if ((format = malloc(strlen(func) + strlen(fmt) + 8)) != NULL) { 75 sprintf(format, "in %s(): %s", func, fmt); | 75 for (len = strlen(fmt); len > 0 && isspace(fmt[len]); len--) 76 /* nothing */; 77 if ((format = malloc(strlen(func) + len + 16)) != NULL) { 78 sprintf(format, "in %s(): %.*s\n", func, len, fmt); |
76 vsyslog(priority, format, ap); | 79 vsyslog(priority, format, ap); |
80#ifdef DEBUG 81 vfprintf(stderr, format, ap); 82#endif |
|
77 free(format); 78 } else { 79 vsyslog(priority, fmt, ap); 80 } 81 va_end(ap); 82} 83 84#else --- 33 unchanged lines hidden --- | 83 free(format); 84 } else { 85 vsyslog(priority, fmt, ap); 86 } 87 va_end(ap); 88} 89 90#else --- 33 unchanged lines hidden --- |