GNU bug report logs - #26371
[PATCH 0/1] tty: do not provide conflicting information

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Christian Brauner <christian.brauner@HIDDEN>; Keywords: patch; Done: Paul Eggert <eggert@HIDDEN>; Maintainer for coreutils is bug-coreutils@HIDDEN.
bug unarchived. Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
bug archived. Request was from Debbugs Internal Request <help-debbugs@HIDDEN> to internal_control <at> debbugs.gnu.org. Full text available.

Message received at 26371-done <at> debbugs.gnu.org:


Received: (at 26371-done) by debbugs.gnu.org; 5 Apr 2017 21:49:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 05 17:49:26 2017
Received: from localhost ([127.0.0.1]:34141 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cvsnt-0003VS-50
	for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 17:49:26 -0400
Received: from mx1.mailbox.org ([80.241.60.212]:55722)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvsnq-0003VA-UE
 for 26371-done <at> debbugs.gnu.org; Wed, 05 Apr 2017 17:49:23 -0400
Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1.mailbox.org (Postfix) with ESMTPS id A5B6345E27;
 Wed,  5 Apr 2017 23:49:16 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de
 [80.241.56.117]) (amavisd-new, port 10030)
 with ESMTP id 6IgWelFF30Ey; Wed,  5 Apr 2017 23:49:14 +0200 (CEST)
Date: Wed, 5 Apr 2017 23:49:12 +0200
From: Christian Brauner <christian.brauner@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#26371: [PATCH 0/1] tty: do not provide conflicting information
Message-ID: <20170405214912.gr3kejv2je3tgsji@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <7d059cad-a395-184c-ecf3-9648dfe9b4d3@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 26371-done
Cc: Christian Brauner <christian.brauner@HIDDEN>, serge@HIDDEN,
 26371-done <at> debbugs.gnu.org, stgraber@HIDDEN, coreutils@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

On Wed, Apr 05, 2017 at 02:27:12PM -0700, Paul Eggert wrote:
> On 04/05/2017 01:17 PM, Christian Brauner wrote:
> > Oh, where can that information be gathered from? I looked up isatty() and
> > ttyname{_r}() in:
> > 
> > The Open Group Base Specifications Issue 7
> > IEEE Std 1003.1-2008, 2016 Edition
> > Copyright © 2001-2016 The IEEE and The Open Group
> > 
> > but couldn't find any such requirement
> I inferred it from the similar wording used for both functions. isatty
> "shall return 1 if fildes is associated with a terminal", and ttyname "shall
> return a pointer to a string containing a null-terminated pathname of the
> terminal associated with file descriptor fildes". Although in theory POSIX
> allows either function to fail with a weird error number whenever it
> pleases, clearly the intent is that the two functions be consistent, many
> programs assume that they are consistent, and any implementation where
> isatty succeeds but ttyname fails is an implementation that is asking for
> trouble.

Maybe, but it doesn't sound obvious to me especially in the presence of e.g.
mount namespaces on Linux. But this isn't even platform specific! If you somehow
mask the device path (overmounting or think of any other reason) the file
descriptor refers to then ttyname{_r}() _will fail to retrieve it_. I don't know
if most platforms will even set an errno in this case and so your patch will
likely be just another version of reporting misleading information. If errno is
not set then now instead of reporting "not a tty" but exiting with success you
will now report ./tty: standard input: Success! but exit with an error.

> 
> > Form a purely technical perspective it just seems to make a lot more sense to
> > exit with success if the file descriptor actually refers to a terminal. The name
> > of the device it refers to just seems syntactical sugar.
> That's what 'tty -s' does. Perhaps if we were designing things from scratch,
> 'tty' would behave like 'tty -s'. But longstanding practice is for 'tty'
> (without arguments) to output the terminal's name, and programs expect that
> behavior.
> 
> Really, the underlying platform should get fixed. In the meantime I suppose

Maybe, but it's not really an explicit POSIX requirement according to what I've
gathered from the above paragraph. For glibc, Serge and I have taken care that
errno is set to ENODEV in this case which seemed to everyone involved in this
discussion to be the most natural way of handling this scenario.

> that the best plain 'tty' can do is report the configuration error and exit.
> 
> Did you try the patch I installed? That is, does ttyname have a reasonable
> errno value when it returns NULL on your platform?

