From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124429 invoked by alias); 15 Apr 2016 17:06:50 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 124361 invoked by uid 89); 15 Apr 2016 17:06:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1585 X-HELO: mx1.redhat.com Subject: Re: [PATCH 1/1] linux ttyname: return link if appropriate To: Serge Hallyn References: <20160415152929.GA7932@ubuntumail> <5711165D.5040902@redhat.com> <20160415164652.GE8450@ubuntumail> Cc: libc-alpha@sourceware.org From: Florian Weimer Message-ID: <57111F9C.8030902@redhat.com> Date: Fri, 15 Apr 2016 17:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <20160415164652.GE8450@ubuntumail> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-04/txt/msg00399.txt.bz2 On 04/15/2016 06:46 PM, Serge Hallyn wrote: > Quoting Florian Weimer (fweimer@redhat.com): >> On 04/15/2016 05:29 PM, Serge Hallyn wrote: >>> The current ttyname does the wrong thing in two cases: >>> >>> 1. If the passed-in link (say /proc/self/fd/0) points to a >>> device, say /dev/pts/2, in a parent mount namespace, and a >>> /dev/pts/2 exists (in a different devpts) in the current >>> namespace, then it returns /dev/pts/2. But /dev/pts/2 is >>> NOT the current tty, it is a different file and device. >> >> Is this the first change? > > Right, it ensures that the filesystem of the two files is > the same. > >>> 2. If the passed-in link (say /proc/self/fd/0) points to >>> a device, say /dev/pts/2, in a parent mount namespace, and >>> /dev/pts/2 does not exist in the current namespace, it >>> returns success but an empty name. As far as I can tell, >>> there is no reason for it to not return /proc/self/fd/0. >>> http://pubs.opengroup.org/onlinepubs/009695399/functions/ttyname.html >>> does not say anything about not returning a link. >> >> Is it safe to drop the verification that ttyname ordinarily would do? > > Which verification do you mean exactly? That the file descriptor actually belongs to a PTY device listed under /dev/pts. >> ttyname_r will need a similar change. > > Oh, yeah, it will. Please also fix the stylistic issues (GNU style requires a space in function calls, braces on their own lines etc.). But I don't think we can make the change, considering the security implications. Florian