From patchwork Fri Mar 16 16:18:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Hathaway X-Patchwork-Id: 26340 Received: (qmail 20017 invoked by alias); 16 Mar 2018 16:18:42 -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 20002 invoked by uid 89); 16 Mar 2018 16:18:42 -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=loginid X-HELO: mail-pf0-f172.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:from:date:message-id:subject:to; bh=3o4pQQxExuzfg0qpeKuLhxWhwk1IssMJ3EgEbN4RC7w=; b=b4qcu+qbMXdIUYa9XtuTaoOcwMSSEPSntUj7rXtDpSXadGYRnUF/J5IjAyxQ/D7Y5R 0qf5ArC/Ceva63hOAtV6+YHgmWGmSRW5ToeCpwwaMy1xG1Qnq1MXx1LUZeWAv149iL5x UtUyWuflIUcTgzjJ88jjpEy+9a2aK/a+l+W6RKGZbKXEDJh9Kr09WxS8s4sBz4cgVswP L02e+HAUZZKmgakr0QzI2iBnPGLHs67+6z3xgHw7MP85jsEyGv0aczffjw6U5SyVHVLh iiAlT9YP8QX1IJmrSySXpQk6sx52tFkzGq+HOOqA1RbxAgkwAfAfjCvcJqwl4F6OanIM c/Ug== X-Gm-Message-State: AElRT7HVwDtUpunihGtPXxa31NBQ07SCCc09gCUleWzu35mpPx5b9H3u qkY94QWIbIBoFIDkHk1Y0/sHpbQP7sJ6fO2G0y9sgylz X-Google-Smtp-Source: AG47ELvuXFQOmUkQki20wHZvfrFAwJ9ENcMJ/M76ZVvUSstom24/HbDznd0XsHpGwNgmO4taLAnOGmmLsLdH+Gxe8Rs= X-Received: by 10.98.27.10 with SMTP id b10mr2043617pfb.121.1521217118724; Fri, 16 Mar 2018 09:18:38 -0700 (PDT) MIME-Version: 1.0 From: Jesse Hathaway Date: Fri, 16 Mar 2018 11:18:38 -0500 Message-ID: Subject: [PATCH] getlogin_r: return early when linux sentinel value is set To: libc-alpha@sourceware.org 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;