From owner-freebsd-current Tue Dec 24 6:10:13 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 04AD737B401; Tue, 24 Dec 2002 06:10:12 -0800 (PST) Received: from the-frontier.org (ns1.the-frontier.org [216.86.199.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5619E43ED8; Tue, 24 Dec 2002 06:10:11 -0800 (PST) (envelope-from pscott@skycoast.us) Received: from [192.168.66.249] (dhcp-249-66-168-192.the-frontier.org [192.168.66.249]) by the-frontier.org (8.9.3/8.9.3) with ESMTP id GAA99084; Tue, 24 Dec 2002 06:09:30 -0800 (PST) (envelope-from pscott@skycoast.us) User-Agent: Microsoft-Entourage/10.1.1.2418 Date: Tue, 24 Dec 2002 06:09:30 -0800 Subject: Re: revoke(2) redux... From: "Paul A. Scott" To: Poul-Henning Kamp , Message-ID: In-Reply-To: <30917.1040730025@critter.freebsd.dk> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG -- > From: Poul-Henning Kamp >>void setctty(char *name) { >> (void) revoke(name); >> if ((fd = open(name, O_RDWR)) == -1) { > Isn't there a pretty obvious race between the revoke() and the open() ? > Wouldn't it in fact make much more sense if revoke(2) was defined as > int revoke(int fd); /* kick everybody else off */ > and the code above would look like: >> if ((fd = open(name, O_RDWR)) == -1) { >> } >> (void) revoke(fd); But, revoke() invalidates all descriptors for the named path, so any subsequent operations on the open file descriptor would fail, which defeats the purpose of open(). I think what's needed is some form of serialization around revoke() and open(). I'm not a master of the init code, but it may be that the code is inherently non-reentrant, so the original code would then be okay. Paul Paul A. Scott mailto:pscott@skycoast.us http://skycoast.us/pscott/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message