Yes, as I said at least for glibc you'd get:

root@zest1:~/dummy/coreutils/src# ./tty
./tty: standard input: No such device

Which is not necessarily an improvement since the fd _is_ actually a tty.

Thanks for hearing me rant! :)
Christian




Information forwarded to bug-coreutils@HIDDEN:
bug#26371; Package coreutils. Full text available.

Message received at 26371-done <at> debbugs.gnu.org:


Received: (at 26371-done) by debbugs.gnu.org; 5 Apr 2017 21:27:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 05 17:27:22 2017
Received: from localhost ([127.0.0.1]:34110 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cvsSY-0002sU-0t
	for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 17:27:22 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35526)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1cvsSW-0002sA-3F
 for 26371-done <at> debbugs.gnu.org; Wed, 05 Apr 2017 17:27:20 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0653D160072;
 Wed,  5 Apr 2017 14:27:14 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id 82TqnIvYYRpb; Wed,  5 Apr 2017 14:27:13 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3F4FF160086;
 Wed,  5 Apr 2017 14:27:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 4Yjzy6leHRwt; Wed,  5 Apr 2017 14:27:13 -0700 (PDT)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 21A6F160072;
 Wed,  5 Apr 2017 14:27:13 -0700 (PDT)
Subject: Re: bug#26371: [PATCH 0/1] tty: do not provide conflicting information
To: Christian Brauner <christian.brauner@HIDDEN>
References: <20170405144441.20050-1-christian.brauner@HIDDEN>
 <20170405201717.736e5xdq3qctjrt4@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <7d059cad-a395-184c-ecf3-9648dfe9b4d3@HIDDEN>
Date: Wed, 5 Apr 2017 14:27:12 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <20170405201717.736e5xdq3qctjrt4@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 26371-done
Cc: Christian Brauner <christian.brauner@HIDDEN>, serge@HIDDEN,
 26371-done <at> debbugs.gnu.org, stgraber@HIDDEN, coreutils@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 04/05/2017 01:17 PM, Christian Brauner wrote:
> Oh, where can that information be gathered from? I looked up isatty() a=
nd
> ttyname{_r}() in:
>
> The Open Group Base Specifications Issue 7
> IEEE Std 1003.1-2008, 2016 Edition
> Copyright =C2=A9 2001-2016 The IEEE and The Open Group
>
> but couldn't find any such requirement
I inferred it from the similar wording used for both functions. isatty=20
"shall return 1 if fildes is associated with a terminal", and ttyname=20
"shall return a pointer to a string containing a null-terminated=20
pathname of the terminal associated with file descriptor fildes".=20
Although in theory POSIX allows either function to fail with a weird=20
error number whenever it pleases, clearly the intent is that the two=20
functions be consistent, many programs assume that they are consistent,=20
and any implementation where isatty succeeds but ttyname fails is an=20
implementation that is asking for trouble.

> Form a purely technical perspective it just seems to make a lot more se=
nse to
> exit with success if the file descriptor actually refers to a terminal.=
 The name
> of the device it refers to just seems syntactical sugar.
That's what 'tty -s' does. Perhaps if we were designing things from=20
scratch, 'tty' would behave like 'tty -s'. But longstanding practice is=20
for 'tty' (without arguments) to output the terminal's name, and=20
programs expect that behavior.

Really, the underlying platform should get fixed. In the meantime I=20
suppose that the best plain 'tty' can do is report the configuration=20
error and exit.

Did you try the patch I installed? That is, does ttyname have a=20
reasonable errno value when it returns NULL on your platform?




Information forwarded to bug-coreutils@HIDDEN:
bug#26371; Package coreutils. Full text available.

Message received at 26371-done <at> debbugs.gnu.org:


Received: (at 26371-done) by debbugs.gnu.org; 5 Apr 2017 20:36:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 05 16:36:55 2017
Received: from localhost ([127.0.0.1]:34081 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cvrfj-0001Pp-CL
	for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 16:36:55 -0400
Received: from mx2.mailbox.org ([80.241.60.215]:56726)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvrMy-0000rK-Ts
 for 26371-done <at> debbugs.gnu.org; Wed, 05 Apr 2017 16:17:33 -0400
Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx2.mailbox.org (Postfix) with ESMTPS id 871E7457BA;
 Wed,  5 Apr 2017 22:17:26 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de
 [80.241.56.116]) (amavisd-new, port 10030)
 with ESMTP id mo6hvC-CQiCV; Wed,  5 Apr 2017 22:17:19 +0200 (CEST)
