summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristiano <cristianorolim@hotmail.com>2010-03-02 07:37:48 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-02 07:37:48 +0100
commitd7755dd3dc5a653adff79a83b6115f872509b3d9 (patch)
treeee0e58e758a93747efd1c0d947d828001a0dba97
parentaf6c73439ecef2446c5fae0d774a8c093e2a3747 (diff)
downloadrsyslog-d7755dd3dc5a653adff79a83b6115f872509b3d9.tar.gz
rsyslog-d7755dd3dc5a653adff79a83b6115f872509b3d9.tar.xz
rsyslog-d7755dd3dc5a653adff79a83b6115f872509b3d9.zip
solved compile problems on FreeBSD 9.0 (those caused by utmpx.h)
Signed-off-by: Rainer Gerhards <rgerhards@adiscon.com>
-rw-r--r--tools/omusrmsg.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c
index a89297d7..9279028c 100644
--- a/tools/omusrmsg.c
+++ b/tools/omusrmsg.c
@@ -52,8 +52,13 @@
#include <sys/param.h>
#ifdef HAVE_UTMP_H
# include <utmp.h>
+# define STRUCTUTMP struct utmp
#else
# include <utmpx.h>
+# define _PATH_UTMP "/var/run/utx.active"
+# define _PATH_WTMP "/var/log/utx.log"
+# define _PATH_LASTLOG "/var/log/utx.lastlogin"
+# define STRUCTUTMP struct utmpx
#endif
#include <unistd.h>
#include <sys/uio.h>
@@ -138,9 +143,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;
@@ -177,8 +182,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 +196,21 @@ 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')
+
+ char UTNAME[MAXUNAMES];
+#ifdef HAVE_UTMP_H
+ strcpy(UTNAME,ut.ut_name);
+#else
+ strcpy(UTNAME,ut.ut_user);
+#endif
+
+ if(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 (UTNAME,"LOGIN", 6))) /* paranoia */
continue;
/* should we send the message to this user? */
@@ -207,7 +220,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], UTNAME, UNAMESZ) == 0)
break;
}
if(i == MAXUNAMES) /* user not found? */