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: 886950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-91098-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mbuki-mvuki.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="qHZbfGVs"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 402rHX1KP5z9s8f for ; Sat, 17 Mar 2018 03:18:47 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=ugxqdRuPvGTiHKSUKx+eA0StOtEMD c0El+dCuIQQPJ94AtgQp5i9KnZ8h0PqL7elBaDWfyOF7tYIb61fuxTfELLScMkdG c6Tnu23m8NUT0uYSjgGsSucqIIvJPUMd1VbjvoWEPq5Vmk1RHuZbckfDvcE1Qetb FIv4ewn0My2pys= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=DorJvaeK8FXxIi+eAojZL0UEDf0=; b=qHZ bfGVsNFXP8gAcfW6XHVmknvRBoQ8QtAiKDpQ0jbD4ycTf5J3RVJjfUpC6OsWy3Ud 7bRgVk0wlFSvZSKq3Oq0UiOsriPABODwj27X3uAqMtAP3uVNyoO1t197IxosbqWb BA8D9bHwhh9N8JgVh8wx958Dx79fzZ8DyjhypbIg= 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. Reviewed-by: Adhemerval Zanella 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;