****** Message from InterScan E-Mail VirusWall NT ******
** No virus found in attached file noname.htm
Bu mailin virus taramasi test programi ile yapilmistir.
***************** End of message ***************
answer is from Bob Vickers /* thanks a lot for the c code that is ı want
hundred percentage */
#include <time.h>
#include <lastlog.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#define MAXUID 65535
#define MAXSHELL 20
#define USLENGTH 10
#define LASTLOG_FILE "/var/adm/lastlog"
main(int argc, char *argv[])
{
time_t logtime;
struct lastlog llrec;
struct passwd *pw;
uid_t uid;
FILE *llfile;
struct userinfo {
char name[USLENGTH+1];
char shell[MAXSHELL+1];
};
struct userinfo ui[MAXUID];
setpwent();
while (pw=getpwent()) {
uid=pw->pw_uid;
if (uid >= MAXUID ) {
fprintf(stderr, "lastlog: MAXUID=%d is too small",
MAXUID);
sprintf(ui[uid].name, "%ld", (long)uid );
}
else strncpy(ui[uid].name, pw->pw_name, USLENGTH);
strncpy( ui[uid].shell, pw->pw_shell, MAXSHELL);
}
llfile=fopen(LASTLOG_FILE, "rb");
for (uid=0;;uid++) {
if (fread(&llrec, sizeof llrec, 1, llfile) != 1) break;
if (ui[uid].name[0] == NULL) continue; /* unassigned UID
*/
logtime=llrec.ll_time;
printf("%-10.10s %-19s%11ld ", ui[uid].name, ui[uid].shell,
logtime);
if (logtime == 0 )
printf("never logged on\n");
else
printf("%s", ctime(&logtime));
}
}
Hasan Atasoy
Unix System Admin.
Ihlas Finans Kurumu
Sistem İletişim Müdürlügü
29 Ekim C. No:23 34530
Y.bosna/Istanbul-Turkey
++90.212.454 1362 tel.
* hatasoy_at_ifk.com.tr
Received on Wed Jul 05 2000 - 14:28:26 NZST