Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Dec 2002 06:09:30 -0800
From:      "Paul A. Scott" <pscott@skycoast.us>
To:        Poul-Henning Kamp <phk@freebsd.org>, <current@freebsd.org>
Subject:   Re: revoke(2) redux...
Message-ID:  <BA2DAA9A.17D62%pscott@skycoast.us>
In-Reply-To: <30917.1040730025@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

-- 

> From: Poul-Henning Kamp <phk@FreeBSD.ORG>
>>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BA2DAA9A.17D62%pscott>