From nobody Mon Apr 28 12:23:37 2025 X-Original-To: dev-commits-src-main@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 4ZmN0B1pvHz5vJRf; Mon, 28 Apr 2025 12:23:38 +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 4ZmN095YS1z3g8V; Mon, 28 Apr 2025 12:23:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745843017; 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=MIqKF7NQYId8vXYt6fT7pvWKfFpC2jLu2JZMYhAM5AA=; b=SvhDTjaitWshkRbHyX8n/ZzF2fyO1Z3X4TUJW6C+VGgQOiwuYdesIB0FQ5V37aIwAgx7q+ PPtwN4O9KVJ0N2+D+B/57xyWQx6ZApLZKuVDDkLUO9QAZrOdjJLZyd0LazO07WGfn/ylsI O/gJRKnXoiSkpgd1GjrF5PK6szkSCmmQpiopm4mAAEVRKrgEGGv4OjDOes6/VOympuldRy fJIUt2NcbuIdy/CLTBaGppjBEkZBTa1EP+PerCRBljkrcx3KIZI8iEa6p2wSnJbcttv1dt /hkhDFJXzF4tX9v5F+p34suZC3rGI1ewbQwxgtuDN94zqC5l41QV7vVB6WB2yA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745843017; a=rsa-sha256; cv=none; b=TCa835XhHUTDPvJCQVz4MqA6VwanXLNrBYeP0HMOekii1NDyA1m3yjS8NpPdrLSJvluDq8 PI2rwDT8oj+tzwaZC4i4WCxzN3h37/n+mq4IvW4KjHT9lhdyku+nLaU/tqJhpiYQdmbElW JSJHKvVGovgg01alrfUCYs5nULYlhG+AdjpYb5KjJ/05arCby1L3p2RS4lSSQnrokxw/Fw IfQpSqqgaK0RHoPrC2HyG+GAG8DZkOTF8JrNtGeWUsAean721xntbanKsOo/ooRAsiv4fM uNdfC8Y8BOBzG6iyKc5DxXa5zyBO/LFSTf9+0inwUhdO7G3gNITJHgbmZnjfJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745843017; 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=MIqKF7NQYId8vXYt6fT7pvWKfFpC2jLu2JZMYhAM5AA=; b=QzGXu1Jx9sbPYp9huQcIu6MIu88SomJ/vq83rnnFvwHXu63fm5t0H4tQ6jA1x2PI6jc5Jl mCkG0/gzIealagMvnmWQ3y8io8L2uhojZ6aFyI/ms/A98q57r+pvchNfRt+kLBCghDkcIe A8K5dMgEwkJbqu1pLPodU2MrviZMdoYGZVF+f0cB0480GB1YuVT8bSWIl4fmfoRH4NAy8D X2RDW0ChsaVtUC5m5taoCJWSepOqq4sqz8qhTTwbeTIwzDcc4QsIvrUMYOuMjBXTP6fqKv 9mz0nDV5m/wyJt1yuw4fVg+Hr6YVX5zGMfYL66B1cUo46tOQP0OyZ7MuQ5sk9g== 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 4ZmN0957lbzbwG; Mon, 28 Apr 2025 12:23:37 +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 53SCNb0n025689; Mon, 28 Apr 2025 12:23:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53SCNbSL025686; Mon, 28 Apr 2025 12:23:37 GMT (envelope-from git) Date: Mon, 28 Apr 2025 12:23:37 GMT Message-Id: <202504281223.53SCNbSL025686@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 995b690d1398 - main - ps(1): '-U' to select processes by real user IDs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 995b690d1398044dc9d85a6d86ec550cda30b2ac Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=995b690d1398044dc9d85a6d86ec550cda30b2ac commit 995b690d1398044dc9d85a6d86ec550cda30b2ac Author: Olivier Certner AuthorDate: 2025-04-01 13:07:24 +0000 Commit: Olivier Certner CommitDate: 2025-04-28 12:18:26 +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) --- 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 174f18a2f2d9..ff9a847ffd86 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -371,8 +371,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 6c007e8fc1a1..a75ea512ad54 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -356,20 +356,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; @@ -401,21 +387,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;