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: Jim Meyering
Subject: Re: how does O_NOCTTY help? [Re: bug in chdir-safer
Date: Sun, 12 Feb 2006 22:44:29 +0100

Paul Eggert <address@hidden> wrote:
> 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

Your use of `processes' means `processes in the same process group', right?
Which means the exposure is still pretty limited.

> 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.

I agree.
Thanks.




reply via email to

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