Date: Wed, 5 Apr 2017 22:17:18 +0200
From: Christian Brauner <christian.brauner@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#26371: [PATCH 0/1] tty: do not provide conflicting information
Message-ID: <20170405201717.736e5xdq3qctjrt4@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <86ae9ed0-8a2f-d173-54cb-acf37909a60a@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 26371-done
X-Mailman-Approved-At: Wed, 05 Apr 2017 16:36:54 -0400
Cc: Christian Brauner <christian.brauner@HIDDEN>, serge@HIDDEN,
 26371-done <at> debbugs.gnu.org, coreutils@HIDDEN, stgraber@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Hi Paul,

Thanks for the quick response. :)

On Wed, Apr 05, 2017 at 11:40:15AM -0700, Paul Eggert wrote:
> 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

Oh, where can that information be gathered from? I looked up isatty() and
ttyname{_r}() in:

The Open Group Base Specifications Issue 7
IEEE Std 1003.1-2008, 2016 Edition
Copyright © 2001-2016 The IEEE and The Open Group

but couldn't find any such requirement that forces an alignment between isatty()
and ttyname{_r}().

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

Form a purely technical perspective it just seems to make a lot more sense to
exit with success if the file descriptor actually refers to a terminal. The name
of the device it refers to just seems syntactical sugar. :)

Thanks again!
Christian




Information forwarded to bug-coreutils@HIDDEN:
bug#26371; Package coreutils. Full text available.

Message received at 26371-done <at> debbugs.gnu.org:


Received: (at 26371-done) by debbugs.gnu.org; 5 Apr 2017 18:40:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 05 14:40:25 2017
Received: from localhost ([127.0.0.1]:33976 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cvpqz-0006QA-4x
	for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 14:40:25 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:32804)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1cvpqx-0006Pv-QI
 for 26371-done <at> debbugs.gnu.org; Wed, 05 Apr 2017 14:40:24 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0B040160072;
 Wed,  5 Apr 2017 11:40:17 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id wuemZjNO255r; Wed,  5 Apr 2017 11:40:16 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2D025160086;
 Wed,  5 Apr 2017 11:40:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 5MvxF1D0Pkvv; Wed,  5 Apr 2017 11:40:16 -0700 (PDT)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 0FB27160074;
 Wed,  5 Apr 2017 11:40:16 -0700 (PDT)
Subject: Re: bug#26371: [PATCH 0/1] tty: do not provide conflicting information
To: Christian Brauner <christian.brauner@HIDDEN>, coreutils@HIDDEN,
 26371-done <at> debbugs.gnu.org, stgraber@HIDDEN, serge@HIDDEN
References: <20170405144441.20050-1-christian.brauner@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <86ae9ed0-8a2f-d173-54cb-acf37909a60a@HIDDEN>
Date: Wed, 5 Apr 2017 11:40:15 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <20170405144441.20050-1-christian.brauner@HIDDEN>
Content-Type: multipart/mixed; boundary="------------E8A9BBAE620A4DDC70F4CEC0"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 26371-done
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

This is a multi-part message in MIME format.
--------------E8A9BBAE620A4DDC70F4CEC0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

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.

--------------E8A9BBAE620A4DDC70F4CEC0
Content-Type: application/x-patch;
 name="0001-tty-handle-misconfigured-namespaces.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="0001-tty-handle-misconfigured-namespaces.patch"

