From f12a1995e42d098217fef22cba6e7158ed76e635 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Sun, 28 Feb 2010 18:33:08 +0100 Subject: bugfix: fixed problem that caused compilation on FreeBSD 9.0 to fail. bugtracker: http://bugzilla.adiscon.com/show_bug.cgi?id=181 Thanks to Christiano for reporting. --- tools/omusrmsg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools/omusrmsg.c') diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index 499a11dd..fe3fb4d4 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -50,7 +50,11 @@ #include #include #include -#include +#ifdef HAVE_UTMP_X_H +# include +#else +# include +#endif #include #include #include -- cgit From 7b654060b624d976116d959f4cf799f940c00f0a Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 1 Mar 2010 07:57:24 +0100 Subject: fixed typo that (could have) caused compilation fail under FreeBSD Note that I now also prefer to use utmp.h if it is present - this seems to be much better under Linux. --- tools/omusrmsg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/omusrmsg.c') diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index fe3fb4d4..a89297d7 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -50,10 +50,10 @@ #include #include #include -#ifdef HAVE_UTMP_X_H -# include -#else +#ifdef HAVE_UTMP_H # include +#else +# include #endif #include #include -- cgit From d7755dd3dc5a653adff79a83b6115f872509b3d9 Mon Sep 17 00:00:00 2001 From: Cristiano Date: Tue, 2 Mar 2010 07:37:48 +0100 Subject: solved compile problems on FreeBSD 9.0 (those caused by utmpx.h) Signed-off-by: Rainer Gerhards --- tools/omusrmsg.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'tools/omusrmsg.c') 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 #ifdef HAVE_UTMP_H # include +# define STRUCTUTMP struct utmp #else # include +# 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 #include @@ -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? */ -- cgit From 4c060687cf877e4c7faee02f33c219e5f6c8f8f6 Mon Sep 17 00:00:00 2001 From: Cristiano Date: Thu, 4 Mar 2010 09:51:28 +0100 Subject: streamlined BSD utmpx.h patch Signed-off-by: Rainer Gerhards --- tools/omusrmsg.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'tools/omusrmsg.c') diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index 9279028c..e788a006 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -53,12 +53,11 @@ #ifdef HAVE_UTMP_H # include # define STRUCTUTMP struct utmp +# define UTNAME ut_name #else # include -# 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 +# define UTNAME ut_user #endif #include #include @@ -133,6 +132,12 @@ ENDdbgPrintInstInfo * need! rgerhards 2005-03-18 */ #ifdef OS_BSD +/* Since version 900007, FreeBSD has a POSIX compliant */ +#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) { @@ -158,6 +163,7 @@ void endutent(void) fclose(BSD_uf); BSD_uf = NULL; } +#endif /* if defined(__FreeBSD__) */ #endif /* #ifdef OS_BSD */ @@ -196,21 +202,13 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) while((uptr = getutent())) { memcpy(&ut, uptr, sizeof(ut)); /* is this slot used? */ - - char UTNAME[MAXUNAMES]; -#ifdef HAVE_UTMP_H - strcpy(UTNAME,ut.ut_name); -#else - strcpy(UTNAME,ut.ut_user); -#endif - - if(UTNAME[0] == '\0') + if(ut.UTNAME[0] == '\0') continue; #ifndef OS_BSD if(ut.ut_type != USER_PROCESS) continue; #endif - if(!(strncmp (UTNAME,"LOGIN", 6))) /* paranoia */ + if(!(strncmp (ut.UTNAME,"LOGIN", 6))) /* paranoia */ continue; /* should we send the message to this user? */ @@ -220,7 +218,7 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) i = MAXUNAMES; break; } - if(strncmp(pData->uname[i], UTNAME, UNAMESZ) == 0) + if(strncmp(pData->uname[i], ut.UTNAME, UNAMESZ) == 0) break; } if(i == MAXUNAMES) /* user not found? */ -- cgit