From patchwork Thu Mar 30 11:09:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 1763189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=QNtgDS5g; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PnLKh2tZbz1yXv for ; Thu, 30 Mar 2023 22:09:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A60438559A5 for ; Thu, 30 Mar 2023 11:09:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A60438559A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680174582; bh=TkDq18o8l0sri4dD6BAJhPtP8/SCMd45bDwcxhEGoDk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QNtgDS5gHV2eyOkqE+6o9XedMsfe2RPSkQa/RTrR6FD4REr4VOpLFF1q/Io79aRDQ 41RWLnypbsH2yf1VxgEY5sOl8kE4O2HOANUFrd3GRh8pbzUReQiCjMAuS5H62fGKV0 Iy5u4rW2YT7eKtk9Gcezy6TSV1iD/ZcW4/Ni2EUQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id E5E213858C78 for ; Thu, 30 Mar 2023 11:09:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5E213858C78 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2A8C51FEC8 for ; Thu, 30 Mar 2023 11:09:24 +0000 (UTC) Received: from hawking.suse.de (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id 20DBA2C423 for ; Thu, 30 Mar 2023 11:09:24 +0000 (UTC) Received: by hawking.suse.de (Postfix, from userid 17005) id 138264A0378; Thu, 30 Mar 2023 13:09:24 +0200 (CEST) To: libc-alpha@sourceware.org Subject: [PATCH] getlogin_r: fix missing fallback if loginuid is unset (bug 30235) X-Yow: I'll take ROAST BEEF if you're out of LAMB!! Date: Thu, 30 Mar 2023 13:09:24 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andreas Schwab via Libc-alpha From: Andreas Schwab Reply-To: Andreas Schwab Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" When /proc/self/loginuid is not set, we should still fall back to using the traditional utmp lookup, instead of failing right away. --- sysdeps/unix/sysv/linux/getlogin_r.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index 879df85a16..4ae9a53503 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -59,10 +59,7 @@ __getlogin_r_loginuid (char *name, size_t namesize) 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; - } + return -1; struct passwd pwd; struct passwd *tpwd;