RnJvbSAyMTMwZGEzZGY1MzZhMjc3NzQ5NDk1NjIxYmVhZGY2NjJkMjQwMGU0IE1vbiBTZXAg
MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1
PgpEYXRlOiBXZWQsIDUgQXByIDIwMTcgMTE6MzQ6NDIg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XplX21haW4gKCZhcmdjLCAm
YXJndik7CkBAIC0xMDksMTYgKzEwOSwyOSBAQCBtYWluIChpbnQgYXJnYywgY2hhciAqKmFy
Z3YpCiAgICAgfQogCiAgIGlmIChvcHRpbmQgPCBhcmdjKQotICAgIGVycm9yICgwLCAwLCBf
KCJleHRyYSBvcGVyYW5kICVzIiksIHF1b3RlIChhcmd2W29wdGluZF0pKTsKKyAgICB7Cisg
ICAgICBlcnJvciAoMCwgMCwgXygiZXh0cmEgb3BlcmFuZCAlcyIpLCBxdW90ZSAoYXJndltv
cHRpbmRdKSk7CisgICAgICB1c2FnZSAoVFRZX0ZBSUxVUkUpOworICAgIH0KKworICBlcnJu
byA9IEVOT0VOVDsKKworICBpZiAoc2lsZW50KQorICAgIHJldHVybiAoaXNhdHR5IChTVERJ
Tl9GSUxFTk8pID8gRVhJVF9TVUNDRVNTCisgICAgICAgICAgICA6IGVycm5vID09IEVOT1RU
WSA/IEVYSVRfRkFJTFVSRQorICAgICAgICAgICAgOiBUVFlfU1RESU5fRVJST1IpOworCisg
IGludCBzdGF0dXMgPSBFWElUX1NVQ0NFU1M7CisgIGNoYXIgY29uc3QgKnR0eSA9IHR0eW5h
bWUgKFNURElOX0ZJTEVOTyk7CiAKLSAgdHR5ID0gdHR5bmFtZSAoU1RESU5fRklMRU5PKTsK
LSAgaWYgKCFzaWxlbnQpCisgIGlmICghIHR0eSkKICAgICB7Ci0gICAgICBpZiAodHR5KQot
ICAgICAgICBwdXRzICh0dHkpOwotICAgICAgZWxzZQotICAgICAgICBwdXRzIChfKCJub3Qg
YSB0dHkiKSk7CisgICAgICBpZiAoZXJybm8gIT0gRU5PVFRZKQorICAgICAgICBlcnJvciAo
VFRZX1NURElOX0VSUk9SLCBlcnJubywgXygic3RhbmRhcmQgaW5wdXQiKSk7CisgICAgICB0
dHkgPSBfKCJub3QgYSB0dHkiKTsKKyAgICAgIHN0YXR1cyA9IEVYSVRfRkFJTFVSRTsKICAg
ICB9CiAKLSAgcmV0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gLXMgPC9kZXYvbnVsbCB8fCBmYWlsPTEKKworcmV0dXJuc18gMiB0dHkg
YSB8fCBmYWlsPTEKK3JldHVybnNfIDIgdHR5IC1zIGEgfHwgZmFpbD0xCisKK2lmIHRlc3Qg
LXcgL2Rldi9mdWxsICYmIHRlc3QgLWMgL2Rldi9mdWxsOyB0aGVuCisgIHJldHVybnNfIDMg
dHR5ID4vZGV2L2Z1bGwgfHwgZmFpbD0xCisgIHJldHVybnNfIDMgdHR5IDwvZGV2L251bGwg
Pi9kZXYvZnVsbCB8fCBmYWlsPTEKK2ZpCisKK3JldHVybnNfIDQgdHR5IDwmLSAyPi9kZXYv
bnVsbCB8fCBmYWlsPTEKK3JldHVybnNfIDQgdHR5IC1zIDwmLSB8fCBmYWlsPTEKKworRXhp
dCAkZmFpbAotLSAKMi45LjMKCg==
--------------E8A9BBAE620A4DDC70F4CEC0--




Notification sent to Christian Brauner <christian.brauner@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Paul Eggert <eggert@HIDDEN>:
You have taken responsibility. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 Apr 2017 15:44:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 05 11:44:16 2017
Received: from localhost ([127.0.0.1]:33821 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cvn6W-0000Fg-AX
	for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 11:44:16 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59423)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmBA-0007Ct-SK
 for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 10:45:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmB4-0003xl-JS
 for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 10:44:55 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:59365)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <christian.brauner@HIDDEN>)
 id 1cvmB4-0003xX-Fr
 for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 10:44:54 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50359)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmB3-0000Ab-3J
 for bug-coreutils@HIDDEN; Wed, 05 Apr 2017 10:44:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmAy-0003vq-Ke
 for bug-coreutils@HIDDEN; Wed, 05 Apr 2017 10:44:53 -0400
