[net.unix-wizards] anonymous ftps aren't recorded in wtmp

cak@Purdue.ARPA (01/12/84)

From:  Christopher A Kent <cak@Purdue.ARPA>

Description:
	FTP users who log in as "anonymous" or "ftp" are not recorded
in wtmp.  This is because the logging is done after the chroot call;
thus the open of "/usr/adm/wtmp" is now relative to ~ftp. Even if it
succeeds, the record is written into the wrong file. 

Repeat-By:
	ftp localhost and log in as anonymous. quit and do a last; no
session is recorded.

Fix:
	Move the log action to after the user has logged in but before
the chroot() call. If the chroot fails, there will be extra log
entries, but this is fairly unlikely. A diff:

*** ftpd.c.old
--- ftpd.c.new
***************
*** 235,240
  			pw->pw_name, pw->pw_dir);
  		goto bad;
  	}
  	if (guest && chroot(pw->pw_dir) < 0) {
  		reply(550, "Can't set guest privileges.");
  		goto bad;

--- 235,241 -----
  			pw->pw_name, pw->pw_dir);
  		goto bad;
  	}
+ 	dologin(pw);			/* before chroot for ftp */
  	if (guest && chroot(pw->pw_dir) < 0) {
  		reply(550, "Can't set guest privileges.");
  		goto bad;
***************
*** 244,250
  	else
  		reply(230, "Guest login ok, access restrictions apply.");
  	logged_in = 1;
- 	dologin(pw);
  	seteuid(pw->pw_uid);
  	/*
  	 * Save everything so globbing doesn't

--- 245,250 -----
  	else
  		reply(230, "Guest login ok, access restrictions apply.");
  	logged_in = 1;
  	seteuid(pw->pw_uid);
  	/*
  	 * Save everything so globbing doesn't

----------

lepreau%utah-cs@sri-unix.UUCP (01/14/84)

From:  Jay Lepreau <lepreau@utah-cs>

Index: etc/ftpd.c 4.2BSD
Description:
Repeat-By:
Fix:
--------
You sure your fix works?  I don't think it will record any logout times,
just logins (leaving everything "still-logged-in"), because the second
record of each session has got to be after the chroot(), unless you
leave an extra fork hanging around.  So what I did here was just create
a ~ftp/usr/adm/wtmp file, suitably protected.  This works in concert
with a minor but useful enhancement I long ago made to "last" to take a
-f <file> argument.  Code avail on request.

lepreau@utah-cs, {harpo,hplabs}!utah-cs!lepreau

cak@Purdue.ARPA (01/15/84)

From:  Christopher A Kent <cak@Purdue.ARPA>

Jay, 

I realized the same thing; hence my second set of fixes. I'm surprised
you hadn't received it by the time you sent the message.

Cheers,
chris
----------