Here you go...
There are a bunch of #ifdef's, so it may very well be a system specific thing.
j----- k-----
int log_wtmp(char *line, const char *name, const char *host, p_in_addr_t *ip)
{
struct stat buf;
struct utmp ut;
int res = 0;
static int fd = -1;
#if (defined(SVR4) || defined(__SVR4)) && \
!(defined(LINUX) || defined(__hpux) || defined (_AIX))
/* This "auxilliary" utmp doesn't exist under linux. */
#ifdef __sparcv9
struct futmpx utx;
time_t t;
#else
struct utmpx utx;
#endif
static int fdx = -1;
if (fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
return -1;
}
/* Unfortunately, utmp string fields are terminated by '\0' if they are
* shorter than the size of the field, but if they are exactly the size of
* the field they don't have to be terminated at all. Frankly, this sucks.
* Insane if you ask me. Unless there's massive uproar, I prefer to err on
* the side of caution and always null-terminate our strings.
*/
if (fstat(fdx,&buf) == 0) {
memset(&utx,0,sizeof(utx));
sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
sstrncpy(utx.ut_id, "ftp",sizeof(utx.ut_user));
sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
utx.ut_syslen = strlen(utx.ut_host)+1;
utx.ut_pid = getpid();
#ifdef __sparcv9
time(&t);
utx.ut_tv.tv_sec = (time32_t)t;
#else
time(&utx.ut_tv.tv_sec);
#endif
if (*name)
utx.ut_type = USER_PROCESS;
else
utx.ut_type = DEAD_PROCESS;
#ifdef HAVE_UT_UT_EXIT
utx.ut_exit.e_termination = 0;
utx.ut_exit.e_exit = 0;
#endif /* HAVE_UT_UT_EXIT */
if (write(fdx, (char *)&utx,sizeof(utx)) != sizeof(utx))
ftruncate(fdx, buf.st_size);
} else {
log_debug(DEBUG0, "%s fstat(): %s",WTMPX_FILE,strerror(errno));
res = -1;
}
#else /* Non-SVR4 systems */
if (fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
return -1;
}
if (fstat(fd,&buf) == 0) {
memset(&ut,0,sizeof(ut));
#ifdef HAVE_UTMAXTYPE
#ifdef LINUX
if (ip)
memcpy(&ut.ut_addr,ip,sizeof(ut.ut_addr));
#else
sstrncpy(ut.ut_id, "ftp",sizeof(ut.ut_id));
#ifdef HAVE_UT_UT_EXIT
ut.ut_exit.e_termination = 0;
ut.ut_exit.e_exit = 0;
#endif /* HAVE_UT_UT_EXIT */
#endif
sstrncpy(ut.ut_line,line,sizeof(ut.ut_line));
if (name && *name)
sstrncpy(ut.ut_user,name,sizeof(ut.ut_user));
ut.ut_pid = getpid();
if (name && *name)
ut.ut_type = USER_PROCESS;
else
ut.ut_type = DEAD_PROCESS;
#else /* !HAVE_UTMAXTYPE */
sstrncpy(ut.ut_line,line,sizeof(ut.ut_line));
if (name && *name)
sstrncpy(ut.ut_name,name,sizeof(ut.ut_name));
#endif /* HAVE_UTMAXTYPE */
#ifdef HAVE_UT_UT_HOST
if (host && *host)
sstrncpy(ut.ut_host,host,sizeof(ut.ut_host));
#endif /* HAVE_UT_UT_HOST */
time(&ut.ut_time);
if (write(fd, (char *)&ut,sizeof(ut)) != sizeof(ut))
ftruncate(fd,buf.st_size);
} else {
log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
res = -1;
}
#endif /* SVR4 */
return res;
}
On Wednesday 21 April 2004 08:19 am, Arthur Corliss wrote:
> On Tue, 20 Apr 2004, Joshua Kugler wrote:
> > In the SRPM there is a file entitled: proftpd-1.2.8-biarch-utmp.patch.bz2
> > which contains:
> >
> > --- proftpd-1.2.8/src/log.c.biarch-utmp 2003-02-12 20:03:36.000000000
> > +0100 +++ proftpd-1.2.8/src/log.c 2003-04-07 02:53:11.000000000 +0200
> > @@ -171,7 +171,7 @@ int log_wtmp(char *line, const char *nam
> > time(&t);
> > utx.ut_tv.tv_sec = (time32_t)t;
> > #else
> > - time(&utx.ut_tv.tv_sec);
> > + utx.ut_tv.tv_sec = time(NULL);
> > #endif
> > if (*name)
> > utx.ut_type = USER_PROCESS;
> > @@ -227,7 +227,7 @@ int log_wtmp(char *line, const char *nam
> > sstrncpy(ut.ut_host,host,sizeof(ut.ut_host));
> > #endif /* HAVE_UT_UT_HOST */
> >
> > - time(&ut.ut_time);
> > + ut.ut_time = time(NULL);
> > if (write(fd, (char *)&ut,sizeof(ut)) != sizeof(ut))
> > ftruncate(fd,buf.st_size);
> > } else {
> >
> > So it looks like they fix it, but I didn't take a look at your code, so I
> > don't know if it is the same thing. Maybe they did send the patch to
> > ProFTPd, and it wasn't accepted, or didn't solve the problem in the way
> > they wanted to.
>
> Nope, that doesn't fix it. You can see the only two lines they're changing
> have to do with time fields. Of course, now I need to look at that and see
> if it's still broken in 1.2.9, or whether the patch is logged in bugzilla.
>
> :-P Bizarre. Send me the text of the log_wtmp function from your log.c,
>
> would you? Patched or not.
>
> --Arthur Corliss
> Bolverk's Lair -- http://arthur.corlissfamily.org/
> Digital Mages -- http://www.digitalmages.com/
> "Live Free or Die, the Only Way to Live" -- NH State Motto
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
-- Joshua Kugler Assistant Systems Administrator UAF Department of Mathematical Sciences UAF LUG President --------- To unsubscribe, send email to <aklug-request@aklug.org> with 'unsubscribe' in the message body.Received on Wed Apr 21 13:14:54 2004
This archive was generated by hypermail 2.1.8 : Wed Apr 21 2004 - 13:14:55 AKDT