From owner-freebsd-hackers Sun Sep 14 16:16:01 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id QAA09740 for hackers-outgoing; Sun, 14 Sep 1997 16:16:01 -0700 (PDT) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA09706 for ; Sun, 14 Sep 1997 16:15:53 -0700 (PDT) Received: from gate.lan.awfulhak.org (localhost [127.0.0.1]) by awfulhak.demon.co.uk (8.8.5/8.8.5) with ESMTP id AAA24723; Mon, 15 Sep 1997 00:05:53 +0100 (BST) Message-Id: <199709142305.AAA24723@awfulhak.demon.co.uk> X-Mailer: exmh version 2.0zeta 7/24/97 To: "Jordan K. Hubbard" cc: hackers@FreeBSD.ORG Subject: Re: Here's an interesting bug in our utmp handling. In-reply-to: Your message of "Sun, 14 Sep 1997 13:15:45 PDT." <10396.874268145@time.cdrom.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 15 Sep 1997 00:05:53 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Reported today by one Eddie Wieder.. > > Log in somehow (real login, xterm -ls, whatever) and verify your > user/[pt]ty combo by doing who(1) and tty(1) commands. Now use > login(1) to log in as some other user and do the who/tty thing again. > You'll have a new utmp entry for the user you just logged in as. Now > log out and do another who(1). You'll have had your utmp entry > smashed and still show up as the user you logged in and out again as. > > Not sure how to fix this one - it's "interesting." :) This whole thing is a mess in every version of anything that rhymes with unix that I've ever come across. How about removing logwtmp() and having the whole thing dealt with by kern_exit.c (is that the right place ?) and tcsetpgrp(3). The idea is that calling tcsetpgrp() will call tcgetpgrp(). If tcgetpgrp() returns an invalid pid, we create a new entry in utmp() and tweak a "utmp'd" flag. Exit of a process would move the utmp entry to wtmp if it has the "utmp'd" flag. Would this work ? Would it make sense ? The result AFACT would be that someone doing a "login" themselves would not get a new utmp entry whereas anyone associating with a terminal for the first time (via getty or allocating a new pty) will get one - as they should. The only problem I forsee is that the UID of the process may not be correct at tcsetpgrp() time.... > Jordan -- Brian , Don't _EVER_ lose your sense of humour....