From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A15261F461 for ; Thu, 28 Mar 2024 15:12:02 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Y5wBkEdX; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 599583858D33 for ; Thu, 28 Mar 2024 15:12:01 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E5C633858D1E for ; Thu, 28 Mar 2024 15:11:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5C633858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E5C633858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711638700; cv=none; b=RWzCfBfDw8XVm9Tkuo4+Hacqa+5FWATMPgpiWtCPoIo808YFp69DYn4+KSOkSqwH/btaIpluADxUcSRD/Dfzb91lioVggD4YutSmlqwq+efjC7bk6Y+cyLvYMe+qt4CsgC/HdW5RGqqC4CRP+wijzxflHxptt+0hZt4dYFoorto= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711638700; c=relaxed/simple; bh=aVRpS+FqUVJ0dyeOfRWV5QX2w814I/faHeM1AW/ds6M=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=k7kjezD/EMXqSqCMWyf4CVwWfInSGrc2fRfVOMS6zG3OR9UsWgiszQWgr9KHHlpuUkfLJnytD0AKTiX8N+n9exm7e40i7Vv3xF3Sd66L6Kuey/t0E62GDLZBUz6HoKTajlcjceLPDSqVf+zGduduRuNWxTSzIniEIBNCrN49SvQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711638698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O4YG9XQSgYXE+7cWtNJxmfq61PMVmMc5UuqHkXC12gw=; b=Y5wBkEdXrM+VpQ3ZuaesAH2RcG3iAGl8vsW57X9a4Oz3lGxhVLhj+2XIwEcIzmjuTp/zeA 2cP5bEmQJw3g14HZ+F95sI2epL8sbaBgpEyGjdDxJS5OTqY4lOximSYMRoET9ELHa1QWdN 5jUQInWebuyHtwKfwiAhdWS+gUM9+NI= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-WsifWJtxOeCHytN_tWc8yQ-1; Thu, 28 Mar 2024 11:11:36 -0400 X-MC-Unique: WsifWJtxOeCHytN_tWc8yQ-1 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1dff9fccdbdso8501025ad.0 for ; Thu, 28 Mar 2024 08:11:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711638695; x=1712243495; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O4YG9XQSgYXE+7cWtNJxmfq61PMVmMc5UuqHkXC12gw=; b=A2xpBYWFNkglAAE9YYF2F5FL4AEqH2ZGcP1v7b6+8XvsuV27v6wAodQfyz/jZ6kZRO no4v9dgGAZ3Qm96ONapVZuCQ1uMfVAXR/w4ySapAUAIvWGx2BTzuz0iSubo1VCvG5xVp eOsTiaPL8pt5QjEkTxwyz/kQ0d9GKsRYJPBN6cYd86iHpmRHeEgFAz7kfdEVg1jD5ii3 wJZa3DK83woCEghD0j1PUpAsYndsHOsBfjxmvtdZy3zaFWEoUUsSRqDRA5U/oHe/11VL SgOGJg4KiHDna3kMqBO+gWZDCXzLZ5KScp6e2g4Dt5xo6R8Uq4dUozXRsmR9KJyUZzOJ ROPg== X-Gm-Message-State: AOJu0YwQTOVtHKvn/850+h9Al3Hqkx5OJGUg4abRKK2VCxdztUgxxASe B7i3/P/y9Q0yugLuPJ0z0Q0IEm/WM66y9daDi7ZzS2tt2pVaLv23QpAnNnoDdE2krihjp3UojlD pD5OhStA2Eq0gvxvEiyLodm5Wb6PtkZdROrcH2vTn1BcxaXdILLdajfNbVziGS2n0QqN/VN9tjH sRlbiW4L/9dwqETOrTKBuWJat8RBV5z1VD X-Received: by 2002:a17:903:32c7:b0:1e0:7bbf:bef4 with SMTP id i7-20020a17090332c700b001e07bbfbef4mr2869005plr.41.1711638695236; Thu, 28 Mar 2024 08:11:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHP5utupbbsJQkl6kgKbezGVnv4OqQsjJ05068DWLXPT6+lXsL94d7H/blzoEtX/rgfl208HeUQA9RuytIrgzw= X-Received: by 2002:a17:903:32c7:b0:1e0:7bbf:bef4 with SMTP id i7-20020a17090332c700b001e07bbfbef4mr2868970plr.41.1711638694755; Thu, 28 Mar 2024 08:11:34 -0700 (PDT) MIME-Version: 1.0 References: <20240327184324.916402-1-josimmon@redhat.com> <3733a0a9-211f-4ce2-9bc1-c032144afd45@cs.ucla.edu> In-Reply-To: <3733a0a9-211f-4ce2-9bc1-c032144afd45@cs.ucla.edu> From: Joe Simmons-Talbott Date: Thu, 28 Mar 2024 11:11:18 -0400 Message-ID: Subject: Re: [PATCH v11] posix: Deprecate group_member for Linux To: Paul Eggert Cc: libc-alpha@sourceware.org, Florian Weimer X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org On Wed, Mar 27, 2024 at 4:57=E2=80=AFPM Paul Eggert wr= ote: > > On 3/27/24 12:43, Joe Simmons-Talbott wrote: > > + int granted; > > + > > + if (uid =3D=3D stats.st_uid) > > + granted =3D (unsigned int) (stats.st_mode & (mode << 6)) >> 6; > > + else > > + { > > + if (((flag & AT_EACCESS) && stats.st_gid =3D=3D __getegid()) || > > + (!(flag & AT_EACCESS) && stats.st_gid =3D=3D __getgid())) > > + granted =3D (unsigned int) (stats.st_mode & (mode << 3)) >> 3; > > + else > > + { > > + int gm =3D __group_member2 (stats.st_gid); > > + if (gm =3D=3D -1) > > + return -1; > > + else if (gm) > > + granted =3D (unsigned int) (stats.st_mode & (mode << 3)) >= > 3; > > + else > > + granted =3D (stats.st_mode & mode); > > + } > > + } > > > > if (granted =3D=3D mode) > > return 0; > > This is still too complicated, with repetitions of AT_EACCESS that were > not in the original. Come to think of it, it has unnecessary casts and > repetitive shifting and masking, and that indentation of || is not GNU > style. How about something like the following untested code instead? > > int shift; > > if (uid =3D=3D stats.st_uid) > shift =3D 6; > else > { > int gm =3D (stats.st_gid > =3D=3D (flag & AT_EACCESS ? __getegid () : __getgid ())); > if (!gm) > { > gm =3D __group_member2 (stats.st_gid); > if (gm < 0) > return gm; > } > shift =3D gm ? 3 : 0; > } > > if ((stats.st_mode >> shift & mode) =3D=3D mode) > return 0; > I like that much better. I've posted a v12[1] with your suggestion that was tested via 'make check'. Thanks, Joe [1] https://sourceware.org/pipermail/libc-alpha/2024-March/155666.html --=20 Joe Simmons-Talbott