home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2646 / ultrix.syslogd.patches < prev   
Encoding:
Text File  |  1991-02-01  |  25.7 KB  |  1,089 lines

  1. *** pristine-syslogd.c    Thu Jan 31 11:58:58 1991
  2. --- syslogd.c    Thu Jan 31 13:29:47 1991
  3. ***************
  4. *** 24,30 ****
  5.   #endif /* not lint */
  6.   
  7.   #ifndef lint
  8. ! static char sccsid[] = "@(#)syslogd.c    5.42 (Berkeley) 6/29/90";
  9.   #endif /* not lint */
  10.   
  11.   /*
  12. --- 24,30 ----
  13.   #endif /* not lint */
  14.   
  15.   #ifndef lint
  16. ! static char sccsid[] = "@(#)syslogd.c    5.42 (Berkeley) 6/29/90, with ultrix/zephyr/COMPAT42 mods";
  17.   #endif /* not lint */
  18.   
  19.   /*
  20. ***************
  21. *** 47,52 ****
  22. --- 47,57 ----
  23.    * Author: Eric Allman
  24.    * extensive changes by Ralph Campbell
  25.    * more extensive changes by Eric Allman (again)
  26. + #ifdef ZEPHYR
  27. +  * changes for Zephyr and a little dynamic allocation 
  28. +  *    by Jon Rochlis (MIT), July 1987
  29. + #endif
  30. +  * COMPAT42 changes by John Kohl (MIT/DEC), December 1990
  31.    */
  32.   
  33.   #define    MAXLINE        1024        /* maximum line length */
  34. ***************
  35. *** 62,68 ****
  36. --- 67,75 ----
  37.   #include <sys/wait.h>
  38.   #include <sys/socket.h>
  39.   #include <sys/file.h>
  40. + #ifndef NO_KLOG
  41.   #include <sys/msgbuf.h>
  42. + #endif
  43.   #include <sys/uio.h>
  44.   #include <sys/un.h>
  45.   #include <sys/time.h>
  46. ***************
  47. *** 69,83 ****
  48. --- 76,101 ----
  49.   #include <sys/resource.h>
  50.   #include <sys/signal.h>
  51.   
  52. + #ifdef ZEPHYR
  53. + #include <zephyr/zephyr.h>
  54. + #else
  55.   #include <netinet/in.h>
  56. + #endif /* ZEPHYR */
  57.   #include <netdb.h>
  58.   
  59. + #ifdef macII
  60. + #include <sys/types.h>
  61. + #include <time.h>
  62. + #endif
  63.   #include <utmp.h>
  64.   #include <setjmp.h>
  65.   #include <stdio.h>
  66.   #include <ctype.h>
  67.   #include <string.h>
  68. + #ifdef POSIX
  69.   #include <unistd.h>
  70. + #endif
  71.   #include "pathnames.h"
  72.   
  73.   #define SYSLOG_NAMES
  74. ***************
  75. *** 88,97 ****
  76. --- 106,132 ----
  77.   char    *PidFile = _PATH_LOGPID;
  78.   char    ctty[] = _PATH_CONSOLE;
  79.   
  80. + #ifdef COMPAT42
  81. + struct in_addr localhostaddr;
  82. + #endif
  83.   #define FDMASK(fd)    (1 << (fd))
  84.   
  85.   #define    dprintf        if (Debug) printf
  86.   
  87. + #ifndef UT_NAMESIZE
  88. + #define UT_NAMESIZE    8
  89. + #endif
  90. + #ifndef _PATH_UTMP
  91. + #define _PATH_UTMP    UTMP_FILE
  92. + #endif
  93. + #ifdef ZEPHYR
  94. + #define UNAMESIZE    ANAME_SZ+INST_SZ+REALM_SZ /* 8 isn't good enough anymore */
  95. + #else
  96. + #define UNAMESIZE    UT_NAMESIZE
  97. + #endif
  98.   #define MAXUNAMES    20    /* maximum number of user names */
  99.   
  100.   /*
  101. ***************
  102. *** 115,121 ****
  103.       time_t    f_time;            /* time this was last written */
  104.       u_char    f_pmask[LOG_NFACILITIES+1];    /* priority mask */
  105.       union {
  106. !         char    f_uname[MAXUNAMES][UT_NAMESIZE+1];
  107.           struct {
  108.               char    f_hname[MAXHOSTNAMELEN+1];
  109.               struct sockaddr_in    f_addr;
  110. --- 150,156 ----
  111.       time_t    f_time;            /* time this was last written */
  112.       u_char    f_pmask[LOG_NFACILITIES+1];    /* priority mask */
  113.       union {
  114. !         char    f_uname[MAXUNAMES][UNAMESIZE+1];
  115.           struct {
  116.               char    f_hname[MAXHOSTNAMELEN+1];
  117.               struct sockaddr_in    f_addr;
  118. ***************
  119. *** 126,131 ****
  120. --- 161,167 ----
  121.       char    f_lasttime[16];            /* time of last occurrence */
  122.       char    f_prevhost[MAXHOSTNAMELEN+1];    /* host from which recd. */
  123.       int    f_prevpri;            /* pri of f_prevline */
  124. +     int    f_prevfac;            /* fac of f_prevline */
  125.       int    f_prevlen;            /* length of f_prevline */
  126.       int    f_prevcount;            /* repetition cnt of prevline */
  127.       int    f_repeatcount;            /* number of "repeated" msgs */
  128. ***************
  129. *** 151,160 ****
  130.   #define F_FORW        4        /* remote machine */
  131.   #define F_USERS        5        /* list of users */
  132.   #define F_WALL        6        /* everyone logged on */
  133.   
  134. ! char    *TypeNames[7] = {
  135.       "UNUSED",    "FILE",        "TTY",        "CONSOLE",
  136.       "FORW",        "USERS",    "WALL"
  137.   };
  138.   
  139.   struct    filed *Files;
  140. --- 187,202 ----
  141.   #define F_FORW        4        /* remote machine */
  142.   #define F_USERS        5        /* list of users */
  143.   #define F_WALL        6        /* everyone logged on */
  144. + #define F_ZEPHYR    7        /* use zephyr notification system */
  145.   
  146. ! char    *TypeNames[8] = {
  147.       "UNUSED",    "FILE",        "TTY",        "CONSOLE",
  148.       "FORW",        "USERS",    "WALL"
  149. + #ifdef ZEPHYR
  150. +     ,"ZEPHYR"
  151. + #else
  152. +     ,0
  153. + #endif
  154.   };
  155.   
  156.   struct    filed *Files;
  157. ***************
  158. *** 170,178 ****
  159. --- 212,276 ----
  160.   int    MarkInterval = 20 * 60;    /* interval between marks in seconds */
  161.   int    MarkSeq = 0;        /* mark sequence number */
  162.   
  163. + #ifdef ZEPHYR
  164. + ZNotice_t znotice;              /* for zephyr notices */
  165. + #endif
  166. + extern    int sys_nerr;
  167. + extern    char *sys_errlist[];
  168.   extern    int errno;
  169.   extern    char *ctime(), *index(), *calloc();
  170.   
  171. + #ifndef max
  172. + #define max(a,b) ((a) > (b) ? (a) : (b))
  173. + #endif
  174. + #ifdef ZEPHYR
  175. + /* private copies here, since the facility/priority names in the header file
  176. +    are not in numerical order, and we need a no-gap table */
  177. + CODE FacNames[] = {
  178. +     "kern",        LOG_KERN,
  179. +     "user",        LOG_USER,
  180. +     "mail",        LOG_MAIL,
  181. +     "daemon",    LOG_DAEMON,
  182. +     "auth",        LOG_AUTH,
  183. +     "syslog",    LOG_SYSLOG,
  184. +     "lpr",        LOG_LPR,
  185. +     "news",        LOG_NEWS,
  186. +     "uucp",        LOG_UUCP,
  187. +     "cron",     LOG_CRON,
  188. +     "reserved",    -1,
  189. +     "reserved",    -1,
  190. +     "reserved",    -1,
  191. +     "reserved",    -1,
  192. +     "reserved",    -1,
  193. +     "compat",    LOG_COMPAT,
  194. +     "local0",    LOG_LOCAL0,
  195. +     "local1",    LOG_LOCAL1,
  196. +     "local2",    LOG_LOCAL2,
  197. +     "local3",    LOG_LOCAL3,
  198. +     "local4",    LOG_LOCAL4,
  199. +     "local5",    LOG_LOCAL5,
  200. +     "local6",    LOG_LOCAL6,
  201. +     "local7",    LOG_LOCAL7,
  202. +     NULL,        -1,
  203. + };
  204. + CODE PriNames[] = {
  205. +     "emerg",    LOG_EMERG,
  206. +     "alert",    LOG_ALERT,
  207. +     "crit",        LOG_CRIT,
  208. +     "err",        LOG_ERR,
  209. +     "warning",    LOG_WARNING,
  210. +     "notice",    LOG_NOTICE,
  211. +     "info",        LOG_INFO,
  212. +     "debug",    LOG_DEBUG,
  213. +     NULL,        -1,
  214. + };
  215. + #endif
  216.   main(argc, argv)
  217.       int argc;
  218.       char **argv;
  219. ***************
  220. *** 184,193 ****
  221.       struct sockaddr_in sin, frominet;
  222.       FILE *fp;
  223.       int ch;
  224. !     char line[MSG_BSIZE + 1];
  225.       extern int optind;
  226.       extern char *optarg;
  227.       void die(), domark(), init(), reapchild();
  228.   
  229.       while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
  230.           switch((char)ch) {
  231. --- 282,298 ----
  232.       struct sockaddr_in sin, frominet;
  233.       FILE *fp;
  234.       int ch;
  235. ! #ifdef MSG_BSIZE
  236. !     char line[max(MSG_BSIZE,BUFSIZ) + 1];
  237. ! #else
  238. !     char line[BUFSIZ + 1];
  239. ! #endif
  240.       extern int optind;
  241.       extern char *optarg;
  242.       void die(), domark(), init(), reapchild();
  243. + #ifdef COMPAT42
  244. +     localhostaddr.s_addr = htonl(0x7f000001L); /* 127.0.0.1 */
  245. + #endif
  246.   
  247.       while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
  248.           switch((char)ch) {
  249. ***************
  250. *** 212,219 ****
  251.   
  252.       if (!Debug)
  253.           daemon(0, 0);
  254. !     else
  255. !         setlinebuf(stdout);
  256.   
  257.       consfile.f_type = F_CONSOLE;
  258.       (void) strcpy(consfile.f_un.f_fname, ctty);
  259. --- 317,330 ----
  260.   
  261.       if (!Debug)
  262.           daemon(0, 0);
  263. !     else {
  264. ! #ifndef macII
  265. !           setlinebuf(stdout);
  266. ! #else
  267. !         static char buf[BUFSIZ];
  268. !         setvbuf (stdout, buf, _IOLBF, BUFSIZ);
  269. ! #endif
  270. !     }
  271.   
  272.       consfile.f_type = F_CONSOLE;
  273.       (void) strcpy(consfile.f_un.f_fname, ctty);
  274. ***************
  275. *** 225,232 ****
  276. --- 336,354 ----
  277.       else
  278.           LocalDomain = "";
  279.       (void) signal(SIGTERM, die);
  280. + #ifdef ultrix
  281. +     /* compiler otherwise chokes on the ? : */
  282. +     if (Debug) {
  283. +         (void) signal(SIGINT, die);
  284. +         (void) signal(SIGQUIT, die);
  285. +     } else {
  286. +         (void) signal(SIGINT, SIG_IGN);
  287. +         (void) signal(SIGQUIT, SIG_IGN);
  288. +     }
  289. + #else
  290.       (void) signal(SIGINT, Debug ? die : SIG_IGN);
  291.       (void) signal(SIGQUIT, Debug ? die : SIG_IGN);
  292. + #endif
  293.       (void) signal(SIGCHLD, reapchild);
  294.       (void) signal(SIGALRM, domark);
  295.       (void) alarm(TIMERINTVL);
  296. ***************
  297. *** 237,243 ****
  298.       (void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
  299.       funix = socket(AF_UNIX, SOCK_DGRAM, 0);
  300.       if (funix < 0 || bind(funix, (struct sockaddr *) &sunx,
  301. !         sizeof(sunx.sun_family)+sizeof(sunx.sun_len)+
  302.           strlen(sunx.sun_path)) < 0 ||
  303.           chmod(LogName, 0666) < 0) {
  304.           (void) sprintf(line, "cannot create %s", LogName);
  305. --- 359,368 ----
  306.       (void) strncpy(sunx.sun_path, LogName, sizeof sunx.sun_path);
  307.       funix = socket(AF_UNIX, SOCK_DGRAM, 0);
  308.       if (funix < 0 || bind(funix, (struct sockaddr *) &sunx,
  309. !         sizeof(sunx.sun_family)+
  310. ! #ifdef TAHOE_SOCKETS
  311. !         sizeof(sunx.sun_len)+
  312. ! #endif
  313.           strlen(sunx.sun_path)) < 0 ||
  314.           chmod(LogName, 0666) < 0) {
  315.           (void) sprintf(line, "cannot create %s", LogName);
  316. ***************
  317. *** 266,271 ****
  318. --- 391,400 ----
  319.               InetInuse = 1;
  320.           }
  321.       }
  322. + #ifdef NO_KLOG
  323. +     klogm = 0;
  324. +     fklog = 0;
  325. + #else
  326.       if ((fklog = open(_PATH_KLOG, O_RDONLY, 0)) >= 0)
  327.           klogm = FDMASK(fklog);
  328.       else {
  329. ***************
  330. *** 272,277 ****
  331. --- 401,407 ----
  332.           dprintf("can't open %s (%d)\n", _PATH_KLOG, errno);
  333.           klogm = 0;
  334.       }
  335. + #endif
  336.   
  337.       /* tuck my process id away */
  338.       fp = fopen(PidFile, "w");
  339. ***************
  340. *** 282,287 ****
  341. --- 412,427 ----
  342.   
  343.       dprintf("off & running....\n");
  344.   
  345. + #ifdef ZEPHYR
  346. +     /* initialize zephyr stuff */
  347. +     bzero (&znotice, sizeof (znotice));
  348. +     znotice.z_kind = UNSAFE;
  349. +     znotice.z_class = "SYSLOG";
  350. +     znotice.z_class_inst = LocalHostName;
  351. +     znotice.z_default_format = "Syslog message from $instance, level $opcode:\n$message";
  352. +     (void) ZInitialize ();
  353. + #endif
  354.       init();
  355.       (void) signal(SIGHUP, init);
  356.   
  357. ***************
  358. *** 317,323 ****
  359.                   (struct sockaddr *) &fromunix, &len);
  360.               if (i > 0) {
  361.                   line[i] = '\0';
  362. !                 printline(LocalHostName, line);
  363.               } else if (i < 0 && errno != EINTR)
  364.                   logerror("recvfrom unix");
  365.           }
  366. --- 457,463 ----
  367.                   (struct sockaddr *) &fromunix, &len);
  368.               if (i > 0) {
  369.                   line[i] = '\0';
  370. !                 printline(LocalHostName, line, 0);
  371.               } else if (i < 0 && errno != EINTR)
  372.                   logerror("recvfrom unix");
  373.           }
  374. ***************
  375. *** 329,335 ****
  376.                   extern char *cvthname();
  377.   
  378.                   line[i] = '\0';
  379. !                 printline(cvthname(&frominet), line);
  380.               } else if (i < 0 && errno != EINTR)
  381.                   logerror("recvfrom inet");
  382.           } 
  383. --- 469,483 ----
  384.                   extern char *cvthname();
  385.   
  386.                   line[i] = '\0';
  387. ! #ifdef COMPAT42
  388. !                 /* if it matches the localhost loopback,
  389. !                    this is an old client, so humor him. */
  390. !                 if (frominet.sin_addr.s_addr ==
  391. !                     localhostaddr.s_addr)
  392. !                     printline(cvthname(&frominet), line, 1);
  393. !                 else
  394. ! #endif
  395. !                     printline(cvthname(&frominet), line, 0);
  396.               } else if (i < 0 && errno != EINTR)
  397.                   logerror("recvfrom inet");
  398.           } 
  399. ***************
  400. *** 343,356 ****
  401.       exit(1);
  402.   }
  403.   
  404.   /*
  405.    * Take a raw input line, decode the message, and print the message
  406.    * on the appropriate log files.
  407.    */
  408.   
  409. ! printline(hname, msg)
  410.       char *hname;
  411.       char *msg;
  412.   {
  413.       register char *p, *q;
  414.       register int c;
  415. --- 491,522 ----
  416.       exit(1);
  417.   }
  418.   
  419. + #ifdef COMPAT42
  420. + int convert_oldpri[] = {
  421. +     LOG_COMPAT|LOG_EMERG,        /* there is no 0 */
  422. +     LOG_COMPAT|LOG_ALERT,        /* old LOG_ALERT */
  423. +     LOG_COMPAT|LOG_ALERT,        /* old LOG_SALERT */
  424. +     LOG_COMPAT|LOG_CRIT,        /* old LOG_EMERG */
  425. +     LOG_COMPAT|LOG_ERR,            /* old LOG_ERROR */
  426. +     LOG_COMPAT|LOG_WARNING,        /* old LOG_CRIT */
  427. +     LOG_COMPAT|LOG_WARNING,        /* old LOG_WARNING */
  428. +     LOG_COMPAT|LOG_NOTICE,        /* old LOG_NOTICE */
  429. +     LOG_COMPAT|LOG_INFO,        /* old LOG_INFO */
  430. +     LOG_COMPAT|LOG_DEBUG,        /* old LOG_DEBUG */
  431. + };
  432. + int noldpri = sizeof(convert_oldpri)/sizeof(convert_oldpri[0]);
  433. + #endif
  434.   /*
  435.    * Take a raw input line, decode the message, and print the message
  436.    * on the appropriate log files.
  437.    */
  438.   
  439. ! printline(hname, msg, oldcompat)
  440.       char *hname;
  441.       char *msg;
  442. +     int oldcompat;
  443.   {
  444.       register char *p, *q;
  445.       register int c;
  446. ***************
  447. *** 367,372 ****
  448. --- 533,546 ----
  449.           if (*p == '>')
  450.               ++p;
  451.       }
  452. + #ifdef COMPAT42
  453. +     if (oldcompat) {
  454. +         if (pri > 0 && pri < noldpri)
  455. +         pri = convert_oldpri[pri];
  456. +         else
  457. +         pri = LOG_MAKEPRI(LOG_COMPAT, LOG_ERR);
  458. +     }
  459. + #endif
  460.       if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
  461.           pri = DEFUPRI;
  462.   
  463. ***************
  464. *** 435,440 ****
  465. --- 609,630 ----
  466.   
  467.   time_t    now;
  468.   
  469. + #ifndef O_NOCTTY
  470. + void
  471. + untty()
  472. + {
  473. +     int i;
  474. +     if (!Debug) {
  475. +         i = open("/dev/tty", O_RDWR);
  476. +         if (i >= 0) {
  477. +             (void) ioctl(i, (int) TIOCNOTTY, (char *)0);
  478. +             (void) close(i);
  479. +         }
  480. +     }
  481. + }
  482. + #endif
  483.   /*
  484.    * Log a message to the appropriate log files, users, etc. based on
  485.    * the priority.
  486. ***************
  487. *** 483,492 ****
  488.       /* log the message to the particular outputs */
  489.       if (!Initialized) {
  490.           f = &consfile;
  491.           f->f_file = open(ctty, O_WRONLY, 0);
  492.   
  493.           if (f->f_file >= 0) {
  494. !             fprintlog(f, flags, msg);
  495.               (void) close(f->f_file);
  496.           }
  497.           (void) sigsetmask(omask);
  498. --- 673,689 ----
  499.       /* log the message to the particular outputs */
  500.       if (!Initialized) {
  501.           f = &consfile;
  502. + #ifdef O_NOCTTY
  503. +         f->f_file = open(ctty, O_WRONLY|O_NOCTTY, 0);
  504. + #else
  505.           f->f_file = open(ctty, O_WRONLY, 0);
  506. + #endif
  507.   
  508.           if (f->f_file >= 0) {
  509. ! #ifndef O_NOCTTY
  510. !             untty();
  511. ! #endif
  512. !             fprintlog(f, flags, msg, fac, prilev);
  513.               (void) close(f->f_file);
  514.           }
  515.           (void) sigsetmask(omask);
  516. ***************
  517. *** 523,535 ****
  518.                * in the future.
  519.                */
  520.               if (now > REPEATTIME(f)) {
  521. !                 fprintlog(f, flags, (char *)NULL);
  522.                   BACKOFF(f);
  523.               }
  524.           } else {
  525.               /* new line, save it */
  526.               if (f->f_prevcount)
  527. !                 fprintlog(f, 0, (char *)NULL);
  528.               f->f_repeatcount = 0;
  529.               (void) strncpy(f->f_lasttime, timestamp, 15);
  530.               (void) strncpy(f->f_prevhost, from,
  531. --- 720,732 ----
  532.                * in the future.
  533.                */
  534.               if (now > REPEATTIME(f)) {
  535. !                 fprintlog(f, flags, (char *)NULL, fac, prilev);
  536.                   BACKOFF(f);
  537.               }
  538.           } else {
  539.               /* new line, save it */
  540.               if (f->f_prevcount)
  541. !                 fprintlog(f, 0, (char *)NULL, fac, prilev);
  542.               f->f_repeatcount = 0;
  543.               (void) strncpy(f->f_lasttime, timestamp, 15);
  544.               (void) strncpy(f->f_prevhost, from,
  545. ***************
  546. *** 537,548 ****
  547.               if (msglen < MAXSVLINE) {
  548.                   f->f_prevlen = msglen;
  549.                   f->f_prevpri = pri;
  550.                   (void) strcpy(f->f_prevline, msg);
  551. !                 fprintlog(f, flags, (char *)NULL);
  552.               } else {
  553.                   f->f_prevline[0] = 0;
  554.                   f->f_prevlen = 0;
  555. !                 fprintlog(f, flags, msg);
  556.               }
  557.           }
  558.       }
  559. --- 734,746 ----
  560.               if (msglen < MAXSVLINE) {
  561.                   f->f_prevlen = msglen;
  562.                   f->f_prevpri = pri;
  563. +                 f->f_prevfac = fac;
  564.                   (void) strcpy(f->f_prevline, msg);
  565. !                 fprintlog(f, flags, (char *)NULL, fac, prilev);
  566.               } else {
  567.                   f->f_prevline[0] = 0;
  568.                   f->f_prevlen = 0;
  569. !                 fprintlog(f, flags, msg, fac, prilev);
  570.               }
  571.           }
  572.       }
  573. ***************
  574. *** 549,570 ****
  575.       (void) sigsetmask(omask);
  576.   }
  577.   
  578. ! fprintlog(f, flags, msg)
  579.       register struct filed *f;
  580.       int flags;
  581.       char *msg;
  582.   {
  583.       struct iovec iov[6];
  584.       register struct iovec *v;
  585.       register int l;
  586.       char line[MAXLINE + 1], repbuf[80], greetings[200];
  587.   
  588.       v = iov;
  589.       if (f->f_type == F_WALL) {
  590.           v->iov_base = greetings;
  591. !         v->iov_len = sprintf(greetings,
  592.               "\r\n\7Message from syslogd@%s at %.24s ...\r\n",
  593.               f->f_prevhost, ctime(&now));
  594.           v++;
  595.           v->iov_base = "";
  596.           v->iov_len = 0;
  597. --- 747,776 ----
  598.       (void) sigsetmask(omask);
  599.   }
  600.   
  601. ! fprintlog(f, flags, msg, fac, prilev)
  602.       register struct filed *f;
  603.       int flags;
  604.       char *msg;
  605. +     int fac;
  606. +     int prilev;
  607.   {
  608.       struct iovec iov[6];
  609.       register struct iovec *v;
  610.       register int l;
  611.       char line[MAXLINE + 1], repbuf[80], greetings[200];
  612. + #ifdef ZEPHYR
  613. +     char pri_fac_str[MAXLINE];
  614. +     int zcode;
  615. +     register int i;
  616. + #endif
  617.   
  618.       v = iov;
  619.       if (f->f_type == F_WALL) {
  620.           v->iov_base = greetings;
  621. !         (void) sprintf(greetings,
  622.               "\r\n\7Message from syslogd@%s at %.24s ...\r\n",
  623.               f->f_prevhost, ctime(&now));
  624. +         v->iov_len = strlen(greetings);
  625.           v++;
  626.           v->iov_base = "";
  627.           v->iov_len = 0;
  628. ***************
  629. *** 589,596 ****
  630.           v->iov_len = strlen(msg);
  631.       } else if (f->f_prevcount > 1) {
  632.           v->iov_base = repbuf;
  633. !         v->iov_len = sprintf(repbuf, "last message repeated %d times",
  634.               f->f_prevcount);
  635.       } else {
  636.           v->iov_base = f->f_prevline;
  637.           v->iov_len = f->f_prevlen;
  638. --- 795,803 ----
  639.           v->iov_len = strlen(msg);
  640.       } else if (f->f_prevcount > 1) {
  641.           v->iov_base = repbuf;
  642. !         (void) sprintf(repbuf, "last message repeated %d times",
  643.               f->f_prevcount);
  644. +         v->iov_len = strlen(repbuf);
  645.       } else {
  646.           v->iov_base = f->f_prevline;
  647.           v->iov_len = f->f_prevlen;
  648. ***************
  649. *** 607,614 ****
  650.   
  651.       case F_FORW:
  652.           dprintf(" %s\n", f->f_un.f_forw.f_hname);
  653. !         l = sprintf(line, "<%d>%.15s %s", f->f_prevpri,
  654.               iov[0].iov_base, iov[4].iov_base);
  655.           if (l > MAXLINE)
  656.               l = MAXLINE;
  657.           if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
  658. --- 814,822 ----
  659.   
  660.       case F_FORW:
  661.           dprintf(" %s\n", f->f_un.f_forw.f_hname);
  662. !         (void) sprintf(line, "<%d>%.15s %s", f->f_prevpri,
  663.               iov[0].iov_base, iov[4].iov_base);
  664. +         l = strlen(line);
  665.           if (l > MAXLINE)
  666.               l = MAXLINE;
  667.           if (sendto(finet, line, l, 0, &f->f_un.f_forw.f_addr,
  668. ***************
  669. *** 662,667 ****
  670. --- 870,905 ----
  671.               (void) fsync(f->f_file);
  672.           break;
  673.   
  674. + #ifdef ZEPHYR
  675. +              case F_ZEPHYR:
  676. +             (void) sprintf(line, "%.15s [%s] %s",
  677. +                        iov[0].iov_base,
  678. +                        iov[2].iov_base,
  679. +                        iov[4].iov_base);
  680. +             (void) sprintf(pri_fac_str, "%s.%s",
  681. +                        FacNames[fac].c_name,
  682. +                        PriNames[(prilev & LOG_PRIMASK)].c_name);
  683. +             znotice.z_message = line;
  684. +             /* include the null just in case */
  685. +             znotice.z_message_len = strlen (line) + 1;
  686. +             znotice.z_opcode = pri_fac_str;
  687. +             dprintf (" z_opcode %s\n", pri_fac_str);
  688. +             for (i = 0; i < MAXUNAMES; i++) {
  689. +               if (!f->f_un.f_uname[i][0]) 
  690. +                 break;
  691. +               /* map "*" into null recipient and therefore
  692. +                  anybody who is listening */
  693. +               if (strcmp (f->f_un.f_uname[i], "*") == 0)
  694. +                 znotice.z_recipient = "";
  695. +               else
  696. +                 znotice.z_recipient = f->f_un.f_uname[i];
  697. +               zcode = ZSendNotice (&znotice, ZNOAUTH); 
  698. +               if (zcode != 0)
  699. +                 logerror (error_message (zcode));
  700. +             }
  701. +             break;
  702. + #endif
  703.       case F_USERS:
  704.       case F_WALL:
  705.           dprintf("\n");
  706. ***************
  707. *** 752,757 ****
  708. --- 990,1000 ----
  709.           dprintf("Malformed from address\n");
  710.           return ("???");
  711.       }
  712. + #ifdef COMPAT42
  713. +     /* don't bother looking up 127.0.0.1, it's us. */
  714. +     if (f->sin_addr.s_addr == localhostaddr.s_addr)
  715. +         return(LocalHostName);
  716. + #endif
  717.       hp = gethostbyaddr(&f->sin_addr, sizeof(struct in_addr), f->sin_family);
  718.       if (hp == 0) {
  719.           dprintf("Host name for your address (%s) unknown\n",
  720. ***************
  721. *** 781,787 ****
  722.               dprintf("flush %s: repeated %d times, %d sec.\n",
  723.                   TypeNames[f->f_type], f->f_prevcount,
  724.                   repeatinterval[f->f_repeatcount]);
  725. !             fprintlog(f, 0, (char *)NULL);
  726.               BACKOFF(f);
  727.           }
  728.       }
  729. --- 1024,1030 ----
  730.               dprintf("flush %s: repeated %d times, %d sec.\n",
  731.                   TypeNames[f->f_type], f->f_prevcount,
  732.                   repeatinterval[f->f_repeatcount]);
  733. !             fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
  734.               BACKOFF(f);
  735.           }
  736.       }
  737. ***************
  738. *** 814,820 ****
  739.       for (f = Files; f != NULL; f = f->f_next) {
  740.           /* flush any pending output */
  741.           if (f->f_prevcount)
  742. !             fprintlog(f, 0, (char *)NULL);
  743.       }
  744.       if (sig) {
  745.           dprintf("syslogd: exiting on signal %d\n", sig);
  746. --- 1057,1063 ----
  747.       for (f = Files; f != NULL; f = f->f_next) {
  748.           /* flush any pending output */
  749.           if (f->f_prevcount)
  750. !             fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
  751.       }
  752.       if (sig) {
  753.           dprintf("syslogd: exiting on signal %d\n", sig);
  754. ***************
  755. *** 848,860 ****
  756.       for (f = Files; f != NULL; f = next) {
  757.           /* flush any pending output */
  758.           if (f->f_prevcount)
  759. !             fprintlog(f, 0, (char *)NULL);
  760.   
  761.           switch (f->f_type) {
  762.             case F_FILE:
  763.             case F_TTY:
  764.             case F_CONSOLE:
  765. -           case F_FORW:
  766.               (void) close(f->f_file);
  767.               break;
  768.           }
  769. --- 1091,1102 ----
  770.       for (f = Files; f != NULL; f = next) {
  771.           /* flush any pending output */
  772.           if (f->f_prevcount)
  773. !             fprintlog(f, 0, (char *)NULL, f->f_prevfac, f->f_prevpri);
  774.   
  775.           switch (f->f_type) {
  776.             case F_FILE:
  777.             case F_TTY:
  778.             case F_CONSOLE:
  779.               (void) close(f->f_file);
  780.               break;
  781.           }
  782. ***************
  783. *** 920,925 ****
  784. --- 1162,1168 ----
  785.                   break;
  786.   
  787.               case F_USERS:
  788. +             case F_ZEPHYR:
  789.                   for (i = 0; i < MAXUNAMES && *f->f_un.f_uname[i]; i++)
  790.                       printf("%s, ", f->f_un.f_uname[i]);
  791.                   break;
  792. ***************
  793. *** 1025,1031 ****
  794.           hp = gethostbyname(p);
  795.           if (hp == NULL) {
  796.               extern int h_errno, h_nerr;
  797. !             extern char **h_errlist;
  798.   
  799.               logerror((u_int)h_errno < h_nerr ?
  800.                   h_errlist[h_errno] : "Unknown error");
  801. --- 1268,1274 ----
  802.           hp = gethostbyname(p);
  803.           if (hp == NULL) {
  804.               extern int h_errno, h_nerr;
  805. !             extern char *h_errlist[];
  806.   
  807.               logerror((u_int)h_errno < h_nerr ?
  808.                   h_errlist[h_errno] : "Unknown error");
  809. ***************
  810. *** 1041,1064 ****
  811.   
  812.       case '/':
  813.           (void) strcpy(f->f_un.f_fname, p);
  814. !         if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) {
  815.               f->f_file = F_UNUSED;
  816.               logerror(p);
  817.               break;
  818.           }
  819. !         if (isatty(f->f_file))
  820.               f->f_type = F_TTY;
  821. !         else
  822.               f->f_type = F_FILE;
  823.           if (strcmp(p, ctty) == 0)
  824.               f->f_type = F_CONSOLE;
  825.           break;
  826.   
  827.       case '*':
  828.           f->f_type = F_WALL;
  829.           break;
  830. !     default:
  831.           for (i = 0; i < MAXUNAMES && *p; i++) {
  832.               for (q = p; *q && *q != ','; )
  833.                   q++;
  834. --- 1284,1322 ----
  835.   
  836.       case '/':
  837.           (void) strcpy(f->f_un.f_fname, p);
  838. ! #ifdef O_NOCTTY
  839. ! #define FLAGS O_WRONLY|O_APPEND|O_NOCTTY
  840. ! #else
  841. ! #define FLAGS O_WRONLY|O_APPEND
  842. ! #endif
  843. !         if ((f->f_file = open(p, FLAGS, 0)) < 0) {
  844. ! #undef FLAGS
  845.               f->f_file = F_UNUSED;
  846.               logerror(p);
  847.               break;
  848.           }
  849. !         if (isatty(f->f_file)) {
  850.               f->f_type = F_TTY;
  851. ! #ifndef O_NOCTTY
  852. !             untty();
  853. ! #endif
  854. !         } else
  855.               f->f_type = F_FILE;
  856.           if (strcmp(p, ctty) == 0)
  857.               f->f_type = F_CONSOLE;
  858.           break;
  859.   
  860. + #ifndef ZEPHYR
  861.       case '*':
  862.           f->f_type = F_WALL;
  863.           break;
  864. ! #else
  865. !     case '!':
  866. !         p++;
  867. !         if (*p == '*') {
  868. !         f->f_type = F_WALL;
  869. !         break;
  870. !         }
  871.           for (i = 0; i < MAXUNAMES && *p; i++) {
  872.               for (q = p; *q && *q != ','; )
  873.                   q++;
  874. ***************
  875. *** 1072,1077 ****
  876. --- 1330,1356 ----
  877.               p = q;
  878.           }
  879.           f->f_type = F_USERS;
  880. +         break;
  881. + #endif
  882. +     default:
  883. +         for (i = 0; i < MAXUNAMES && *p; i++) {
  884. +             for (q = p; *q && *q != ','; )
  885. +                 q++;
  886. +             (void) strncpy(f->f_un.f_uname[i], p, UNAMESIZE);
  887. +             if ((q - p) > UNAMESIZE)
  888. +                 f->f_un.f_uname[i][UNAMESIZE] = '\0';
  889. +             else
  890. +                 f->f_un.f_uname[i][q - p] = '\0';
  891. +             while (*q == ',' || *q == ' ')
  892. +                 q++;
  893. +             p = q;
  894. +         }
  895. + #ifdef ZEPHYR
  896. +         f->f_type = F_ZEPHYR;
  897. + #else
  898. +         f->f_type = F_USERS;
  899. + #endif
  900.           break;
  901.       }
  902.   }
  903. *** pristine-syslog.h    Thu Jan 31 12:18:55 1991
  904. --- syslog.h    Thu Jan 31 13:26:30 1991
  905. ***************
  906. *** 17,23 ****
  907.    * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  908.    * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  909.    *
  910. !  *    @(#)syslog.h    7.16 (Berkeley) 6/28/90
  911.    */
  912.   
  913.   /*
  914. --- 17,23 ----
  915.    * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  916.    * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  917.    *
  918. !  *    @(#)syslog.h    7.16 (Berkeley) 6/28/90, with COMPAT42 mods
  919.    */
  920.   
  921.   /*
  922. ***************
  923. *** 80,85 ****
  924. --- 80,86 ----
  925.   #define    LOG_NEWS    (7<<3)    /* network news subsystem */
  926.   #define    LOG_UUCP    (8<<3)    /* UUCP subsystem */
  927.   #define    LOG_CRON    (9<<3)    /* clock daemon */
  928. + #define    LOG_COMPAT    (15<<3)    /* compatibility with 4.2 syslog */
  929.       /* other codes through 15 reserved for system use */
  930.   #define    LOG_LOCAL0    (16<<3)    /* reserved for local use */
  931.   #define    LOG_LOCAL1    (17<<3)    /* reserved for local use */
  932. ***************
  933. *** 98,103 ****
  934. --- 99,105 ----
  935.   #ifdef SYSLOG_NAMES
  936.   CODE facilitynames[] = {
  937.       "auth",        LOG_AUTH,
  938. +     "compat",    LOG_COMPAT,
  939.       "cron",     LOG_CRON,
  940.       "daemon",    LOG_DAEMON,
  941.       "kern",        LOG_KERN,
  942. *** pristine-pathnames.h    Thu Jan 31 13:20:23 1991
  943. --- pathnames.h    Thu Jan 31 13:21:00 1991
  944. ***************
  945. *** 16,22 ****
  946.    * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  947.    * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  948.    *
  949. !  *    @(#)pathnames.h    5.3 (Berkeley) 6/1/90
  950.    */
  951.   
  952.   #include <paths.h>
  953. --- 16,22 ----
  954.    * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  955.    * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  956.    *
  957. !  *    @(#)pathnames.h    5.3 (Berkeley) 6/1/90, with COMPAT42 mods
  958.    */
  959.   
  960.   #include <paths.h>
  961. ***************
  962. *** 23,27 ****
  963. --- 23,32 ----
  964.   
  965.   #define    _PATH_KLOG    "/dev/klog"
  966.   #define    _PATH_LOG    "/dev/log"
  967. + #ifdef COMPAT42
  968. + #define    _PATH_LOGCONF    "/etc/nsyslog.conf"
  969. + #define    _PATH_LOGPID    "/etc/nsyslog.pid"
  970. + #else
  971.   #define    _PATH_LOGCONF    "/etc/syslog.conf"
  972.   #define    _PATH_LOGPID    "/var/run/syslog.pid"
  973. + #endif
  974. *** pristine-syslog.c    Thu Jan 31 13:49:38 1991
  975. --- syslog.c    Thu Jan 31 13:56:42 1991
  976. ***************
  977. *** 18,24 ****
  978.    */
  979.   
  980.   #if defined(LIBC_SCCS) && !defined(lint)
  981. ! static char sccsid[] = "@(#)syslog.c    5.28 (Berkeley) 6/27/90";
  982.   #endif /* LIBC_SCCS and not lint */
  983.   
  984.   /*
  985. --- 18,24 ----
  986.    */
  987.   
  988.   #if defined(LIBC_SCCS) && !defined(lint)
  989. ! static char sccsid[] = "@(#)syslog.c    5.28 (Berkeley) 6/27/90, with varags changes";
  990.   #endif /* LIBC_SCCS and not lint */
  991.   
  992.   /*
  993. ***************
  994. *** 37,42 ****
  995. --- 37,48 ----
  996.    * Modified to use UNIX domain IPC by Ralph Campbell
  997.    */
  998.   
  999. + #ifdef __STDC__
  1000. + #include <stdarg.h>
  1001. + #else
  1002. + #include <varargs.h>
  1003. + #endif
  1004.   #include <sys/types.h>
  1005.   #include <sys/socket.h>
  1006.   #include <sys/file.h>
  1007. ***************
  1008. *** 46,52 ****
  1009.   #include <sys/wait.h>
  1010.   #include <netdb.h>
  1011.   #include <string.h>
  1012. - #include <varargs.h>
  1013.   #include <paths.h>
  1014.   #include <stdio.h>
  1015.   
  1016. --- 52,57 ----
  1017. ***************
  1018. *** 58,68 ****
  1019.   static char    *LogTag = "syslog";    /* string to tag the entry with */
  1020.   static int    LogFacility = LOG_USER;    /* default facility code */
  1021.   
  1022. ! syslog(pri, fmt, args)
  1023. !     int pri, args;
  1024. !     char *fmt;
  1025.   {
  1026. !     vsyslog(pri, fmt, &args);
  1027.   }
  1028.   
  1029.   vsyslog(pri, fmt, ap)
  1030. --- 63,85 ----
  1031.   static char    *LogTag = "syslog";    /* string to tag the entry with */
  1032.   static int    LogFacility = LOG_USER;    /* default facility code */
  1033.   
  1034. ! #ifdef __STDC__
  1035. ! syslog(int pri, const char *fmt, ...)
  1036. ! #else
  1037. ! syslog(pri, fmt, va_alist)
  1038. !       int pri;
  1039. !       char *fmt;
  1040. !       va_dcl
  1041. ! #endif
  1042.   {
  1043. !     va_list pvar;
  1044. ! #ifdef __STDC__
  1045. !     va_start(pvar, fmt);
  1046. ! #else
  1047. !     va_start(pvar);
  1048. ! #endif
  1049. !     vsyslog(pri, fmt, pvar);
  1050. !     va_end(pvar);
  1051.   }
  1052.   
  1053.   vsyslog(pri, fmt, ap)
  1054. ***************
  1055. *** 149,156 ****
  1056. --- 166,178 ----
  1057.        * output the message to the console; don't worry about
  1058.        * blocking, if console blocks everything will.
  1059.        */
  1060. + #ifdef O_NOCTTY
  1061. +     if ((fd = open(_PATH_CONSOLE, O_NOCTTY|O_WRONLY, 0)) < 0)
  1062. +         return;
  1063. + #else
  1064.       if ((fd = open(_PATH_CONSOLE, O_WRONLY, 0)) < 0)
  1065.           return;
  1066. + #endif
  1067.       (void)strcat(tbuf, "\r\n");
  1068.       cnt += 2;
  1069.       p = index(tbuf, '>') + 1;
  1070.