From patchwork Thu Mar 22 13:49:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Hathaway X-Patchwork-Id: 26430 Received: (qmail 14648 invoked by alias); 22 Mar 2018 13:49:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 14633 invoked by uid 89); 22 Mar 2018 13:49:51 -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:k22-v6s X-HELO: mail-pl0-f50.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:cc; bh=iMZyRgBBTES+o1AZnl2aungVjrs7QtrzrykADxXIJn0=; b=cdnPo8xCZKc2WCadQKe2W5nKS7geqHgfMphw51KsxxbcdR12q47gSmGTaNeOfqsZ2Q vkaj3+R6Ud1anApusZoWscSrHW7A89m74NjJDU5l0olcLb90ByBDVUK++cMhIERoBLAY cPMHExapaDsPvi/rpSIlUWjK/5IB8ZRUG+Y2Tg2U1NZhHGcIwbw+Aqku6ODptfrJIADY qnwg+Ihu/d5CANJajd2crOEWdz59gdmdYCsjD92tTUEZ91Af+WkYmvHsNyrD4Cq0r38K HNY7CsUvqE/YD61YZTQFnd6TfIyzGEzKVc4OCGQu0098wPgfoX1biuI7X+888SE+2shy 58xw== X-Gm-Message-State: AElRT7HkwgqRHrebrFwISbrHcfY1jxN/DNaLmfIIUIaQ+RLww7t5fUQ7 0k75jW9fPQSXMxla6CmyPhaqXrT0CCggbbJZRASaVubT X-Google-Smtp-Source: AG47ELuyQhnH+05c/jMZ1aRqCZvabCa4B/q1c9RBsPje4NagECUQWOkpCOUjdwNMUysr786cB6ac8c1Jm1bZ2ZKMy18= X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr20049940pla.22.1521726586736; Thu, 22 Mar 2018 06:49:46 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <73b04097-ef36-b597-4f7c-2e73c6eb9fa3@linaro.org> <877eq6ppkw.fsf@linux-m68k.org> From: Jesse Hathaway Date: Thu, 22 Mar 2018 08:49:45 -0500 Message-ID: Subject: Re: [PATCH] getlogin_r: return early when linux sentinel value is set To: Adhemerval Zanella Cc: Andreas Schwab , libc-alpha@sourceware.org On Thu, Mar 22, 2018 at 1:14 AM, Adhemerval Zanella wrote: > LGTM with CL bit fixed below. Do you need someone to push it for you? Thanks for the review, if you could push it that would be great, updated patch attached which fixes the changelog entry commit 2fe96a5e58bb1b4ab379d1e7a85925bd83755cf7 Author: Jesse Hathaway Date: Fri Mar 16 10:46:50 2018 -0500 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. diff --git a/ChangeLog b/ChangeLog index 3399e567b8..5d776d995f 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. + 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;