bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how does O_NOCTTY help? [Re: bug in chdir-safer


From: Paul Eggert
Subject: Re: how does O_NOCTTY help? [Re: bug in chdir-safer
Date: Fri, 10 Feb 2006 14:51:09 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> So O_NOCTTY is definitely worthwhile, if only to avoid
> exposure for the time between an open and close of /dev/tty,
> assuming the process in question already had no controlling terminal.
> Right?

That's the basic idea, but I'm afraid it's a bit more complicated than
that.  The process is exposed even after it closes the terminal, since
it doesn't relinquish the controlling terminal even after it closes
the corresponding file descriptor (certainly if other processes have
the terminal open -- even via an independent descriptor -- and on some
systems not even when all processes close all their file descriptors
that access that terminal).

It is tempting to think that we should use O_NOCTTY everywhere we open
a file, but I don't think that's right.  For one thing, POSIX doesn't
allow it.  I suspect it's more accurate to say that we should
generally use O_NOCTTY when we're opening a file for a reason other
than to read() or write() it.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]