Fix utmpx related bug. Built w/o eror but failed to function.

This commit is contained in:
cy
2012-05-02 03:20:35 +00:00
parent eaf8442b96
commit d60c48b890
7 changed files with 154 additions and 194 deletions
+1 -9
View File
@@ -7,7 +7,7 @@
PORTNAME= doinkd
PORTVERSION= 0.01
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= sysutils
MASTER_SITES= SF/idled/${PORTNAME}/${PORTVERSION}/
@@ -25,14 +25,6 @@ PLIST_DIRSTRY= etc/doinkd
.include <bsd.port.pre.mk>
.if ${OSVERSION} > 900006
EXTRA_PATCHES= ${PATCHDIR}/utmpx-Makefile \
${PATCHDIR}/utmpx-doinkd.h \
${PATCHDIR}/utmpx-doinkd.c
.else
EXTRA_PATCHES= ${PATCHDIR}/utmp-Makefile
.endif
post-extract:
(cd ${WRKSRC}; make clean)
+130 -2
View File
@@ -1,6 +1,134 @@
--- doinkd.c.orig 2006-05-30 00:17:44.000000000 -0700
+++ doinkd.c 2012-01-04 12:28:11.183448967 -0800
@@ -651,7 +651,7 @@
+++ doinkd.c 2012-05-01 20:13:50.992115867 -0700
@@ -2,6 +2,7 @@
* Main doinkd routine contols everything.
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <signal.h>
@@ -147,6 +148,7 @@
FILE *logfd;
#ifdef HAVE_UTMPX
struct utmpx utmpbuf;
+ struct utmpx *utmp_ptr;
#else
struct utmp utmpbuf;
#endif
@@ -226,9 +228,11 @@
(void) signal (SIGQUIT, SIG_IGN);
/* Trap some error ones */
+#if 0
(void) signal (SIGILL, core_time);
(void) signal (SIGBUS, core_time);
(void) signal (SIGSEGV, core_time);
+#endif
#if defined(SIGTTOU) && defined(SIGTSTP)
(void) signal (SIGTTOU, SIG_IGN);
@@ -285,11 +289,15 @@
(void) time (&tempus);
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ setutxent();
+#else
if ((utmpfd = open (UTMP_FILE, O_RDONLY, 0)) == SYSERROR)
{
logfile ("%19.19s: Cannot open %s.",ctime(&tempus),UTMP_FILE);
exit (1);
}
+#endif
/* Set our nextcheck time to the max (sleeptime), though it may
* be lowered in the coming for loop so that an idle tty gets
@@ -318,11 +326,15 @@
* examine him again.
*/
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ for (utmptr = 0, userptr = 0; utmp_ptr = getutxent();)
+#else
#ifdef HAVE_UTMPX
for (utmptr = 0, userptr = 0; (res = read (utmpfd, (char *) &utmpbuf, sizeof (struct utmpx))) > 0;)
#else
for (utmptr = 0, userptr = 0; (res = read (utmpfd, (char *) &utmpbuf, sizeof (struct utmp))) > 0;)
#endif
+#endif __FreeBSD_version
{
if (utmptr >= MAXUSERS)
{
@@ -330,6 +342,9 @@
break;
}
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ memcpy(&utmpbuf,utmp_ptr,sizeof(utmpbuf));
+#else
#ifdef HAVE_UTMPX
if (res != sizeof (struct utmpx))
#else
@@ -339,6 +354,7 @@
logfile ("Error reading utmp file, continuing.");
break;
}
+#endif
(void) time (&tempus);
@@ -347,24 +363,36 @@
if (strcmp(utmpbuf.ut_line,XDM_DEV) == 0)
{
/* This is the console. Is there a real name attached? */
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ if (strlen(utmpbuf.ut_user) > 0)
+#else
if (strlen(utmpbuf.ut_name) > 0)
+#endif
isConsole = TRUE; /* Yes, use it */
else
strcpy(console_user,""); /* No, clear the console user */
}
#endif
-#ifdef SYSV
+#if defined(SYSV) || (defined(__FreeBSD_version) && __FreeBSD_version >= 900007)
if (utmpbuf.ut_type == USER_PROCESS || isConsole)
#else /* SYSV */
if (utmpbuf.ut_name[0] != NULL || isConsole)
#endif /* SYSV */
{
user = &users[utmptr];
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ (void) strncpy (tmpname, utmpbuf.ut_user, NAMELEN);
+#else
(void) strncpy (tmpname, utmpbuf.ut_name, NAMELEN);
+#endif
tmpname[NAMELEN] = 0;
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ if (!strcmp (user->uid, tmpname) && user->time_on == utmpbuf.ut_tv.tv_sec)
+#else
if (!strcmp (user->uid, tmpname) && user->time_on == utmpbuf.ut_xtime)
+#endif
{
if (new)
setlimits (utmptr);
@@ -414,7 +442,11 @@
logfile ("Error: could not get info on supposed user %s.",user->uid);
else
getgroups_func (pswd->pw_name, user->groups, pswd->pw_gid);
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+ user->time_on = utmpbuf.ut_tv.tv_sec;
+#else
user->time_on = utmpbuf.ut_xtime;
+#endif
setlimits (utmptr);
user->next = tempus;
chk_session_refuse(user);
@@ -651,7 +683,7 @@
int grpcnt = 0;
int tgrpcnt = 0;
+23
View File
@@ -0,0 +1,23 @@
--- doinkd.h.orig 2006-05-29 23:52:32.000000000 -0700
+++ doinkd.h 2012-05-01 15:58:36.200762985 -0700
@@ -1,11 +1,20 @@
#include <sys/types.h>
#include <stdio.h>
#include <sys/param.h>
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#define HAVE_UTMPX
+#else
#include <utmp.h>
+#endif
+
+#if defined(__FreeBSD_version) && __FreeBSD_version < 900007
#define qelem qelem_sys /* Work around to use our own qelem below */
+#endif
#include <stdlib.h>
+#if defined(__FreeBSD_version) && __FreeBSD_version < 900007
#undef qelem
+#endif
#ifdef HAVE_UTMPX
#include <utmpx.h>
-70
View File
@@ -1,70 +0,0 @@
--- Makefile.orig 2006-05-30 00:19:28.000000000 -0700
+++ Makefile 2010-08-27 12:42:08.661284827 -0700
@@ -2,8 +2,8 @@
#
# C compiler flags
-CC = cc
-RM = rm
+CC ?= cc
+RM ?= rm
INCLUDE =
######################################################################
@@ -81,7 +81,7 @@
######################################################################
# UnixWare 7 -- SVR5 MP
#DEFS = -DSYSV -DHAVE_PROC_FS -DUTMPPID -DHAVE_SETSID -DHAVE_UTMPX -DUTMPHOST -DUNIXWARE
-DEFS = -DSYSV -DPS_HACK -DRUDE_KILL -DHAVE_SETSID -DHAVE_UTMPX -DUTMPHOST -DUNIXWARE
+DEFS = -DPS_HACK -DRUDE_KILL -DHAVE_SETSID -DUTMPHOST
SPECLIBS =
INSTTYPE = install4
@@ -193,26 +193,26 @@
# You will need to delete parse.c before compiling! You can either
# do so by hand, or do a 'make clean' followed by the normal 'make'.
#DEFS += -O -m486
-#DEFS += -DBSD_OS2 -DHAVE_SETSID -DHAVE_YYRESTART -DPS_HACK
+DEFS += -DBSD_OS2 -DHAVE_SETSID -DHAVE_YYRESTART -DPS_HACK
#DEFS += -DPROC_SEARCH_1
#SPECLIBS = -lkvm
-#INSTTYPE = install1a
+INSTTYPE = install1a
#
-#DEST = /usr/local/sbin
-#CFDEST = /etc/doinkd
-#MDEST = /usr/local/man
-#LOGDEST = /var/log
+DEST = ${PREFIX}/sbin
+CFDEST = ${PREFIX}/etc/doinkd
+MDEST = ${PREFIX}/man
+LOGDEST = /var/log
#
#OWNER = root
#CFOWNER = root
-#MOWNER = man
+MOWNER = man
#
-#GROUP = daemon
-#CFGROUP = daemon
+GROUP = daemon
+CFGROUP = daemon
#
-#MODE = 750
-#CFMODE = 664
-#MMODE = 444
+MODE = 750
+CFMODE = 664
+MMODE = 444
######################################################################
######################################################################
@@ -456,7 +452,7 @@
# HERE are the big CFLAGS
# Add -g if you want debugging
# Add -O or whatever variant for optimization
-CFLAGS = ${DEFS} ${DEBUG} -DCONFIG=\"${CONFIG}\" -DLOGFILE=\"${LOGFILE}\" ${INCLUDE}
+CFLAGS+= ${DEFS} ${DEBUG} -DCONFIG=\"${CONFIG}\" -DLOGFILE=\"${LOGFILE}\" ${INCLUDE}
# For HP's ANSI C compiler (use -g instead of +O3 for debugging)
# CFLAGS = +O3 -Aa -D_HPUX_SOURCE ${DEFS} ${DEBUG} -DCONFIG=\"${CONFIG}\" -DLOGFILE=\"${LOGFILE}\" ${INCLUDE}
-70
View File
@@ -1,70 +0,0 @@
--- Makefile.orig 2006-05-30 00:19:28.000000000 -0700
+++ Makefile 2010-11-01 16:40:53.000000000 -0800
@@ -2,8 +2,8 @@
#
# C compiler flags
-CC = cc
-RM = rm
+CC ?= cc
+RM ?= rm
INCLUDE =
######################################################################
@@ -81,7 +81,7 @@
######################################################################
# UnixWare 7 -- SVR5 MP
#DEFS = -DSYSV -DHAVE_PROC_FS -DUTMPPID -DHAVE_SETSID -DHAVE_UTMPX -DUTMPHOST -DUNIXWARE
-DEFS = -DSYSV -DPS_HACK -DRUDE_KILL -DHAVE_SETSID -DHAVE_UTMPX -DUTMPHOST -DUNIXWARE
+DEFS = -DPS_HACK -DRUDE_KILL -DHAVE_SETSID -DHAVE_UTMPX -DUTMPHOST
SPECLIBS =
INSTTYPE = install4
@@ -193,26 +193,26 @@
# You will need to delete parse.c before compiling! You can either
# do so by hand, or do a 'make clean' followed by the normal 'make'.
#DEFS += -O -m486
-#DEFS += -DBSD_OS2 -DHAVE_SETSID -DHAVE_YYRESTART -DPS_HACK
+DEFS += -DBSD_OS2 -DHAVE_SETSID -DHAVE_YYRESTART -DPS_HACK
#DEFS += -DPROC_SEARCH_1
#SPECLIBS = -lkvm
-#INSTTYPE = install1a
+INSTTYPE = install1a
#
-#DEST = /usr/local/sbin
-#CFDEST = /etc/doinkd
-#MDEST = /usr/local/man
-#LOGDEST = /var/log
+DEST = ${PREFIX}/sbin
+CFDEST = ${PREFIX}/etc/doinkd
+MDEST = ${PREFIX}/man
+LOGDEST = /var/log
#
#OWNER = root
#CFOWNER = root
-#MOWNER = man
+MOWNER = man
#
-#GROUP = daemon
-#CFGROUP = daemon
+GROUP = daemon
+CFGROUP = daemon
#
-#MODE = 750
-#CFMODE = 664
-#MMODE = 444
+MODE = 750
+CFMODE = 664
+MMODE = 444
######################################################################
######################################################################
@@ -456,7 +456,7 @@
# HERE are the big CFLAGS
# Add -g if you want debugging
# Add -O or whatever variant for optimization
-CFLAGS = ${DEFS} ${DEBUG} -DCONFIG=\"${CONFIG}\" -DLOGFILE=\"${LOGFILE}\" ${INCLUDE}
+CFLAGS = ${DEFS} ${DEBUG} -DCONFIG=\"${CONFIG}\" -DLOGFILE=\"${LOGFILE}\" ${INCLUDE} -DHAVE_UTMPX -DSYSV
# For HP's ANSI C compiler (use -g instead of +O3 for debugging)
# CFLAGS = +O3 -Aa -D_HPUX_SOURCE ${DEFS} ${DEBUG} -DCONFIG=\"${CONFIG}\" -DLOGFILE=\"${LOGFILE}\" ${INCLUDE}
-33
View File
@@ -1,33 +0,0 @@
--- doinkd.c.orig 2010-01-25 16:06:48.000000000 -0800
+++ doinkd.c 2010-01-25 16:09:39.000000000 -0800
@@ -335,7 +335,7 @@
if (strcmp(utmpbuf.ut_line,XDM_DEV) == 0)
{
/* This is the console. Is there a real name attached? */
- if (strlen(utmpbuf.ut_name) > 0)
+ if (strlen(utmpbuf.ut_user) > 0)
isConsole = TRUE; /* Yes, use it */
else
strcpy(console_user,""); /* No, clear the console user */
@@ -349,10 +349,10 @@
#endif /* SYSV */
{
user = &users[utmptr];
- (void) strncpy (tmpname, utmpbuf.ut_name, NAMELEN);
+ (void) strncpy (tmpname, utmpbuf.ut_user, NAMELEN);
tmpname[NAMELEN] = 0;
- if (!strcmp (user->uid, tmpname) && user->time_on == utmpbuf.ut_xtime)
+ if (!strcmp (user->uid, tmpname) && user->time_on == utmpbuf.ut_tv.tv_sec)
{
if (new)
setlimits (utmptr);
@@ -402,7 +402,7 @@
logfile ("Error: could not get info on supposed user %s.",user->uid);
else
getgroups_func (pswd->pw_name, user->groups, pswd->pw_gid);
- user->time_on = utmpbuf.ut_xtime;
+ user->time_on = utmpbuf.ut_tv.tv_sec;
setlimits (utmptr);
user->next = tempus;
chk_session_refuse(user);
-10
View File
@@ -1,10 +0,0 @@
--- doinkd.h.orig 2010-01-25 16:07:42.000000000 -0800
+++ doinkd.h 2010-01-25 16:07:50.000000000 -0800
@@ -1,7 +1,6 @@
#include <sys/types.h>
#include <stdio.h>
#include <sys/param.h>
-#include <utmp.h>
#define qelem qelem_sys /* Work around to use our own qelem below */
#include <stdlib.h>