Deleted Added
full compact
syslog.c (50476) syslog.c (55837)
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35/*
36static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
37*/
38static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35/*
36static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
37*/
38static const char rcsid[] =
39 "$FreeBSD: head/lib/libc/gen/syslog.c 50476 1999-08-28 00:22:10Z peter $";
39 "$FreeBSD: head/lib/libc/gen/syslog.c 55837 2000-01-12 09:23:48Z jasone $";
40#endif /* LIBC_SCCS and not lint */
41
42#include <sys/types.h>
43#include <sys/socket.h>
44#include <sys/syslog.h>
45#include <sys/uio.h>
46#include <sys/un.h>
47#include <netdb.h>

--- 207 unchanged lines hidden (view full) ---

255 return;
256
257 /*
258 * Output the message to the console; don't worry about blocking,
259 * if console blocks everything will. Make sure the error reported
260 * is the one from the syslogd failure.
261 */
262 if (LogStat & LOG_CONS &&
40#endif /* LIBC_SCCS and not lint */
41
42#include <sys/types.h>
43#include <sys/socket.h>
44#include <sys/syslog.h>
45#include <sys/uio.h>
46#include <sys/un.h>
47#include <netdb.h>

--- 207 unchanged lines hidden (view full) ---

255 return;
256
257 /*
258 * Output the message to the console; don't worry about blocking,
259 * if console blocks everything will. Make sure the error reported
260 * is the one from the syslogd failure.
261 */
262 if (LogStat & LOG_CONS &&
263 (fd = open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
263 (fd = _libc_open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
264 struct iovec iov[2];
265 register struct iovec *v = iov;
266
267 p = strchr(tbuf, '>') + 1;
268 v->iov_base = p;
269 v->iov_len = cnt - (p - tbuf);
270 ++v;
271 v->iov_base = "\r\n";
272 v->iov_len = 2;
273 (void)writev(fd, iov, 2);
264 struct iovec iov[2];
265 register struct iovec *v = iov;
266
267 p = strchr(tbuf, '>') + 1;
268 v->iov_base = p;
269 v->iov_len = cnt - (p - tbuf);
270 ++v;
271 v->iov_base = "\r\n";
272 v->iov_len = 2;
273 (void)writev(fd, iov, 2);
274 (void)close(fd);
274 (void)_libc_close(fd);
275 }
276}
277static void
278disconnectlog()
279{
280 /*
281 * If the user closed the FD and opened another in the same slot,
282 * that's their problem. They should close it before calling on
283 * system services.
284 */
285 if (LogFile != -1) {
275 }
276}
277static void
278disconnectlog()
279{
280 /*
281 * If the user closed the FD and opened another in the same slot,
282 * that's their problem. They should close it before calling on
283 * system services.
284 */
285 if (LogFile != -1) {
286 close(LogFile);
286 _libc_close(LogFile);
287 LogFile = -1;
288 }
289 connected = 0; /* retry connect */
290}
291
292static void
293connectlog()
294{
295 struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */
296
297 if (LogFile == -1) {
298 if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
299 return;
287 LogFile = -1;
288 }
289 connected = 0; /* retry connect */
290}
291
292static void
293connectlog()
294{
295 struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */
296
297 if (LogFile == -1) {
298 if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
299 return;
300 (void)fcntl(LogFile, F_SETFD, 1);
300 (void)_libc_fcntl(LogFile, F_SETFD, 1);
301 }
302 if (LogFile != -1 && !connected) {
303 SyslogAddr.sun_len = sizeof(SyslogAddr);
304 SyslogAddr.sun_family = AF_UNIX;
305 (void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
306 sizeof SyslogAddr.sun_path);
307 connected = connect(LogFile, (struct sockaddr *)&SyslogAddr,
308 sizeof(SyslogAddr)) != -1;

--- 6 unchanged lines hidden (view full) ---

315 (void)strncpy(SyslogAddr.sun_path, _PATH_OLDLOG,
316 sizeof SyslogAddr.sun_path);
317 connected = connect(LogFile,
318 (struct sockaddr *)&SyslogAddr,
319 sizeof(SyslogAddr)) != -1;
320 }
321
322 if (!connected) {
301 }
302 if (LogFile != -1 && !connected) {
303 SyslogAddr.sun_len = sizeof(SyslogAddr);
304 SyslogAddr.sun_family = AF_UNIX;
305 (void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
306 sizeof SyslogAddr.sun_path);
307 connected = connect(LogFile, (struct sockaddr *)&SyslogAddr,
308 sizeof(SyslogAddr)) != -1;

--- 6 unchanged lines hidden (view full) ---

315 (void)strncpy(SyslogAddr.sun_path, _PATH_OLDLOG,
316 sizeof SyslogAddr.sun_path);
317 connected = connect(LogFile,
318 (struct sockaddr *)&SyslogAddr,
319 sizeof(SyslogAddr)) != -1;
320 }
321
322 if (!connected) {
323 (void)close(LogFile);
323 (void)_libc_close(LogFile);
324 LogFile = -1;
325 }
326 }
327}
328
329void
330openlog(ident, logstat, logfac)
331 const char *ident;

--- 9 unchanged lines hidden (view full) ---

341 connectlog();
342
343 opened = 1; /* ident and facility has been set */
344}
345
346void
347closelog()
348{
324 LogFile = -1;
325 }
326 }
327}
328
329void
330openlog(ident, logstat, logfac)
331 const char *ident;

--- 9 unchanged lines hidden (view full) ---

341 connectlog();
342
343 opened = 1; /* ident and facility has been set */
344}
345
346void
347closelog()
348{
349 (void)close(LogFile);
349 (void)_libc_close(LogFile);
350 LogFile = -1;
351 connected = 0;
352}
353
354/* setlogmask -- set the log mask level */
355int
356setlogmask(pmask)
357 int pmask;
358{
359 int omask;
360
361 omask = LogMask;
362 if (pmask != 0)
363 LogMask = pmask;
364 return (omask);
365}
350 LogFile = -1;
351 connected = 0;
352}
353
354/* setlogmask -- set the log mask level */
355int
356setlogmask(pmask)
357 int pmask;
358{
359 int omask;
360
361 omask = LogMask;
362 if (pmask != 0)
363 LogMask = pmask;
364 return (omask);
365}