xsyslog.c revision 1.2.4.2 1 1.2.4.2 pgoyette /* $NetBSD: xsyslog.c,v 1.2.4.2 2017/03/20 06:56:57 pgoyette Exp $ */
2 1.2.4.2 pgoyette
3 1.2.4.2 pgoyette /*
4 1.2.4.2 pgoyette * Copyright (c) 1983, 1988, 1993
5 1.2.4.2 pgoyette * The Regents of the University of California. All rights reserved.
6 1.2.4.2 pgoyette *
7 1.2.4.2 pgoyette * Redistribution and use in source and binary forms, with or without
8 1.2.4.2 pgoyette * modification, are permitted provided that the following conditions
9 1.2.4.2 pgoyette * are met:
10 1.2.4.2 pgoyette * 1. Redistributions of source code must retain the above copyright
11 1.2.4.2 pgoyette * notice, this list of conditions and the following disclaimer.
12 1.2.4.2 pgoyette * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.4.2 pgoyette * notice, this list of conditions and the following disclaimer in the
14 1.2.4.2 pgoyette * documentation and/or other materials provided with the distribution.
15 1.2.4.2 pgoyette * 3. Neither the name of the University nor the names of its contributors
16 1.2.4.2 pgoyette * may be used to endorse or promote products derived from this software
17 1.2.4.2 pgoyette * without specific prior written permission.
18 1.2.4.2 pgoyette *
19 1.2.4.2 pgoyette * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 1.2.4.2 pgoyette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.2.4.2 pgoyette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.2.4.2 pgoyette * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 1.2.4.2 pgoyette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.2.4.2 pgoyette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.2.4.2 pgoyette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.2.4.2 pgoyette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.2.4.2 pgoyette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.2.4.2 pgoyette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.2.4.2 pgoyette * SUCH DAMAGE.
30 1.2.4.2 pgoyette */
31 1.2.4.2 pgoyette
32 1.2.4.2 pgoyette #include <sys/cdefs.h>
33 1.2.4.2 pgoyette #if defined(LIBC_SCCS) && !defined(lint)
34 1.2.4.2 pgoyette #if 0
35 1.2.4.2 pgoyette static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
36 1.2.4.2 pgoyette #else
37 1.2.4.2 pgoyette __RCSID("$NetBSD: xsyslog.c,v 1.2.4.2 2017/03/20 06:56:57 pgoyette Exp $");
38 1.2.4.2 pgoyette #endif
39 1.2.4.2 pgoyette #endif /* LIBC_SCCS and not lint */
40 1.2.4.2 pgoyette
41 1.2.4.2 pgoyette #include "namespace.h"
42 1.2.4.2 pgoyette #include <sys/types.h>
43 1.2.4.2 pgoyette #include <sys/param.h>
44 1.2.4.2 pgoyette #include <sys/socket.h>
45 1.2.4.2 pgoyette #include <sys/syslog.h>
46 1.2.4.2 pgoyette #include <sys/uio.h>
47 1.2.4.2 pgoyette #include <sys/un.h>
48 1.2.4.2 pgoyette
49 1.2.4.2 pgoyette #include <errno.h>
50 1.2.4.2 pgoyette #include <stdio.h>
51 1.2.4.2 pgoyette #include <stdarg.h>
52 1.2.4.2 pgoyette #include <string.h>
53 1.2.4.2 pgoyette #include <fcntl.h>
54 1.2.4.2 pgoyette #include <unistd.h>
55 1.2.4.2 pgoyette #include <stdlib.h>
56 1.2.4.2 pgoyette #include <paths.h>
57 1.2.4.2 pgoyette #include "syslog_private.h"
58 1.2.4.2 pgoyette #include "reentrant.h"
59 1.2.4.2 pgoyette #include "extern.h"
60 1.2.4.2 pgoyette
61 1.2.4.2 pgoyette static void
62 1.2.4.2 pgoyette disconnectlog_r(struct syslog_data *data)
63 1.2.4.2 pgoyette {
64 1.2.4.2 pgoyette /*
65 1.2.4.2 pgoyette * If the user closed the FD and opened another in the same slot,
66 1.2.4.2 pgoyette * that's their problem. They should close it before calling on
67 1.2.4.2 pgoyette * system services.
68 1.2.4.2 pgoyette */
69 1.2.4.2 pgoyette if (data->log_file != -1) {
70 1.2.4.2 pgoyette (void)close(data->log_file);
71 1.2.4.2 pgoyette data->log_file = -1;
72 1.2.4.2 pgoyette }
73 1.2.4.2 pgoyette data->log_connected = 0; /* retry connect */
74 1.2.4.2 pgoyette }
75 1.2.4.2 pgoyette
76 1.2.4.2 pgoyette static void
77 1.2.4.2 pgoyette connectlog_r(struct syslog_data *data)
78 1.2.4.2 pgoyette {
79 1.2.4.2 pgoyette /* AF_UNIX address of local logger */
80 1.2.4.2 pgoyette static const struct sockaddr_un sun = {
81 1.2.4.2 pgoyette .sun_family = AF_LOCAL,
82 1.2.4.2 pgoyette .sun_len = sizeof(sun),
83 1.2.4.2 pgoyette .sun_path = _PATH_LOG,
84 1.2.4.2 pgoyette };
85 1.2.4.2 pgoyette
86 1.2.4.2 pgoyette if (data->log_file == -1 || fcntl(data->log_file, F_GETFL, 0) == -1) {
87 1.2.4.2 pgoyette if ((data->log_file = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC,
88 1.2.4.2 pgoyette 0)) == -1)
89 1.2.4.2 pgoyette return;
90 1.2.4.2 pgoyette data->log_connected = 0;
91 1.2.4.2 pgoyette }
92 1.2.4.2 pgoyette if (!data->log_connected) {
93 1.2.4.2 pgoyette if (connect(data->log_file,
94 1.2.4.2 pgoyette (const struct sockaddr *)(const void *)&sun,
95 1.2.4.2 pgoyette (socklen_t)sizeof(sun)) == -1) {
96 1.2.4.2 pgoyette (void)close(data->log_file);
97 1.2.4.2 pgoyette data->log_file = -1;
98 1.2.4.2 pgoyette } else
99 1.2.4.2 pgoyette data->log_connected = 1;
100 1.2.4.2 pgoyette }
101 1.2.4.2 pgoyette }
102 1.2.4.2 pgoyette
103 1.2.4.2 pgoyette void
104 1.2.4.2 pgoyette _openlog_unlocked_r(const char *ident, int logstat, int logfac,
105 1.2.4.2 pgoyette struct syslog_data *data)
106 1.2.4.2 pgoyette {
107 1.2.4.2 pgoyette if (ident != NULL)
108 1.2.4.2 pgoyette data->log_tag = ident;
109 1.2.4.2 pgoyette data->log_stat = logstat;
110 1.2.4.2 pgoyette if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
111 1.2.4.2 pgoyette data->log_fac = logfac;
112 1.2.4.2 pgoyette
113 1.2.4.2 pgoyette if (data->log_stat & LOG_NDELAY) /* open immediately */
114 1.2.4.2 pgoyette connectlog_r(data);
115 1.2.4.2 pgoyette
116 1.2.4.2 pgoyette data->log_opened = 1;
117 1.2.4.2 pgoyette }
118 1.2.4.2 pgoyette
119 1.2.4.2 pgoyette void
120 1.2.4.2 pgoyette _closelog_unlocked_r(struct syslog_data *data)
121 1.2.4.2 pgoyette {
122 1.2.4.2 pgoyette (void)close(data->log_file);
123 1.2.4.2 pgoyette data->log_file = -1;
124 1.2.4.2 pgoyette data->log_connected = 0;
125 1.2.4.2 pgoyette }
126 1.2.4.2 pgoyette
127 1.2.4.2 pgoyette static void
128 1.2.4.2 pgoyette _xsyslogp_r(int pri, struct syslog_fun *fun,
129 1.2.4.2 pgoyette struct syslog_data *data, const char *msgid,
130 1.2.4.2 pgoyette const char *sdfmt, const char *msgfmt, ...)
131 1.2.4.2 pgoyette {
132 1.2.4.2 pgoyette va_list ap;
133 1.2.4.2 pgoyette va_start(ap, msgfmt);
134 1.2.4.2 pgoyette _vxsyslogp_r(pri, fun, data, msgid, sdfmt, msgfmt, ap);
135 1.2.4.2 pgoyette va_end(ap);
136 1.2.4.2 pgoyette }
137 1.2.4.2 pgoyette
138 1.2.4.2 pgoyette void
139 1.2.4.2 pgoyette _vxsyslogp_r(int pri, struct syslog_fun *fun,
140 1.2.4.2 pgoyette struct syslog_data *data, const char *msgid,
141 1.2.4.2 pgoyette const char *sdfmt, const char *msgfmt, va_list ap)
142 1.2.4.2 pgoyette {
143 1.2.4.2 pgoyette static const char BRCOSP[] = "]: ";
144 1.2.4.2 pgoyette static const char CRLF[] = "\r\n";
145 1.2.4.2 pgoyette size_t cnt, prlen, tries;
146 1.2.4.2 pgoyette char ch, *p, *t;
147 1.2.4.2 pgoyette int fd, saved_errno;
148 1.2.4.2 pgoyette #define TBUF_LEN 2048
149 1.2.4.2 pgoyette #define FMT_LEN 1024
150 1.2.4.2 pgoyette #define MAXTRIES 10
151 1.2.4.2 pgoyette char tbuf[TBUF_LEN], fmt_cpy[FMT_LEN], fmt_cat[FMT_LEN] = "";
152 1.2.4.2 pgoyette size_t tbuf_left, fmt_left, msgsdlen;
153 1.2.4.2 pgoyette char *fmt = fmt_cat;
154 1.2.4.2 pgoyette struct iovec iov[7]; /* prog + [ + pid + ]: + fmt + crlf */
155 1.2.4.2 pgoyette int opened, iovcnt;
156 1.2.4.2 pgoyette
157 1.2.4.2 pgoyette #define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
158 1.2.4.2 pgoyette /* Check for invalid bits. */
159 1.2.4.2 pgoyette if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
160 1.2.4.2 pgoyette _xsyslogp_r(INTERNALLOG, &_syslog_ss_fun, data, NULL, NULL,
161 1.2.4.2 pgoyette "%s: unknown facility/priority: %x", pri);
162 1.2.4.2 pgoyette pri &= LOG_PRIMASK|LOG_FACMASK;
163 1.2.4.2 pgoyette }
164 1.2.4.2 pgoyette
165 1.2.4.2 pgoyette /* Check priority against setlogmask values. */
166 1.2.4.2 pgoyette if (!(LOG_MASK(LOG_PRI(pri)) & data->log_mask))
167 1.2.4.2 pgoyette return;
168 1.2.4.2 pgoyette
169 1.2.4.2 pgoyette saved_errno = errno;
170 1.2.4.2 pgoyette
171 1.2.4.2 pgoyette /* Set default facility if none specified. */
172 1.2.4.2 pgoyette if ((pri & LOG_FACMASK) == 0)
173 1.2.4.2 pgoyette pri |= data->log_fac;
174 1.2.4.2 pgoyette
175 1.2.4.2 pgoyette /* Build the message. */
176 1.2.4.2 pgoyette p = tbuf;
177 1.2.4.2 pgoyette tbuf_left = TBUF_LEN;
178 1.2.4.2 pgoyette
179 1.2.4.2 pgoyette prlen = snprintf_ss(p, tbuf_left, "<%d>1 ", pri);
180 1.2.4.2 pgoyette DEC();
181 1.2.4.2 pgoyette
182 1.2.4.2 pgoyette prlen = (*fun->timefun)(p, tbuf_left);
183 1.2.4.2 pgoyette
184 1.2.4.2 pgoyette (*fun->lock)(data);
185 1.2.4.2 pgoyette
186 1.2.4.2 pgoyette if (data->log_hostname[0] == '\0' && gethostname(data->log_hostname,
187 1.2.4.2 pgoyette sizeof(data->log_hostname)) == -1) {
188 1.2.4.2 pgoyette /* can this really happen? */
189 1.2.4.2 pgoyette data->log_hostname[0] = '-';
190 1.2.4.2 pgoyette data->log_hostname[1] = '\0';
191 1.2.4.2 pgoyette }
192 1.2.4.2 pgoyette
193 1.2.4.2 pgoyette DEC();
194 1.2.4.2 pgoyette prlen = snprintf_ss(p, tbuf_left, " %s ", data->log_hostname);
195 1.2.4.2 pgoyette
196 1.2.4.2 pgoyette if (data->log_tag == NULL)
197 1.2.4.2 pgoyette data->log_tag = getprogname();
198 1.2.4.2 pgoyette
199 1.2.4.2 pgoyette DEC();
200 1.2.4.2 pgoyette prlen = snprintf_ss(p, tbuf_left, "%s ",
201 1.2.4.2 pgoyette data->log_tag ? data->log_tag : "-");
202 1.2.4.2 pgoyette
203 1.2.4.2 pgoyette (*fun->unlock)(data);
204 1.2.4.2 pgoyette
205 1.2.4.2 pgoyette if (data->log_stat & (LOG_PERROR|LOG_CONS)) {
206 1.2.4.2 pgoyette iovcnt = 0;
207 1.2.4.2 pgoyette iov[iovcnt].iov_base = p;
208 1.2.4.2 pgoyette iov[iovcnt].iov_len = prlen - 1;
209 1.2.4.2 pgoyette iovcnt++;
210 1.2.4.2 pgoyette }
211 1.2.4.2 pgoyette DEC();
212 1.2.4.2 pgoyette
213 1.2.4.2 pgoyette if (data->log_stat & LOG_PID) {
214 1.2.4.2 pgoyette prlen = snprintf_ss(p, tbuf_left, "%d ", getpid());
215 1.2.4.2 pgoyette if (data->log_stat & (LOG_PERROR|LOG_CONS)) {
216 1.2.4.2 pgoyette iov[iovcnt].iov_base = __UNCONST("[");
217 1.2.4.2 pgoyette iov[iovcnt].iov_len = 1;
218 1.2.4.2 pgoyette iovcnt++;
219 1.2.4.2 pgoyette iov[iovcnt].iov_base = p;
220 1.2.4.2 pgoyette iov[iovcnt].iov_len = prlen - 1;
221 1.2.4.2 pgoyette iovcnt++;
222 1.2.4.2 pgoyette iov[iovcnt].iov_base = __UNCONST(BRCOSP);
223 1.2.4.2 pgoyette iov[iovcnt].iov_len = 3;
224 1.2.4.2 pgoyette iovcnt++;
225 1.2.4.2 pgoyette }
226 1.2.4.2 pgoyette } else {
227 1.2.4.2 pgoyette prlen = snprintf_ss(p, tbuf_left, "- ");
228 1.2.4.2 pgoyette if (data->log_stat & (LOG_PERROR|LOG_CONS)) {
229 1.2.4.2 pgoyette iov[iovcnt].iov_base = __UNCONST(BRCOSP + 1);
230 1.2.4.2 pgoyette iov[iovcnt].iov_len = 2;
231 1.2.4.2 pgoyette iovcnt++;
232 1.2.4.2 pgoyette }
233 1.2.4.2 pgoyette }
234 1.2.4.2 pgoyette DEC();
235 1.2.4.2 pgoyette
236 1.2.4.2 pgoyette /*
237 1.2.4.2 pgoyette * concat the format strings, then use one vsnprintf()
238 1.2.4.2 pgoyette */
239 1.2.4.2 pgoyette if (msgid != NULL && *msgid != '\0') {
240 1.2.4.2 pgoyette strlcat(fmt_cat, msgid, FMT_LEN);
241 1.2.4.2 pgoyette strlcat(fmt_cat, " ", FMT_LEN);
242 1.2.4.2 pgoyette } else
243 1.2.4.2 pgoyette strlcat(fmt_cat, "- ", FMT_LEN);
244 1.2.4.2 pgoyette
245 1.2.4.2 pgoyette if (sdfmt != NULL && *sdfmt != '\0') {
246 1.2.4.2 pgoyette strlcat(fmt_cat, sdfmt, FMT_LEN);
247 1.2.4.2 pgoyette } else
248 1.2.4.2 pgoyette strlcat(fmt_cat, "-", FMT_LEN);
249 1.2.4.2 pgoyette
250 1.2.4.2 pgoyette if (data->log_stat & (LOG_PERROR|LOG_CONS))
251 1.2.4.2 pgoyette msgsdlen = strlen(fmt_cat) + 1;
252 1.2.4.2 pgoyette else
253 1.2.4.2 pgoyette msgsdlen = 0; /* XXX: GCC */
254 1.2.4.2 pgoyette
255 1.2.4.2 pgoyette if (msgfmt != NULL && *msgfmt != '\0') {
256 1.2.4.2 pgoyette strlcat(fmt_cat, " ", FMT_LEN);
257 1.2.4.2 pgoyette strlcat(fmt_cat, msgfmt, FMT_LEN);
258 1.2.4.2 pgoyette }
259 1.2.4.2 pgoyette
260 1.2.4.2 pgoyette /*
261 1.2.4.2 pgoyette * We wouldn't need this mess if printf handled %m, or if
262 1.2.4.2 pgoyette * strerror() had been invented before syslog().
263 1.2.4.2 pgoyette */
264 1.2.4.2 pgoyette for (t = fmt_cpy, fmt_left = FMT_LEN; (ch = *fmt) != '\0'; ++fmt) {
265 1.2.4.2 pgoyette if (ch == '%' && fmt[1] == 'm') {
266 1.2.4.2 pgoyette char buf[256];
267 1.2.4.2 pgoyette
268 1.2.4.2 pgoyette if ((*fun->errfun)(saved_errno, buf, sizeof(buf)) != 0)
269 1.2.4.2 pgoyette prlen = snprintf_ss(t, fmt_left, "Error %d",
270 1.2.4.2 pgoyette saved_errno);
271 1.2.4.2 pgoyette else
272 1.2.4.2 pgoyette prlen = strlcpy(t, buf, fmt_left);
273 1.2.4.2 pgoyette if (prlen >= fmt_left)
274 1.2.4.2 pgoyette prlen = fmt_left - 1;
275 1.2.4.2 pgoyette t += prlen;
276 1.2.4.2 pgoyette fmt++;
277 1.2.4.2 pgoyette fmt_left -= prlen;
278 1.2.4.2 pgoyette } else if (ch == '%' && fmt[1] == '%' && fmt_left > 2) {
279 1.2.4.2 pgoyette *t++ = '%';
280 1.2.4.2 pgoyette *t++ = '%';
281 1.2.4.2 pgoyette fmt++;
282 1.2.4.2 pgoyette fmt_left -= 2;
283 1.2.4.2 pgoyette } else {
284 1.2.4.2 pgoyette if (fmt_left > 1) {
285 1.2.4.2 pgoyette *t++ = ch;
286 1.2.4.2 pgoyette fmt_left--;
287 1.2.4.2 pgoyette }
288 1.2.4.2 pgoyette }
289 1.2.4.2 pgoyette }
290 1.2.4.2 pgoyette *t = '\0';
291 1.2.4.2 pgoyette
292 1.2.4.2 pgoyette prlen = (*fun->prfun)(p, tbuf_left, fmt_cpy, ap);
293 1.2.4.2 pgoyette if (data->log_stat & (LOG_PERROR|LOG_CONS)) {
294 1.2.4.2 pgoyette iov[iovcnt].iov_base = p + msgsdlen;
295 1.2.4.2 pgoyette iov[iovcnt].iov_len = prlen - msgsdlen;
296 1.2.4.2 pgoyette iovcnt++;
297 1.2.4.2 pgoyette }
298 1.2.4.2 pgoyette
299 1.2.4.2 pgoyette DEC();
300 1.2.4.2 pgoyette cnt = p - tbuf;
301 1.2.4.2 pgoyette
302 1.2.4.2 pgoyette /* Output to stderr if requested. */
303 1.2.4.2 pgoyette if (data->log_stat & LOG_PERROR) {
304 1.2.4.2 pgoyette iov[iovcnt].iov_base = __UNCONST(CRLF + 1);
305 1.2.4.2 pgoyette iov[iovcnt].iov_len = 1;
306 1.2.4.2 pgoyette (void)writev(STDERR_FILENO, iov, iovcnt + 1);
307 1.2.4.2 pgoyette }
308 1.2.4.2 pgoyette
309 1.2.4.2 pgoyette /* Get connected, output the message to the local logger. */
310 1.2.4.2 pgoyette (*fun->lock)(data);
311 1.2.4.2 pgoyette opened = !data->log_opened;
312 1.2.4.2 pgoyette if (opened)
313 1.2.4.2 pgoyette _openlog_unlocked_r(data->log_tag, data->log_stat, 0, data);
314 1.2.4.2 pgoyette connectlog_r(data);
315 1.2.4.2 pgoyette
316 1.2.4.2 pgoyette /*
317 1.2.4.2 pgoyette * If the send() failed, there are two likely scenarios:
318 1.2.4.2 pgoyette * 1) syslogd was restarted
319 1.2.4.2 pgoyette * 2) /dev/log is out of socket buffer space
320 1.2.4.2 pgoyette * We attempt to reconnect to /dev/log to take care of
321 1.2.4.2 pgoyette * case #1 and keep send()ing data to cover case #2
322 1.2.4.2 pgoyette * to give syslogd a chance to empty its socket buffer.
323 1.2.4.2 pgoyette */
324 1.2.4.2 pgoyette for (tries = 0; tries < MAXTRIES; tries++) {
325 1.2.4.2 pgoyette if (send(data->log_file, tbuf, cnt, 0) != -1)
326 1.2.4.2 pgoyette break;
327 1.2.4.2 pgoyette if (errno != ENOBUFS) {
328 1.2.4.2 pgoyette disconnectlog_r(data);
329 1.2.4.2 pgoyette connectlog_r(data);
330 1.2.4.2 pgoyette } else
331 1.2.4.2 pgoyette (void)usleep(1);
332 1.2.4.2 pgoyette }
333 1.2.4.2 pgoyette
334 1.2.4.2 pgoyette /*
335 1.2.4.2 pgoyette * Output the message to the console; try not to block
336 1.2.4.2 pgoyette * as a blocking console should not stop other processes.
337 1.2.4.2 pgoyette * Make sure the error reported is the one from the syslogd failure.
338 1.2.4.2 pgoyette */
339 1.2.4.2 pgoyette if (tries == MAXTRIES && (data->log_stat & LOG_CONS) &&
340 1.2.4.2 pgoyette (fd = open(_PATH_CONSOLE,
341 1.2.4.2 pgoyette O_WRONLY | O_NONBLOCK | O_CLOEXEC, 0)) >= 0) {
342 1.2.4.2 pgoyette iov[iovcnt].iov_base = __UNCONST(CRLF);
343 1.2.4.2 pgoyette iov[iovcnt].iov_len = 2;
344 1.2.4.2 pgoyette (void)writev(fd, iov, iovcnt + 1);
345 1.2.4.2 pgoyette (void)close(fd);
346 1.2.4.2 pgoyette }
347 1.2.4.2 pgoyette
348 1.2.4.2 pgoyette if (!(*fun->unlock)(data) && opened)
349 1.2.4.2 pgoyette _closelog_unlocked_r(data);
350 1.2.4.2 pgoyette }
351 1.2.4.2 pgoyette
352 1.2.4.2 pgoyette int
353 1.2.4.2 pgoyette setlogmask_r(int pmask, struct syslog_data *data)
354 1.2.4.2 pgoyette {
355 1.2.4.2 pgoyette int omask;
356 1.2.4.2 pgoyette
357 1.2.4.2 pgoyette omask = data->log_mask;
358 1.2.4.2 pgoyette if (pmask != 0)
359 1.2.4.2 pgoyette data->log_mask = pmask;
360 1.2.4.2 pgoyette return omask;
361 1.2.4.2 pgoyette }
362