[11593] in Athena Bugs
solaris /usr/athena/bin/finger local times wrong (and fix)
daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Sat Jan 8 11:34:36 1994
From: epeisach@MIT.EDU
Date: Sat, 8 Jan 1994 11:34:32 -0500
To: bugs@MIT.EDU
It returns bogus information for when a user logged in....
Script started on Sat Jan 08 11:27:23 1994
sneetch% /usr/athena/bin/finger epeisach
Local:
Login name: epeisach In real life: Ezra Peisach
Nickname: E-Z
Office: E40-318, x3-0119 Home phone: 891-3265
Directory: /mit/epeisach Shell: /bin/csh
On since Dec 31 19:00:00 on pts/0 <========
No Plan.
<extra removed>
With some simple modifications to finger.c I get:
sneetch% ./finger epeisach
Local:
Login name: epeisach In real life: Ezra Peisach
Nickname: E-Z
Office: E40-318, x3-0119 Home phone: 891-3265
Directory: /mit/epeisach Shell: /bin/csh
On since Jan 8 11:19:59 on pts/0 <=======
The changes I have made:
a) #endif foo replaced with #endif /*foo*/ for ansi compilers
b) Better handling of utmp and wtmp files when defined in utmp.h
c) On solaris where we are using the utmpx.h file define:
WTMP_FILE and UTMP_FILE properly (they were actually wrong)
d) On SOLARIS define ut_time as ut_xtime (which in itself is a macro)
Backout alot of the ifdef on SOLARIS p->loginat not being set.
which does the right thing.
e) Under POSIX, use time_t instead of long.
Enjoy....
(Lets see if this can get into the net release....)
*** 1.1 1994/01/08 15:59:38
--- finger.c 1994/01/08 16:25:58
***************
*** 8,14 ****
#ifndef lint
static char *rcsid_finger_c = "$Id: finger.c,v 1.1 1994/01/08 15:59:38 epeisach Exp epeisach $";
! #endif lint
/*
* Copyright (c) 1980 Regents of the University of California.
--- 8,14 ----
#ifndef lint
static char *rcsid_finger_c = "$Id: finger.c,v 1.1 1994/01/08 15:59:38 epeisach Exp epeisach $";
! #endif /*lint*/
/*
* Copyright (c) 1980 Regents of the University of California.
***************
*** 21,32 ****
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n";
! #endif not lint
#ifndef lint
static char sccsid[] = "@(#)finger.c 5.8 (Berkeley) 3/13/86";
! #endif not lint
/*
* This is a finger program. It prints out useful information about
--- 21,32 ----
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n";
! #endif /*not lint*/
#ifndef lint
static char sccsid[] = "@(#)finger.c 5.8 (Berkeley) 3/13/86";
! #endif /*not lint*/
/*
* This is a finger program. It prints out useful information about
***************
*** 132,140 ****
char tty[LMAX + 1]; /* null terminated tty line */
char host[BUFSIZ]; /* null terminated remote host name */
int loginout; /* 0 means login time, 1 logout */
long loginat; /* time of (last) login/out */
- char *logintime; /* pointer to string showing logintime */
long idletime; /* how long idle (if logged in) */
char *realname; /* pointer to full name */
char *nickname; /* pointer to nickname */
char *office; /* pointer to office name */
--- 132,145 ----
char tty[LMAX + 1]; /* null terminated tty line */
char host[BUFSIZ]; /* null terminated remote host name */
int loginout; /* 0 means login time, 1 logout */
+ #ifdef POSIX
+ time_t loginat; /* time of (last) login/out */
+ time_t idletime; /* how long idle (if logged in) */
+ #else
long loginat; /* time of (last) login/out */
long idletime; /* how long idle (if logged in) */
+ #endif
+ char *logintime; /* pointer to string showing logintime */
char *realname; /* pointer to full name */
char *nickname; /* pointer to nickname */
char *office; /* pointer to office name */
***************
*** 151,161 ****
char LASTLOG[] = "/usr/adm/lastlog"; /* last login info */
#ifdef SOLARIS
! char USERLOG[] = "/etc/utmpx"; /* who is logged in */
#else
char USERLOG[] = "/etc/utmp"; /* who is logged in */
#endif
char ACCTLOG[] = "/usr/adm/wtmp"; /* Accounting file */
char PLAN[] = "/.plan"; /* what plan file is */
char PROJ[] = "/.project"; /* what project file */
char MM[] = "%MENTION-MAIL%\n"; /* if present, check for mail */
--- 156,178 ----
char LASTLOG[] = "/usr/adm/lastlog"; /* last login info */
#ifdef SOLARIS
! #undef UTMP_FILE
! #undef WTMPX_FILE
! #define UTMP_FILE UTMPX_FILE
! #define WTMPX_FILE UTMPX_FILE
! #define ut_time ut_xtime
! #endif
!
! #ifdef UTMP_FILE
! char USERLOG[] = UTMP_FILE; /* who is logged in */
#else
char USERLOG[] = "/etc/utmp"; /* who is logged in */
#endif
+ #ifdef WTMP_FILE
+ char ACCTLOG[] = WTMP_FILE; /* Accounting file */
+ #else
char ACCTLOG[] = "/usr/adm/wtmp"; /* Accounting file */
+ #endif
char PLAN[] = "/.plan"; /* what plan file is */
char PROJ[] = "/.project"; /* what project file */
char MM[] = "%MENTION-MAIL%\n"; /* if present, check for mail */
***************
*** 183,189 ****
--- 200,210 ----
/* !#$%!@#$! Bezerkeley non-initializations !!! */
struct person *person1 = (struct person *) NULL; /* list of people */
struct person *person2 = (struct person *) NULL; /* 2nd list of people */
+ #ifdef POSIX
+ time_t tloc; /* current time */
+ #else
long tloc; /* current time */
+ #endif
char ttnames[MAXTTYS][LMAX]; /* TTY names */
long logouts[MAXTTYS]; /* Logout times */
***************
*** 195,201 ****
--- 216,224 ----
char *malloc();
char *ctime();
+ #ifndef POSIX
long time();
+ #endif
/*ARGSUSED*/
main(argc, argv)
***************
*** 309,317 ****
bcopy(user.ut_host, p->host, HMAX);
p->host[HMAX] = 0;
p->loginout = 0;
- #ifndef SOLARIS
p->loginat = user.ut_time;
- #endif
p->pwd = 0;
p->loggedin = 1;
p->zlocation = 0;
--- 332,338 ----
***************
*** 368,376 ****
p->tty[0] = q->tty[0] = '\0';
p->host[0] = q->host[0] = '\0';
p->loginout = q->loginout = 0;
- #ifndef SOLARIS
p->loginat = q->loginat = 0;
- #endif
p->logintime = q->logintime = (char *) NULL;
p->idletime = q->idletime = 0;
p->realname = q->realname = (char *) NULL;
--- 389,395 ----
***************
*** 466,474 ****
p->tty[LMAX] = 0;
bcopy(user.ut_host, p->host, HMAX);
p->host[HMAX] = 0;
- #ifndef SOLARIS
p->loginat = user.ut_time;
- #endif
p->loggedin = 1;
}
else { /* p->loggedin == 1 */
--- 485,491 ----
***************
*** 480,488 ****
new->tty[LMAX] = 0;
bcopy(user.ut_host, new->host, HMAX);
new->host[HMAX] = 0;
- #ifndef SOLARIS
new->loginat = user.ut_time;
- #endif
new->pwd = p->pwd;
new->loggedin = 1;
new->original = 0;
--- 497,503 ----
***************
*** 693,705 ****
if (pers->loggedin) {
if (idle) {
findidle(pers);
- #ifndef SOLARIS
printf("%c%-*s %-16.16s", pers->writable ? ' ' : '*',
LMAX, pers->tty, ctime(&pers->loginat));
- #else
- printf("%c%-*s", pers->writable ? ' ' : '*',
- LMAX, pers->tty);
- #endif
(void) ltimeprint(" ", &pers->idletime, "");
}
else
--- 708,715 ----
***************
*** 1137,1153 ****
(void) strncpy(ttnames[i],
bp->ut_line,
sizeof(bp->ut_line));
- #ifndef SOLARIS
logouts[i] = bp->ut_time;
- #endif
break;
}
if (!strncmp(ttnames[i],
bp->ut_line,
sizeof(bp->ut_line))) {
- #ifndef SOLARIS
logouts[i] = bp->ut_time;
- #endif
break;
}
}
--- 1147,1159 ----
***************
*** 1207,1213 ****
--- 1213,1223 ----
{
struct stat ttystatus;
static char buffer[20] = "/dev/";
+ #ifdef POSIX
+ time_t t;
+ #else
long t;
+ #endif
#define TTYLEN 5
***************
*** 1240,1246 ****
--- 1250,1260 ----
* if the idle time is zero, it prints 4 blanks.
*/
stimeprint(dt)
+ #ifdef POSIX
+ time_t *dt;
+ #else
long *dt;
+ #endif
{
register struct tm *delta;
***************
*** 1271,1277 ****
--- 1285,1295 ----
* print "prefix" first.
*/
ltimeprint(before, dt, after)
+ #ifdef POSIX
+ time_t *dt;
+ #else
long *dt;
+ #endif
char *before, *after;
{
register struct tm *delta;