From nobody Thu May 1 19:51:46 2025 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZpPnt34NYz5vdvK; Thu, 01 May 2025 19:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZpPnt0xxjz46qk; Thu, 01 May 2025 19:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746129106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oS+7wNCXEyoG+9otqsdQ14hF1AZuKogQa9UaO99RQSI=; b=hXZrceCdOvqr+rpb3fd7vhxMr0t98mc3hXDn1bxAqPVBlinboQ/bD7EBdPqv8PN6DykMS+ choCeBYEYvsqy9t1cpSax3cWvoUVTYsoSwacRaAh5jHvJS8m4lln3lKcKPPCNMoZVsA70h yBAmjvD+3n2Ah7iS7y4F48j00fnYurucVP/gZOpHxGx2b+8E1Hmprt1/hGhNqKA3Hi5Xo5 Bek2byDUgVN5S/Ud6Gj0T/sPVIKuOPjqfGBgBWCUW1kt88tDzpdrayLPTeVgFNn1cTaIsg BGNh5Gu0gGqjfDkfXfyfPWGHYXvrX+RWjgjxZ3HalWxVI5W3LhFMpBLyMYQQTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746129106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oS+7wNCXEyoG+9otqsdQ14hF1AZuKogQa9UaO99RQSI=; b=SX7+RsPblWBiiZdnoTuiBzvypl49XRPQwJyOtYMq1MMaqgM9+XKg8hbWMSGEubIWdt81iC 7W/UfT2tYKriSNQAdAqElSda1vjSw+pxAJnDQG8HetGpzWRj5F0DsiA/9yoa19c0Gw4T+N +hZn9pvGIgaqiRMCQtgFcGx7lBiaRV/BaQsa3NkTqQ3WHenBrSwCB632AkOAphxhqyfiy2 Hf0raqJ2qmxja1RmMSanurp/Aumo3zp1c00A0TlRWK9yYUHI/28d07XP3DSHLwrMGxOvEy vLOclH5Hh/uJGEHeKrqqCTdP2CffTiAwAIKlvCTL2KkhkFnlj1BrCMNEH70xOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746129106; a=rsa-sha256; cv=none; b=qbTsXtnm+jVPn+ELBF8XsjF/ugTau+I5pGqKwWJmbtSuYU4PSpp10xk7yNTvpy3E5C5WWy MBh4b3cubqpE+qGzvD2mGEv+7qRxHh+rSoI8RKnudr2YEj9jfHODl3O4r8BYuFycIJogXF DKEcgmx1cFMFVccEkWWcovLWZcvrsRx0/036tZN8XMpOcUBzjYtYZKZ21hVkP+/oo3KI7K rF+HCmASVLQTlhtwK7IIsDjXtU8rsxrezGrFDZ8yYXCNyew185DUK/RYqYoSB3hMq8tJhw McPrh6K0/83hgo/o3c8pfAOhQivQbJBQLYQpeekinaAC3ow9+X1j/3tY5dslew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZpPnt0YLVzhyR; Thu, 01 May 2025 19:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 541JpkKj068788; Thu, 1 May 2025 19:51:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 541JpkT4068785; Thu, 1 May 2025 19:51:46 GMT (envelope-from git) Date: Thu, 1 May 2025 19:51:46 GMT Message-Id: <202505011951.541JpkT4068785@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: a2132d91739d - stable/14 - ps(1): '-U' to select processes by real user IDs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a2132d91739dc22b99e7da836c81962eed47b8f9 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=a2132d91739dc22b99e7da836c81962eed47b8f9 commit a2132d91739dc22b99e7da836c81962eed47b8f9 Author: Olivier Certner AuthorDate: 2025-04-01 13:07:24 +0000 Commit: Olivier Certner CommitDate: 2025-05-01 19:42:25 +0000 ps(1): '-U' to select processes by real user IDs This is what POSIX mandates for option '-U' and arguably the behavior that most users actually need in most cases. Before, '-U' would select processes by their effective user IDs (which is the behavior mandated by POSIX for option '-u'). Matching by real user IDs allows to list all processes belonging to the passed users, including those temporarily having a different effective user ID, which can happen if launched by a setuid executable or if using some credentials-changing facility (such as seteuid() for root processes or mac_do(4)/setcred(2)). Conversely, processes temporarily assuming the identity of some of the passed users will not be listed anymore (they do not "belong" to these users). This change also makes '-U' consistent with '-G', the latter already matching on real group IDs. While here, remove the (non-compiled) code for tentative option '-R' as its proposed behavior was the one established here for '-U'. Also, move the compiled-out old code for '-U' under '-u' for reference, as this is what the latter should do according to POSIX, even if it seems unlikely we will want to change the behavior of '-u'. Reviewed by: manpages (ziaee) MFC after: 3 days Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49622 (code) Differential Revision: https://reviews.freebsd.org/D49623 (manual page) (cherry picked from commit 995b690d1398044dc9d85a6d86ec550cda30b2ac) --- bin/ps/ps.1 | 14 +++++--------- bin/ps/ps.c | 37 ++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 1814a3fca1b3..329ec4180503 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -367,8 +367,8 @@ Implies .Fl x by default. .It Fl U -Display information about processes whose effective user ID matches the -specified user IDs or names. +Display information about processes whose real user ID matches the specified +user IDs or names. Implies .Fl x by default. @@ -953,20 +953,16 @@ equivalently to .Pc , and option .Fl u -to select processes by effective user ID -.Po -which is the current behavior of option -.Fl U -.Pc . +to select processes by effective user ID. .Pp However, options -.Fl A , a , G , l , o , p , +.Fl A , a , G , l , o , p , U , and .Fl t behave as prescribed by .St -p1003.1-2024 . Options -.Fl f , U , +.Fl f and .Fl w currently do not, but may be changed to in the future. diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 786537a0e959..c78809b218d5 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -381,20 +381,6 @@ main(int argc, char *argv[]) */ nselectors++; break; -#if 0 - case 'R': - /* - * XXX - This un-standard option is still under - * debate. This is what SUSv3 defines as - * the `-U' option, and while it would be - * nice to have, it could cause even more - * confusion to implement it as `-R'. - */ - add_list(&ruidlist, optarg); - xkeep_implied = 1; - nselectors++; - break; -#endif case 'r': sortby = SORTCPU; break; @@ -426,21 +412,34 @@ main(int argc, char *argv[]) nselectors++; break; case 'U': + add_list(&ruidlist, optarg); + xkeep_implied = 1; + nselectors++; + break; + case 'u': +#if 0 /* - * POSIX says that '-U' should match on real user IDs, - * not effective ones as we are doing here, which is - * normally the behavior of option '-u' according to the - * standard. + * POSIX's '-u' behavior. + * + * This has not been activated because: + * 1. Option '-U' is a substitute for most users, and + * those that care seem more likely to want to match + * on the real user ID to display all processes + * launched by some users. + * 2. '-u' has been a canned display on the BSDs for + * a very long time (POLA). */ add_list(&uidlist, optarg); xkeep_implied = 1; nselectors++; break; - case 'u': +#else + /* Historical BSD's '-u'. */ parsefmt(ufmt, &varlist, 0); sortby = SORTCPU; _fmt = 1; break; +#endif case 'v': parsefmt(vfmt, &varlist, 0); sortby = SORTMEM;