Print this page
4211 Some syslog facility names and symbols are missing
1762 Syslogd man page: missing reference.


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Milan Jurik. All rights reserved.

  25  */
  26 
  27 /*
  28  *      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
  29  *      All Rights Reserved
  30  */
  31 
  32 /*
  33  * University Copyright- Copyright (c) 1982, 1986, 1988
  34  * The Regents of the University of California
  35  * All Rights Reserved
  36  *
  37  * University Acknowledgment- Portions of this document are derived from
  38  * software developed by the University of California, Berkeley, and its
  39  * contributors.
  40  */
  41 
  42 /*
  43  *  syslogd -- log system messages
  44  *


 138         "warning",      LOG_WARNING,
 139         "notice",       LOG_NOTICE,
 140         "info",         LOG_INFO,
 141         "debug",        LOG_DEBUG,
 142         "none",         NOPRI,
 143         NULL,           -1
 144 };
 145 
 146 static struct code      FacNames[] = {
 147         "kern",         LOG_KERN,
 148         "user",         LOG_USER,
 149         "mail",         LOG_MAIL,
 150         "daemon",       LOG_DAEMON,
 151         "auth",         LOG_AUTH,
 152         "security",     LOG_AUTH,
 153         "mark",         LOG_MARK,
 154         "syslog",       LOG_SYSLOG,
 155         "lpr",          LOG_LPR,
 156         "news",         LOG_NEWS,
 157         "uucp",         LOG_UUCP,




 158         "audit",        LOG_AUDIT,

 159         "cron",         LOG_CRON,
 160         "local0",       LOG_LOCAL0,
 161         "local1",       LOG_LOCAL1,
 162         "local2",       LOG_LOCAL2,
 163         "local3",       LOG_LOCAL3,
 164         "local4",       LOG_LOCAL4,
 165         "local5",       LOG_LOCAL5,
 166         "local6",       LOG_LOCAL6,
 167         "local7",       LOG_LOCAL7,
 168         NULL,           -1
 169 };
 170 
 171 static char             *TypeNames[7] = {
 172         "UNUSED",       "FILE",         "TTY",          "CONSOLE",
 173         "FORW",         "USERS",        "WALL"
 174 };
 175 
 176 /*
 177  * we allocate our own thread stacks so we can create them
 178  * without the MAP_NORESERVE option. We need to be sure


 600 /*
 601  * this thread listens to the local stream log driver for log messages
 602  * generated by this host, formats them, and queues them to the logger
 603  * thread.
 604  */
 605 /*ARGSUSED*/
 606 static void *
 607 sys_poll(void *ap)
 608 {
 609         int nfds;
 610         static int klogerrs = 0;
 611         pthread_t mythreadno;
 612 
 613         if (Debug) {
 614                 mythreadno = pthread_self();
 615         }
 616 
 617         DPRINT1(1, "sys_poll(%u): sys_thread started\n", mythreadno);
 618 
 619         /*
 620          * Try to process as many messages as we can without blocking on poll.
 621          * We count such "initial" messages with sys_init_msg_count and
 622          * enqueue them without the SYNC_FILE flag.  When no more data is
 623          * waiting on the local log device, we set timeout to INFTIM,
 624          * clear sys_init_msg_count, and generate a flush message to sync
 625          * the previously counted initial messages out to disk.
 626          */
 627 
 628         sys_init_msg_count = 0;
 629 
 630         for (;;) {
 631                 errno = 0;
 632                 t_errno = 0;
 633 
 634                 nfds = poll(&Pfd, 1, INFTIM);
 635 
 636                 if (nfds == 0)
 637                         continue;
 638 
 639                 if (nfds < 0) {
 640                         if (errno != EINTR)
 641                                 logerror("poll");
 642                         continue;
 643                 }
 644                 if (Pfd.revents & POLLIN) {
 645                         getkmsg(INFTIM);


 678         struct log_ctl hdr;
 679         char buf[MAXLINE+1];
 680         size_t buflen;
 681         size_t len;
 682         char tmpbuf[MAXLINE+1];
 683         pthread_t mythreadno;
 684 
 685         if (Debug) {
 686                 mythreadno = pthread_self();
 687         }
 688 
 689         dat.maxlen = MAXLINE;
 690         dat.buf = buf;
 691         ctl.maxlen = sizeof (struct log_ctl);
 692         ctl.buf = (caddr_t)&hdr;
 693 
 694         while ((i = getmsg(Pfd.fd, &ctl, &dat, &flags)) == MOREDATA) {
 695                 lastline = &dat.buf[dat.len];
 696                 *lastline = '\0';
 697 
 698                 DPRINT2(5, "sys_poll:(%u): getmsg: dat.len = %d\n",
 699                     mythreadno, dat.len);
 700                 buflen = strlen(buf);
 701                 len = findnl_bkwd(buf, buflen);
 702 
 703                 (void) memcpy(tmpbuf, buf, len);
 704                 tmpbuf[len] = '\0';
 705 
 706                 /*
 707                  * Format sys will enqueue the log message.
 708                  * Set the sync flag if timeout != 0, which
 709                  * means that we're done handling all the
 710                  * initial messages ready during startup.
 711                  */
 712                 if (timeout == 0) {
 713                         formatsys(&hdr, tmpbuf, 0);
 714                         sys_init_msg_count++;
 715                 } else {
 716                         formatsys(&hdr, tmpbuf, 1);
 717                 }
 718                 sys_msg_count++;




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Milan Jurik. All rights reserved.
  25  * Copyright (c) 2013 Gary Mills
  26  */
  27 
  28 /*
  29  *      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
  30  *      All Rights Reserved
  31  */
  32 
  33 /*
  34  * University Copyright- Copyright (c) 1982, 1986, 1988
  35  * The Regents of the University of California
  36  * All Rights Reserved
  37  *
  38  * University Acknowledgment- Portions of this document are derived from
  39  * software developed by the University of California, Berkeley, and its
  40  * contributors.
  41  */
  42 
  43 /*
  44  *  syslogd -- log system messages
  45  *


 139         "warning",      LOG_WARNING,
 140         "notice",       LOG_NOTICE,
 141         "info",         LOG_INFO,
 142         "debug",        LOG_DEBUG,
 143         "none",         NOPRI,
 144         NULL,           -1
 145 };
 146 
 147 static struct code      FacNames[] = {
 148         "kern",         LOG_KERN,
 149         "user",         LOG_USER,
 150         "mail",         LOG_MAIL,
 151         "daemon",       LOG_DAEMON,
 152         "auth",         LOG_AUTH,
 153         "security",     LOG_AUTH,
 154         "mark",         LOG_MARK,
 155         "syslog",       LOG_SYSLOG,
 156         "lpr",          LOG_LPR,
 157         "news",         LOG_NEWS,
 158         "uucp",         LOG_UUCP,
 159         "altcron",      LOG_ALTCRON,
 160         "authpriv",     LOG_AUTHPRIV,
 161         "ftp",          LOG_FTP,
 162         "ntp",          LOG_NTP,
 163         "audit",        LOG_AUDIT,
 164         "console",      LOG_CONSOLE,
 165         "cron",         LOG_CRON,
 166         "local0",       LOG_LOCAL0,
 167         "local1",       LOG_LOCAL1,
 168         "local2",       LOG_LOCAL2,
 169         "local3",       LOG_LOCAL3,
 170         "local4",       LOG_LOCAL4,
 171         "local5",       LOG_LOCAL5,
 172         "local6",       LOG_LOCAL6,
 173         "local7",       LOG_LOCAL7,
 174         NULL,           -1
 175 };
 176 
 177 static char             *TypeNames[7] = {
 178         "UNUSED",       "FILE",         "TTY",          "CONSOLE",
 179         "FORW",         "USERS",        "WALL"
 180 };
 181 
 182 /*
 183  * we allocate our own thread stacks so we can create them
 184  * without the MAP_NORESERVE option. We need to be sure


 606 /*
 607  * this thread listens to the local stream log driver for log messages
 608  * generated by this host, formats them, and queues them to the logger
 609  * thread.
 610  */
 611 /*ARGSUSED*/
 612 static void *
 613 sys_poll(void *ap)
 614 {
 615         int nfds;
 616         static int klogerrs = 0;
 617         pthread_t mythreadno;
 618 
 619         if (Debug) {
 620                 mythreadno = pthread_self();
 621         }
 622 
 623         DPRINT1(1, "sys_poll(%u): sys_thread started\n", mythreadno);
 624 
 625         /*
 626          * Process messages, blocking on poll because timeout is set
 627          * to INFTIM.  When poll returns with a message, call getkmsg
 628          * to pull up one message from the log driver and enqueue it
 629          * with the sync flag set.


 630          */
 631 
 632         sys_init_msg_count = 0;
 633 
 634         for (;;) {
 635                 errno = 0;
 636                 t_errno = 0;
 637 
 638                 nfds = poll(&Pfd, 1, INFTIM);
 639 
 640                 if (nfds == 0)
 641                         continue;
 642 
 643                 if (nfds < 0) {
 644                         if (errno != EINTR)
 645                                 logerror("poll");
 646                         continue;
 647                 }
 648                 if (Pfd.revents & POLLIN) {
 649                         getkmsg(INFTIM);


 682         struct log_ctl hdr;
 683         char buf[MAXLINE+1];
 684         size_t buflen;
 685         size_t len;
 686         char tmpbuf[MAXLINE+1];
 687         pthread_t mythreadno;
 688 
 689         if (Debug) {
 690                 mythreadno = pthread_self();
 691         }
 692 
 693         dat.maxlen = MAXLINE;
 694         dat.buf = buf;
 695         ctl.maxlen = sizeof (struct log_ctl);
 696         ctl.buf = (caddr_t)&hdr;
 697 
 698         while ((i = getmsg(Pfd.fd, &ctl, &dat, &flags)) == MOREDATA) {
 699                 lastline = &dat.buf[dat.len];
 700                 *lastline = '\0';
 701 
 702                 DPRINT2(5, "getkmsg:(%u): getmsg: dat.len = %d\n",
 703                     mythreadno, dat.len);
 704                 buflen = strlen(buf);
 705                 len = findnl_bkwd(buf, buflen);
 706 
 707                 (void) memcpy(tmpbuf, buf, len);
 708                 tmpbuf[len] = '\0';
 709 
 710                 /*
 711                  * Format sys will enqueue the log message.
 712                  * Set the sync flag if timeout != 0, which
 713                  * means that we're done handling all the
 714                  * initial messages ready during startup.
 715                  */
 716                 if (timeout == 0) {
 717                         formatsys(&hdr, tmpbuf, 0);
 718                         sys_init_msg_count++;
 719                 } else {
 720                         formatsys(&hdr, tmpbuf, 1);
 721                 }
 722                 sys_msg_count++;