From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120742 invoked by alias); 19 Mar 2018 15:03:40 -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 120516 invoked by uid 89); 19 Mar 2018 15:03:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:sk:n15-v6s, HX-Received:sk:33-v6mr X-HELO: mail-pl0-f41.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=laSn0PydAdLG/ygjEjcHHaGwAkEaeZYx5L2WsUOnYac=; b=jo7OFKRf/aSmNaC2K70Ww9J+UHlK9n1bxTUKjxmxTV2Xhhf6i9IMyN0vdvyjUZikJm w+aBtEcp/MB4uNuDwUl3V0jqPDm9To0JPJIaIHbl9DCKGj6LHgwJwlYewgwJijWKzTqC k1ImFDyqDIPgYQg1mXRLkmn7l9vVSzQodeJmNq/0yEIZ8hcCAZK3L7LTJXMm+r8ouS/D r5trpSgDbwcM3wFYToSfLwNMFBoTLUQAu6jjAfVCea53GuPlwAta3cXEBL0X4aYTBWnK xWE/KZS8f8TP0osmBkkwh3n9o5UGk4ZmqhKcSEBH93KloPIFXeMeapoafJAOTbIntunr TOEg== X-Gm-Message-State: AElRT7Ey57pX884/CYYiZXZwmLPaXKTKjVUDcg84IgjYPYImhuYXpxar UIPbxV0agvlNg5q/C59FeG8e7H+kYZ9WwY+f2mn/PQ== X-Google-Smtp-Source: AG47ELu4/6y9CIDhMiPBI/sae4JROjdHOdp8g5TEFkdyQtREitN8D3HXyH36VBIa42mA7TaD5BYs6NFr25nvtOXynP4= X-Received: by 2002:a17:902:8a4:: with SMTP id 33-v6mr13262115pll.274.1521471811958; Mon, 19 Mar 2018 08:03:31 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Jesse Hathaway Date: Mon, 19 Mar 2018 15:03:00 -0000 Message-ID: Subject: Re: [PATCH] getlogin_r: return early when linux sentinel value is set To: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2018-03/txt/msg00456.txt.bz2 This is my first time submitting a patch, so any feedback would be very much appreciated. On Fri, Mar 16, 2018 at 11:18 AM, Jesse Hathaway wrote: > When there is no login uid Linux sets /proc/self/loginid to the sentinel > value of 4294967295. If this is set we can return early and avoid > needlessly looking up the sentinel value in any configured nss > databases. > > diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c > b/sysdeps/unix/sysv/linux/getlogin_r.c > index 73ea14c8f9..43f55a2188 100644 > --- a/sysdeps/unix/sysv/linux/getlogin_r.c > +++ b/sysdeps/unix/sysv/linux/getlogin_r.c > @@ -55,6 +55,12 @@ __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 4294967295, so check if the value is set and return early to > + avoid making unneeded nss lookups. */ > + if (uid == 4294967295) > + return ENXIO; > + > struct passwd pwd; > struct passwd *tpwd; > int result = 0;