1 /* $NetBSD: log.c,v 1.9 2007/12/20 20:17:52 christos Exp $ */
4 * Copyright (c) 1992 Carnegie Mellon University
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation.
13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
15 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 * Carnegie Mellon requests users of this software to return to
19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
20 * School of Computer Science
21 * Carnegie Mellon University
22 * Pittsburgh PA 15213-3890
24 * any improvements or extensions that they make and grant Carnegie Mellon
25 * the rights to redistribute these changes.
28 * Logging support for SUP
29 **********************************************************************
31 * Revision 1.5 92/08/11 12:03:43 mrt
32 * Brad's delinting and variable argument list usage
33 * changes. Added copyright.
35 * Revision 1.3 89/08/15 15:30:37 bww
36 * Updated to use v*printf() in place of _doprnt().
37 * From "[89/04/19 mja]" at CMU.
40 * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
41 * Added check to allow logopen() to be called multiple times.
43 * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
46 **********************************************************************
50 #include <sys/syslog.h>
52 #include "supextern.h"
55 static int opened
= 0;
58 logopen(char *program
)
62 openlog(program
, LOG_PID
, LOG_DAEMON
);
67 logquit(int retval
, const char *fmt
, ...)
69 char buf
[STRINGLENGTH
];
73 vsnprintf(buf
, sizeof(buf
), fmt
, ap
);
76 syslog(LOG_ERR
, "%s", buf
);
80 quit(retval
, "SUP: %s\n", buf
);
84 logerr(const char *fmt
, ...)
86 char buf
[STRINGLENGTH
];
90 vsnprintf(buf
, sizeof(buf
), fmt
, ap
);
93 syslog(LOG_ERR
, "%s", buf
);
96 fprintf(stderr
, "SUP: %s\n", buf
);
97 (void) fflush(stderr
);
101 loginfo(const char *fmt
, ...)
103 char buf
[STRINGLENGTH
];
107 vsnprintf(buf
, sizeof(buf
), fmt
, ap
);
110 syslog(LOG_INFO
, "%s", buf
);
114 (void) fflush(stdout
);
118 #ifndef LIBWRAP_ALLOW_FACILITY
119 #define LIBWRAP_ALLOW_FACILITY LOG_AUTH
121 #ifndef LIBWRAP_ALLOW_SEVERITY
122 #define LIBWRAP_ALLOW_SEVERITY LOG_INFO
124 #ifndef LIBWRAP_DENY_FACILITY
125 #define LIBWRAP_DENY_FACILITY LOG_AUTH
127 #ifndef LIBWRAP_DENY_SEVERITY
128 #define LIBWRAP_DENY_SEVERITY LOG_WARNING
130 int allow_severity
= LIBWRAP_ALLOW_FACILITY
| LIBWRAP_ALLOW_SEVERITY
;
131 int deny_severity
= LIBWRAP_DENY_FACILITY
| LIBWRAP_DENY_SEVERITY
;
134 logdeny(const char *fmt
, ...)
136 char buf
[STRINGLENGTH
];
140 vsnprintf(buf
, sizeof(buf
), fmt
, ap
);
143 syslog(deny_severity
, "%s", buf
);
147 (void) fflush(stdout
);
151 logallow(const char *fmt
, ...)
153 char buf
[STRINGLENGTH
];
157 vsnprintf(buf
, sizeof(buf
), fmt
, ap
);
160 syslog(allow_severity
, "%s", buf
);
164 (void) fflush(stdout
);