--- embedtools/src/Attic/syslogd.c 2010/09/28 17:58:13 1.1.2.2 +++ embedtools/src/Attic/syslogd.c 2011/06/08 09:08:44 1.1.2.5 @@ -75,6 +75,8 @@ __FBSDID("$FreeBSD: src/usr.sbin/syslogd/syslogd.c,v 1 #define TIMERINTVL 30 /* interval for checking flush, mark */ #define TTYMSGTIME 1 /* timeout passed to ttymsg */ +#include "config.h" + #include #include #include @@ -97,7 +99,9 @@ __FBSDID("$FreeBSD: src/usr.sbin/syslogd/syslogd.c,v 1 #include #include #include +#ifdef HAVE_LIBUTIL #include +#endif #include #include #include @@ -106,7 +110,11 @@ __FBSDID("$FreeBSD: src/usr.sbin/syslogd/syslogd.c,v 1 #include #include #include +#if defined(__FreeBSD__) && (__FreeBSD__ > 8) #include +#else +#include +#endif #include "pathnames.h" @@ -1534,17 +1542,37 @@ static void wallmsg(struct filed *f, struct iovec *iov, const int iovlen) { static int reenter; /* avoid calling ourselves */ - struct utmpx *ut; int i; const char *p; if (reenter++) return; +#if defined(__FreeBSD__) && (__FreeBSD__ > 8) + struct utmpx *ut; + setutxent(); /* NOSTRICT */ while ((ut = getutxent()) != NULL) { if (ut->ut_type != USER_PROCESS) continue; +#else + struct utmp ut_, *ut = &ut_; + FILE *uf; + char line[sizeof(ut_.ut_line) + 1]; + + if ((uf = fopen(_PATH_UTMP, "r")) == NULL) { + logerror(_PATH_UTMP); + reenter = 0; + return; + } + /* NOSTRICT */ + while (fread((char *)ut, sizeof(ut_), 1, uf) == 1) { + if (ut->ut_name[0] == '\0') + continue; + /* We must use strncpy since ut_* may not be NUL terminated. */ + strncpy(line, ut->ut_line, sizeof(line) - 1); + line[sizeof(line) - 1] = '\0'; +#endif if (f->f_type == F_WALL) { if ((p = ttymsg(iov, iovlen, ut->ut_line, TTYMSGTIME)) != NULL) { @@ -1557,7 +1585,11 @@ wallmsg(struct filed *f, struct iovec *iov, const int for (i = 0; i < MAXUNAMES; i++) { if (!f->f_un.f_uname[i][0]) break; +#if defined(__FreeBSD__) && (__FreeBSD__ > 8) if (!strcmp(f->f_un.f_uname[i], ut->ut_user)) { +#else + if (!strncmp(f->f_un.f_uname[i], ut->ut_name, UT_NAMESIZE)) { +#endif if ((p = ttymsg(iov, iovlen, ut->ut_line, TTYMSGTIME)) != NULL) { errno = 0; /* already in msg */ @@ -1567,7 +1599,11 @@ wallmsg(struct filed *f, struct iovec *iov, const int } } } +#if defined(__FreeBSD__) && (__FreeBSD__ > 8) endutxent(); +#else + fclose(uf); +#endif reenter = 0; }