mark@comp.vuw.ac.nz (Mark Davies) (04/10/90)
I meant to post this back when we first got 7.0 but I didn't get to it. HP's syslogd leaves children lying around when logging messages that should be displayed on a group of users ttys (The F_USERS and F_WALL cases). The problem is the difference in what is recorded in /etc/utmp between BSD and HP-UX. (Yes this is the same problem I just found in dump). I reported this to our local HP office back at 3.1 but the bug is still in 7.0 so thought I would post diffs for the BSD syslogd source to work under hpux for those who want a working syslogd now. *** /usr/src/etc/syslogd.c Wed Dec 20 15:10:08 1989 --- syslogd.c Fri Mar 9 15:45:25 1990 *************** *** 48,61 **** #include <errno.h> #include <stdio.h> #include <utmp.h> #include <ctype.h> #include <signal.h> #include <sysexits.h> #include <strings.h> #include <sys/syslog.h> ! #include <sys/types.h> #include <sys/param.h> #include <sys/ioctl.h> #include <sys/stat.h> --- 48,72 ---- #include <errno.h> #include <stdio.h> + #include <sys/types.h> #include <utmp.h> #include <ctype.h> #include <signal.h> + #ifndef hpux #include <sysexits.h> #include <strings.h> + #else + #include <string.h> + #endif + #ifdef hpux + #include <syslog.h> + #define LOG_NEWS (7<<3) /* network news subsystem */ + #define LOG_UUCP (8<<3) /* UUCP subsystem */ + #define LOG_RPC (10<<3) /* NFS/RPC messages */ + #else #include <sys/syslog.h> ! #endif #include <sys/param.h> #include <sys/ioctl.h> #include <sys/stat.h> *************** *** 71,76 **** --- 82,91 ---- #include <netinet/in.h> #include <netdb.h> + #ifdef hpux + #define MAXHOSTNAMELEN 64 + #endif + char *LogName = "/dev/log"; char *ConfFile = "/etc/syslog.conf"; char *PidFile = "/etc/syslog.pid"; *************** *** 203,209 **** --- 218,228 ---- (void) dup2(0, 2); untty(); } else + #ifndef hpux setlinebuf(stdout); + #else + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); + #endif (void) gethostname(LocalHostName, sizeof LocalHostName); if (p = index(LocalHostName, '.')) { *************** *** 220,225 **** --- 239,245 ---- (void) alarm(MarkInterval * 60 / MARKCOUNT); (void) unlink(LogName); + #ifndef hpux s_un.sun_family = AF_UNIX; (void) strncpy(s_un.sun_path, LogName, sizeof s_un.sun_path); funix = socket(AF_UNIX, SOCK_DGRAM, 0); *************** *** 226,231 **** --- 246,255 ---- if (funix < 0 || bind(funix, (struct sockaddr *) &s_un, sizeof(s_un.sun_family)+strlen(s_un.sun_path)) < 0 || chmod(LogName, 0666) < 0) { + #else + if (mknod (LogName, S_IFIFO|0666, 0) < 0 || chmod(LogName, 0666) < 0 || + (funix = open(LogName, O_RDWR, 0)) < 0) { + #endif (void) sprintf(line, "cannot create %s", LogName); logerror(line); dprintf("cannot create %s (%d)\n", LogName, errno); *************** *** 298,306 **** --- 322,334 ---- } } if (readfds & FDMASK(funix)) { + #ifndef hpux len = sizeof fromunix; i = recvfrom(funix, line, MAXLINE, 0, (struct sockaddr *) &fromunix, &len); + #else + i = read(funix, line, MAXLINE); + #endif if (i > 0) { line[i] = '\0'; printline(LocalHostName, line); *************** *** 332,342 **** --- 360,374 ---- int i; if (!Debug) { + #ifndef hpux i = open("/dev/tty", O_RDWR); if (i >= 0) { (void) ioctl(i, (int) TIOCNOTTY, (char *)0); (void) close(i); } + #else + setpgrp(0,0); /* should be setsid() in 7.0 */ + #endif } } *************** *** 581,588 **** f->f_type = F_UNUSED; logerror(f->f_un.f_fname); } - else - (void) writev(f->f_file, iov,6); untty(); } else { f->f_type = F_UNUSED; --- 613,618 ---- *************** *** 646,652 **** --- 676,686 ---- /* scan the user login file */ while (fread((char *) &ut, sizeof ut, 1, uf) == 1) { /* is this slot used? */ + #ifndef hpux if (ut.ut_name[0] == '\0') + #else + if (ut.ut_type != USER_PROCESS || ut.ut_name[0] == '\0') + #endif continue; /* should we send the message to this user? */ cheers mark