[7621] in Athena Bugs

home help back first fref pref prev next nref lref last post

Proposed patch to last -- #1501

daemon@ATHENA.MIT.EDU (dskern@ATHENA.MIT.EDU)
Mon Jun 3 02:20:14 1991

From: dskern@ATHENA.MIT.EDU
Date: Mon, 3 Jun 91 02:20:00 -0400
To: bugs@ATHENA.MIT.EDU
Cc: dskern@ATHENA.MIT.EDU


	This patch adds a -f fil flag to last. The flag will cause l
last to use fil as the wtmp file, instead of the default /usr/adm/wtmp.

	Possible problem: user can specify any file  for the wtmp file.
If the file given is not in the same format as a real wtmp file, last
will return some really odd results.


*** /source/bsd-4.3/common/ucb/last.c	Thu May 15 04:55:57 1986
--- last.c	Fri May 24 17:28:22 1991
***************
*** 51,56 ****
--- 51,57 ----
  	register int i, k;
  	int bl, wtmp;
  	char *ct;
+ 	char *fil = "/usr/adm/wtmp";
  	register struct utmp *bp;
  	long otime;
  	struct stat stb;
***************
*** 65,78 ****
  	nameargs = argc = ac;
  	argv = av;
  	for (i = 0; i < argc; i++) {
  		if (argv[i][0] == '-' &&
  		    argv[i][1] >= '0' && argv[i][1] <= '9') {
  			maxrec = atoi(argv[i]+1);
  			nameargs--;
! 			continue;
  		}
  		if (strlen(argv[i])>2)
! 			continue;
  		if (!strcmp(argv[i], "~"))
  			continue;
  		if (!strcmp(argv[i], "ftp"))
--- 66,84 ----
  	nameargs = argc = ac;
  	argv = av;
  	for (i = 0; i < argc; i++) {
+ 		if (!strcmp(argv[i], "-f")) {
+ 		  fil = argv[++i];
+ 		  nameargs -= 2;
+ 		  continue;
+ 		}
  		if (argv[i][0] == '-' &&
  		    argv[i][1] >= '0' && argv[i][1] <= '9') {
  			maxrec = atoi(argv[i]+1);
  			nameargs--;
!        			continue;
  		}
  		if (strlen(argv[i])>2)
! 			continue; 
  		if (!strcmp(argv[i], "~"))
  			continue;
  		if (!strcmp(argv[i], "ftp"))
***************
*** 83,91 ****
  			continue;
  		argv[i] = strspl("tty", argv[i]);
  	}
! 	wtmp = open("/usr/adm/wtmp", 0);
  	if (wtmp < 0) {
! 		perror("/usr/adm/wtmp");
  		exit(1);
  	}
  	fstat(wtmp, &stb);
--- 89,97 ----
  			continue;
  		argv[i] = strspl("tty", argv[i]);
  	}
! 	wtmp = open(fil, 0);
  	if (wtmp < 0) {
! 		perror(fil);
  		exit(1);
  	}
  	fstat(wtmp, &stb);



  

home help back first fref pref prev next nref lref last post