From patchwork Mon Mar 26 14:22:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Hathaway X-Patchwork-Id: 26481 Received: (qmail 99726 invoked by alias); 26 Mar 2018 14:22:31 -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 99712 invoked by uid 89); 26 Mar 2018 14:22:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, 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=databases X-HELO: mail-pg0-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=e7qcUxkhR6wcvnuqGV/G3NlyZNS2RczWk0ogsgy+yog=; b=IfHLK+xLtx3R95kUpRv/9jThwuFgspwSIY4/qpqiewYwSxjvhmLvB/O1BkX5LLS/0P meMXRPzNNtBdAVvF1WjyDbFLOPHxGoF5QkQH3n0SbzOkAlmWfyiELUIFzHJqYKzwDvw7 /njHRH1lZffQcgpjRAtaAEToTkWP4YZJVNG96uDK0rRJvMOidS6eCcLGWUpQrOpBi7K8 THRTWuW8iXf3/87jeKGySjiGBsxKi6MP9JFuomfqdmWdmZhkR/9v+pW2N7LO1mMM5Ra/ WjMWzZruJoQzl/nlaLc7L9WUIpp5Cz3e8OH3CCWulKAo8/UkisfaN8/PdUrqYv+422+S S/mg== X-Gm-Message-State: AElRT7GDkQ/3mSlAaBgtTT4jPMjLyIlh5Xgk5lFJc9+p/waRnrCbg1j6 GNmCD8pL5OyaDgN+10RjbbW/gxdqbO7ZJqYfjBFa+g== X-Google-Smtp-Source: AG47ELtSSRk6UH7RNqVi6lqdFfi2Tycxk0x1nS7ONy51WFFg0ky4zjLuL2F4Yy1FRbWCZYywIE6TBJlVFdM7TAHrmEw= X-Received: by 10.99.115.68 with SMTP id d4mr28964728pgn.145.1522074147479; Mon, 26 Mar 2018 07:22:27 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <73b04097-ef36-b597-4f7c-2e73c6eb9fa3@linaro.org> <877eq6ppkw.fsf@linux-m68k.org> <87370s9fns.fsf@linux-m68k.org> From: Jesse Hathaway Date: Mon, 26 Mar 2018 09:22:26 -0500 Message-ID: Subject: Re: [PATCH] getlogin_r: return early when linux sentinel value is set To: Andreas Schwab Cc: Adhemerval Zanella , libc-alpha@sourceware.org On Thu, Mar 22, 2018 at 2:30 PM, Jesse Hathaway wrote: > fixed, attached Adhemerval Zanella would you be able to push this for me? commit 7d60c6ab90d23bab16adc2809de95f99e84862d5 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..14587712a7 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;