diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-09 14:28:30 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-09 14:28:30 +0100 |
commit | c802afb7e0fc5e2c87af24e12bf63e4a0ba7688c (patch) | |
tree | 107991afae384af32c95be306c86f387ea67083b /tools/omusrmsg.c | |
parent | 81c9cf86267fb0ec1156e578439d09499c97e80f (diff) | |
parent | de7726cbf0957384cc9261ac47d6bf65906739b5 (diff) | |
download | rsyslog-c802afb7e0fc5e2c87af24e12bf63e4a0ba7688c.tar.gz rsyslog-c802afb7e0fc5e2c87af24e12bf63e4a0ba7688c.tar.xz rsyslog-c802afb7e0fc5e2c87af24e12bf63e4a0ba7688c.zip |
Merge branch 'v5-stable'
Conflicts:
ChangeLog
configure.ac
doc/manual.html
doc/property_replacer.html
runtime/datetime.h
Diffstat (limited to 'tools/omusrmsg.c')
-rw-r--r-- | tools/omusrmsg.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index a89297d7..e788a006 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -52,8 +52,12 @@ #include <sys/param.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> @@ -128,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) { @@ -138,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; @@ -153,6 +163,7 @@ void endutent(void) fclose(BSD_uf); BSD_uf = NULL; } +#endif /* if defined(__FreeBSD__) */ #endif /* #ifdef OS_BSD */ @@ -177,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; @@ -191,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? */ @@ -207,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? */ |