Received: from mx1.mailbox.org ([80.241.60.212]:59252)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <christian.brauner@HIDDEN>)
 id 1cvmAy-0003vL-B0; Wed, 05 Apr 2017 10:44:48 -0400
Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1.mailbox.org (Postfix) with ESMTPS id 78C7445717;
 Wed,  5 Apr 2017 16:44:46 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de
 [80.241.56.117]) (amavisd-new, port 10030)
 with ESMTP id BHCtMLYs7aw3; Wed,  5 Apr 2017 16:44:45 +0200 (CEST)
From: Christian Brauner <christian.brauner@HIDDEN>
To: coreutils@HIDDEN, bug-coreutils@HIDDEN, stgraber@HIDDEN,
 serge@HIDDEN
Subject: [PATCH 1/1] tty: do not provide conflicting information
Date: Wed,  5 Apr 2017 16:44:41 +0200
Message-Id: <20170405144441.20050-2-christian.brauner@HIDDEN>
In-Reply-To: <20170405144441.20050-1-christian.brauner@HIDDEN>
References: <20170405144441.20050-1-christian.brauner@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 05 Apr 2017 11:44:15 -0400
Cc: Christian Brauner <christian.brauner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

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.

Signed-off-by: Christian Brauner <christian.brauner@HIDDEN>
---
 src/tty.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/tty.c b/src/tty.c
index c3fdabc85..fb21a995a 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -79,6 +79,7 @@ main (int argc, char **argv)
 {
   char *tty;
   int optc;
+  int is_tty;
 
   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
@@ -111,14 +112,21 @@ main (int argc, char **argv)
   if (optind < argc)
     error (0, 0, _("extra operand %s"), quote (argv[optind]));
 
+  is_tty = isatty (STDIN_FILENO);
+  if (!is_tty)
+    {
+      puts (_("not a tty"));
+      return EXIT_FAILURE;
+    }
+
   tty = ttyname (STDIN_FILENO);
   if (!silent)
     {
       if (tty)
         puts (tty);
       else
-        puts (_("not a tty"));
+        puts (_("is a tty but failed to determine the device path"));
     }
 
-  return isatty (STDIN_FILENO) ? EXIT_SUCCESS : EXIT_FAILURE;
+  return EXIT_SUCCESS;
 }
-- 
2.11.0





Information forwarded to bug-coreutils@HIDDEN:
bug#26371; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 Apr 2017 15:26:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 05 11:26:01 2017
Received: from localhost ([127.0.0.1]:33802 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1cvmoq-0008Ds-CL
	for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 11:26:00 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59407)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmBA-0007Cs-9l
 for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 10:45:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmB4-0003xN-3O
 for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 10:44:55 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:34421)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <christian.brauner@HIDDEN>)
 id 1cvmB4-0003xC-0C
 for submit <at> debbugs.gnu.org; Wed, 05 Apr 2017 10:44:54 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50357)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmB2-0000Aa-Sm
 for bug-coreutils@HIDDEN; Wed, 05 Apr 2017 10:44:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <christian.brauner@HIDDEN>) id 1cvmAy-0003vd-1R
 for bug-coreutils@HIDDEN; Wed, 05 Apr 2017 10:44:52 -0400
Received: from mx2.mailbox.org ([80.241.60.215]:59849)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <christian.brauner@HIDDEN>)
 id 1cvmAx-0003v9-RV; Wed, 05 Apr 2017 10:44:47 -0400
Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx2.mailbox.org (Postfix) with ESMTPS id 44EF644A76;
 Wed,  5 Apr 2017 16:44:46 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de
 [80.241.56.117]) (amavisd-new, port 10030)
 with ESMTP id md_yW18E8d5m; Wed,  5 Apr 2017 16:44:45 +0200 (CEST)
From: Christian Brauner <christian.brauner@HIDDEN>
To: coreutils@HIDDEN, bug-coreutils@HIDDEN, stgraber@HIDDEN,
 serge@HIDDEN
Subject: [PATCH 0/1] tty: do not provide conflicting information
Date: Wed,  5 Apr 2017 16:44:40 +0200
Message-Id: <20170405144441.20050-1-christian.brauner@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 05 Apr 2017 11:25:58 -0400
Cc: Christian Brauner <christian.brauner@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

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





Acknowledgement sent to Christian Brauner <christian.brauner@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#26371; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 20 Jun 2025 19:00:03 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.