From nobody Sat Nov 16 13:50:50 2024 X-Original-To: dev-commits-src-all@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 4XrFf26xPjz5dPfK; Sat, 16 Nov 2024 13:50:50 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XrFf26V7Sz40cp; Sat, 16 Nov 2024 13:50:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731765050; 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=/H8sTvwGnZy+8YOaHpQWXuV9y4piyQvNhaU2qhGrSwU=; b=deKwBVNT2WziPO08k4piTvgpm5mEFbodKysX0foHnhFAfVuMTKZlDXRx35GgeKp57Y3JV2 fHUCWIPhpA+haJNXjS5+e4AAnxcd3OWtK0atQVfgsF8+xHwmUrIpNkkYMplFpZzCz8fq6W z2LdwdbrJds3f1OExDKiiPO5HyoE1nQ2g/SBsCUoA8oGq80HSKuOhJUHqhZM62jVbuuBJl s8ky4FUpIAmDZgQ51fSgpcU4gHnwzYH5U7DPhnq/tUa7g/HXudjyQBun/y9xQr1NX1IpFs rFb5aarFPOtI+PAoB5j9pDIkfFf5PQrwYxgV/R6TxVuTYbzhCHam6T4PL8p5Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731765050; 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=/H8sTvwGnZy+8YOaHpQWXuV9y4piyQvNhaU2qhGrSwU=; b=czPVC3TcTGGVYdC67TEG1uwEqaZY3fqWXkEDwFbHdep+i2j/xPyqJjwuuyIBcbgQT8NdJO C8clP/+/JUnHX+/gONZ4ACMUkT2eMnO2+Fjv6flpTcVqnzCInilm/UIJ5J24BYUDGwQZbp +WIDgN4I+WBovqfWDeXHEm8GgqTFmZ286F2YVdlYMXUNeTUzL2C2b090qf+peb7ZpY5s+v NjADRyNVPsS3DJR1ZFADgENPTmETLHy+5NUWVg3Z01AQyeOU6BLlrH0a1oFRDh8zdrdyVm eBxHz3dtuB05nkxvzvdSv7OVgPoQ7PIN/wYEGWyK6dPdDDH57oB4DbuueVlrJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731765050; a=rsa-sha256; cv=none; b=ewjcZtX4u85v6TtUlLTsco8creDRFHgPr5/04Q7f7XkGMBeDO2CmoqEZkRklYkpXzJ0SRq 6+Y9tOI+Y7P4sEdQuwCaaCBeBicN6p1JmzvSbeTbeJ6ETRKbIDuiCUUQ9plsJ6e2+E75Mj Mnv7VgALcj41x1UCHY29N036EKWSoK9ED/U8F5IIfL01idaGE/55bMGX+VawfByhbk9LSt 2u/+L5m45yrqb2tbPFHwZrBvZgDeouve8GwVueUQGp6JBqipBGbHeBAvDGnY16b49cxosZ kGoTuKP2QtctgrL3OHYm01x2gle7AnArnAKB16FCKlEzqco/q1dWe2u8nFV4ew== 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 4XrFf21lFHz18Mx; Sat, 16 Nov 2024 13:50:50 +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 4AGDooSx035988; Sat, 16 Nov 2024 13:50:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AGDooXV035985; Sat, 16 Nov 2024 13:50:50 GMT (envelope-from git) Date: Sat, 16 Nov 2024 13:50:50 GMT Message-Id: <202411161350.4AGDooXV035985@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 615c9ce250ee - stable/14 - sysctl: Add flags to filter jail prison and vnet variables List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 615c9ce250ee7c92edf403350ed6663c3f54a1f2 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=615c9ce250ee7c92edf403350ed6663c3f54a1f2 commit 615c9ce250ee7c92edf403350ed6663c3f54a1f2 Author: Zhenlei Huang AuthorDate: 2024-10-29 11:26:11 +0000 Commit: Zhenlei Huang CommitDate: 2024-11-16 13:49:45 +0000 sysctl: Add flags to filter jail prison and vnet variables So users do not have to contact the source code to tell whether a variable is a jail prison / vnet one or not. Reviewed by: cy (previous version), markj, jamie (for #jails) MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D47107 (cherry picked from commit 5ec83c660acaf30c1d6b9417dbd8c80dfa9d56ac) --- sbin/sysctl/sysctl.8 | 9 +++++++-- sbin/sysctl/sysctl.c | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8 index 70115fa54318..fadc162b80c6 100644 --- a/sbin/sysctl/sysctl.8 +++ b/sbin/sysctl/sysctl.8 @@ -30,7 +30,7 @@ .\" .\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 .\" -.Dd August 18, 2023 +.Dd October 29, 2024 .Dt SYSCTL 8 .Os .Sh NAME @@ -113,6 +113,8 @@ The purpose is to make use of .Nm for collecting data from a variety of machines (not all of which are necessarily running exactly the same software) easier. +.It Fl J +Display only jail prision sysctl variables (CTLFLAG_PRISON). .It Fl l Show the length of variables along with their values. This option cannot be combined with the @@ -155,6 +157,8 @@ to standard error. Display only variables that are settable via loader (CTLFLAG_TUN). .It Fl t Print the type of the variable. +.It Fl V +Display only VNET sysctl variables (CTLFLAG_VNET). .It Fl W Display only writable variables that are not statistical. Useful for determining the set of runtime tunable sysctls. @@ -327,7 +331,8 @@ option has been deprecated and is silently ignored. .Xr loader.conf 5 , .Xr sysctl.conf 5 , .Xr security 7 , -.Xr loader 8 +.Xr loader 8 , +.Xr jail 8 .Sh HISTORY A .Nm diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index df388e41c560..8ec9089bd2cf 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -64,7 +64,7 @@ static const char *conffile; static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag; static int Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag; -static bool Fflag, lflag; +static bool Fflag, Jflag, lflag, Vflag; static int oidfmt(int *, int, char *, u_int *); static int parsefile(const char *); @@ -137,7 +137,7 @@ main(int argc, char **argv) setbuf(stdout,0); setbuf(stderr,0); - while ((ch = getopt(argc, argv, "AabB:def:FhilNnoqtTwWxX")) != -1) { + while ((ch = getopt(argc, argv, "AabB:def:FhiJlNnoqtTVwWxX")) != -1) { switch (ch) { case 'A': /* compatibility */ @@ -170,6 +170,9 @@ main(int argc, char **argv) case 'i': iflag = 1; break; + case 'J': + Jflag = true; + break; case 'l': lflag = true; break; @@ -191,6 +194,9 @@ main(int argc, char **argv) case 'T': Tflag = 1; break; + case 'V': + Vflag = true; + break; case 'w': /* compatibility */ /* ignored */ @@ -1049,10 +1055,18 @@ show_var(int *oid, int nlen, bool honor_skip) if (Wflag && ((kind & CTLFLAG_WR) == 0 || (kind & CTLFLAG_STATS) != 0)) return (1); + /* if Jflag then only list sysctls that are prison variables. */ + if (Jflag && (kind & CTLFLAG_PRISON) == 0) + return (1); + /* if Tflag then only list sysctls that are tuneables. */ if (Tflag && (kind & CTLFLAG_TUN) == 0) return (1); + /* if Vflag then only list sysctls that are vnet variables. */ + if (Vflag && (kind & CTLFLAG_VNET) == 0) + return (1); + if (Nflag) { printf("%s", name); return (0);