Subject: bug#26371: closed (Re: bug#26371: [PATCH 0/1] tty: do not provide conflicting information)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 05 Apr 2017 18:41:02 +0000

Your bug report

#26371: [PATCH 0/1] tty: do not provide conflicting information

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
26371: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26371
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#26371: [PATCH 0/1] tty: do not provide conflicting information
From: Paul Eggert <[email-masked]>
To: Christian Brauner <[email-masked]>, [email-masked], [email-masked], [email-masked], [email-masked]
Date: Wed, 5 Apr 2017 11:40:15 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for the bug report. The situation you describe seems to be a 
platform that does not conform to POSIX, since POSIX doesn't allow for 
isatty to succeed but ttyname to fail. So I expect you'll run into 
problems other than with the tty program, as other software will make 
the same assumptions that tty is making.

That being said, tty could do a better job about the situation. I 
installed the attached somewhat-more-ambitious patch, so that tty will 
do more-extensive checking of the results of isatty and/or ttyname (and 
so that it never needs to call both functions and worry about whether 
their results are consistent :-). Please give it a try on your platform.

Subject: [PATCH 0/1] tty: do not provide conflicting information
From: Christian Brauner <[email-masked]>
To: [email-masked], [email-masked], [email-masked], [email-masked]
Cc: Christian Brauner <[email-masked]>
Date: Wed, 5 Apr 2017 16:44:40 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi guys,

In case the current file descriptor is a tty but ttyname{_r}() fails to retrieve
the device path tty would falsely report "not a tty" but return EXIT_SUCCESS.
This is confusing. Instead, let's first check whether the fd refers to a tty and
if not report "not a tty" and exit with error. In all other cases, we should
report "is a tty but failed to determine the device path" and exit with success.
This is much clearer. Depending on the platform the user can then decide how to
proceed, e.g. by looking at /proc/self/fd/0 for Linux or somewhere else on other
platforms.

This becomes especially important when we deal with Linux namespaces where this
case can regularly happen should a new devpts instance be mounted in the
namespace but the fd still refers to a pts device from another devpts instance
in another mount namespace.

I added Signed-off-by line but I'm not completely sure if this is used in
cureutils. If not, just drop it. :)

Christian

Christian Brauner (1):
  tty: do not provide conflicting information

 src/tty.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

-- 
2.11.0