From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58679 invoked by alias); 24 Jul 2015 19:15:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 58669 invoked by uid 89); 24 Jul 2015 19:15:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout29.012.net.il Received: from mtaout29.012.net.il (HELO mtaout29.012.net.il) (80.179.55.185) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jul 2015 19:15:13 +0000 Received: from conversion-daemon.mtaout29.012.net.il by mtaout29.012.net.il (HyperSendmail v2007.08) id <0NS000N00A51N100@mtaout29.012.net.il> for gdb-patches@sourceware.org; Fri, 24 Jul 2015 22:14:47 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout29.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NS000LBBASN8E60@mtaout29.012.net.il>; Fri, 24 Jul 2015 22:14:47 +0300 (IDT) Date: Fri, 24 Jul 2015 19:15:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH] Make sure GDB uses a valid shell when starting the inferior and to perform the "shell" command In-reply-to: <1437761993-18758-1-git-send-email-sergiodj@redhat.com> To: Sergio Durigan Junior Cc: gdb-patches@sourceware.org, sergiodj@redhat.com Reply-to: Eli Zaretskii Message-id: <83a8ul2wqp.fsf@gnu.org> References: <1437761993-18758-1-git-send-email-sergiodj@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00718.txt.bz2 > From: Sergio Durigan Junior > Cc: Sergio Durigan Junior > Date: Fri, 24 Jul 2015 14:19:53 -0400 > > It is known that GDB needs a valid shell to start the inferior and to > offer the "shell" command to the user. This has recently been the > cause of a problem on the MIPS buildslave, because $SHELL was set to > /sbin/nologin and several tests were failing. The thread is here: > > > > However, I think we can do better than that. If 'startup-with-shell' > is on, which is the default, we blindly trust that the user will > provide a valid shell for us, and this may not be true all the time. > So I am proposing a patch to increment the tests made by GDB before > running the inferior to decide whether it will use $SHELL or not. > Particularly, I created a new function, called "valid_shell", which > defines the concept of a valid shell for GDB: > > - A file that exists and is executable by the user > > - A file that is not /sbin/nologin > > For now, I think this is enough to cover most cases. The default > action when an invalid shell is found is to use /bin/sh instead (we > already do that when $SHELL is not defined, for example), and also > issue a warning to the user. This applies for when we are starting > the inferior and when we are executing the "shell" command. > > To make things more robust, I made the code also check /bin/sh and > make sure it is also valid. If it is not, and if we are starting the > inferior, then GDB will use fork+exec instead. If we are executing > the "shell" command and we cannot find a valid shell, GDB will error > out. > > I updated the documentation to reflect the new behavior, and created a > testcase to exercise the code. This patch has been regression-tested > on Fedora 22 x86_64. > > OK to apply? The documentation part is OK, but please use @pxref instead of "see @ref" for cross-references in parentheses. Thanks.