diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-04-12 09:10:19 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-04-12 09:10:19 +0200 |
commit | 25bc3b2e30deaee00fcf183e885378a0d64ae94c (patch) | |
tree | 9003917ec023600f4e2916a5907d5a35856b928e /tools/omusrmsg.c | |
parent | 62e00d7a1c1d0301d50e7a28cb84563d61410ecd (diff) | |
parent | 5ef852f4a3f030f61254a963b0d2dca290933e3c (diff) | |
download | rsyslog-25bc3b2e30deaee00fcf183e885378a0d64ae94c.tar.gz rsyslog-25bc3b2e30deaee00fcf183e885378a0d64ae94c.tar.xz rsyslog-25bc3b2e30deaee00fcf183e885378a0d64ae94c.zip |
Merge branch 'v4-stable-solaris' into v4-devel
Conflicts:
ChangeLog
configure.ac
doc/manual.html
tools/omfile.c
tools/syslogd.c
Diffstat (limited to 'tools/omusrmsg.c')
-rw-r--r-- | tools/omusrmsg.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index 499a11dd..e788a006 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -50,7 +50,15 @@ #include <assert.h> #include <signal.h> #include <sys/param.h> -#include <utmp.h> +#ifdef HAVE_UTMP_H +# include <utmp.h> +# define STRUCTUTMP struct utmp +# define UTNAME ut_name +#else +# include <utmpx.h> +# define STRUCTUTMP struct utmpx +# define UTNAME ut_user +#endif #include <unistd.h> #include <sys/uio.h> #include <sys/stat.h> @@ -124,6 +132,12 @@ ENDdbgPrintInstInfo * need! rgerhards 2005-03-18 */ #ifdef OS_BSD +/* Since version 900007, FreeBSD has a POSIX compliant <utmpx.h> */ +#if defined(__FreeBSD__) && (__FreeBSD_version >= 900007) +# define setutent(void) setutxent(void) +# define getutent(void) getutxent(void) +# define endutent(void) endutxent(void) +#else static FILE *BSD_uf = NULL; void setutent(void) { @@ -134,9 +148,9 @@ void setutent(void) } } -struct utmp* getutent(void) +STRUCTUTMP* getutent(void) { - static struct utmp st_utmp; + static STRUCTUTMP st_utmp; if(fread((char *)&st_utmp, sizeof(st_utmp), 1, BSD_uf) != 1) return NULL; @@ -149,6 +163,7 @@ void endutent(void) fclose(BSD_uf); BSD_uf = NULL; } +#endif /* if defined(__FreeBSD__) */ #endif /* #ifdef OS_BSD */ @@ -173,8 +188,8 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) int errnoSave; int ttyf; int wrRet; - struct utmp ut; - struct utmp *uptr; + STRUCTUTMP ut; + STRUCTUTMP *uptr; struct stat statb; DEFiRet; @@ -187,13 +202,13 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) while((uptr = getutent())) { memcpy(&ut, uptr, sizeof(ut)); /* is this slot used? */ - if(ut.ut_name[0] == '\0') + if(ut.UTNAME[0] == '\0') continue; #ifndef OS_BSD if(ut.ut_type != USER_PROCESS) continue; #endif - if(!(strncmp (ut.ut_name,"LOGIN", 6))) /* paranoia */ + if(!(strncmp (ut.UTNAME,"LOGIN", 6))) /* paranoia */ continue; /* should we send the message to this user? */ @@ -203,7 +218,7 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) i = MAXUNAMES; break; } - if(strncmp(pData->uname[i], ut.ut_name, UNAMESZ) == 0) + if(strncmp(pData->uname[i], ut.UTNAME, UNAMESZ) == 0) break; } if(i == MAXUNAMES) /* user not found? */ |