From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93357 invoked by alias); 22 Mar 2018 06:14:26 -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 93347 invoked by uid 89); 22 Mar 2018 06:14:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-io0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=twLSo1AA9vyg+ZWg06iLHKpQvB+GN9adfwaMD1jRS70=; b=UPl4rFFB/ETSwJOqhlb8O34964G9/UJ5ArWM7rO9h7RHszn1IoiLbOu49Gx3aBlpKI 03r1pW7M0/PHpUQ/pAp1LU1pSXSXIamBAjTPVYPF3KZCNks+SCABVigZSN3YMddvKG6W YainiWlrvbANf9dN9jbM7DJFCSKCHrtJogDn/PYBefZuDtLJkEiuUDgrBpXQlGEPL31/ ZWkCkCfumG3j45E6hT6u+8WpoXZxSvA2HswHeLmZmnoeAL0Ldz4Xyb4D4q4vwENzt2IA KKH1GurOmskCsL0Y2CDV/UeG8wDGV0FCfQ6rpxx4jWjlYzG7F0XwHp77PXEa8IRHyZfI p7dA== X-Gm-Message-State: AElRT7EhNbqNGBvCRZXdaf2RI2LjD1gKddCu8oQrLDB1eF8TZYthS/Fr 0Zm8mmOhU3mjcPmcjNLbOhk4jmkcNzY= X-Google-Smtp-Source: AG47ELsuMp3uSA+YgZas65wEwlj69GRUsJh0hrUBFTNmtOe0T4H4XE6GzNPe5SuOjfDmPlaZQcBfcA== X-Received: by 10.107.40.147 with SMTP id o141mr7822786ioo.72.1521699262550; Wed, 21 Mar 2018 23:14:22 -0700 (PDT) Subject: Re: [PATCH] getlogin_r: return early when linux sentinel value is set To: Jesse Hathaway , Andreas Schwab Cc: libc-alpha@sourceware.org References: <73b04097-ef36-b597-4f7c-2e73c6eb9fa3@linaro.org> <877eq6ppkw.fsf@linux-m68k.org> From: Adhemerval Zanella Message-ID: Date: Thu, 22 Mar 2018 06:14:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-03/txt/msg00514.txt.bz2 On 22/03/2018 05:27, Jesse Hathaway wrote: > On Tue, Mar 20, 2018 at 1:30 PM, Andreas Schwab wrote: >> Depends on whether you want the linux __getlogin_r to fall back to the >> generic __getlogin_r. > > Thanks, updated patch below: > > From 04a50b5ee857aa33e1527d70f0676b6daf5a036c Mon Sep 17 00:00:00 2001 > From: Jesse Hathaway > Date: Fri, 16 Mar 2018 10:46:50 -0500 > Subject: [PATCH] getlogin_r: return early when linux sentinel value is set > > When there is no login uid Linux sets /proc/self/loginid to the sentinel > value of, (uid_t) - 1. If this is set we can return early and avoid > needlessly looking up the sentinel value in any configured nss > databases. LGTM with CL bit fixed below. Do you need someone to push it for you? Reviewed-by: Adhemerval Zanella > > diff --git a/ChangeLog b/ChangeLog > index 3399e567b8..1ceff1c094 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,8 @@ > +2018-03-20 Jesse Hathaway (tiny change) > + > + * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): return early > + when linux sentinel value is set. It should contain a tab first and respect the maximum line size of 78, as: * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Return early when linux sentinel value is set. > + > 2018-03-20 Samuel Thibault > > * manual/errno.texi (EOWNERDEAD, ENOTRECOVERABLE): Remove errno > diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c > b/sysdeps/unix/sysv/linux/getlogin_r.c > index 73ea14c8f9..1f90c1ca2d 100644 > --- a/sysdeps/unix/sysv/linux/getlogin_r.c > +++ b/sysdeps/unix/sysv/linux/getlogin_r.c > @@ -55,6 +55,15 @@ __getlogin_r_loginuid (char *name, size_t namesize) > endp == uidbuf || *endp != '\0')) > return -1; > > + /* If there is no login uid, linux sets /proc/self/loginid to the sentinel > + value of, (uid_t) - 1, so check if that value is set and return early to > + avoid making unneeded nss lookups. */ > + if (uid == (uid_t) - 1) > + { > + __set_errno (ENXIO); > + return ENXIO; > + } > + > struct passwd pwd; > struct passwd *tpwd; > int result = 0; >