aboutsummaryrefslogtreecommitdiff
path: root/sbin/sysctl
Commit message (Collapse)AuthorAgeFilesLines
* sysctl_test: Print standard error if sysctl -ao failsMark Johnston2025-07-081-0/+1
| | | | MFC after: 1 week
* sysctl: Add a regression test which runs sysctl -aMark Johnston2025-01-311-0/+57
| | | | | | | | | | | | Run sysctl -a during the test suite so that KASAN/KMSAN have a chance to catch something. Inspired by https://jprx.io/cve-2024-54507/ Reviewed by: jhb, emaste MFC after: 2 weeks Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D48659
* sysctl: Teach sysctl to attach and run itself in a jailZhenlei Huang2025-01-303-5/+60
| | | | | | | | | | | | | | This allows the parent jail to retrieve or set kernel state when child does not have sysctl(8) installed (e.g. light weighted OCI containers or slim jails). This is especially useful when manipulating jail prison or vnet sysctls. For example, `sysctl -j foo -Ja` or `sysctl -j foo net.fibs=2`. Reviewed by: dfr (previous version), markj MFC after: 1 week Relnotes: yes Differential Revision: https://reviews.freebsd.org/D48618
* sysctl: Refactor function parsefile()Zhenlei Huang2025-01-301-9/+10
| | | | | | | | | | Let the caller open the file and pass in the file handler. This can benefit an upcoming change so that we will have cleaner logic. No functional change intended. Suggested by: markj MFC after: 1 week
* sysctl: Sort optionsZhenlei Huang2025-01-232-21/+21
| | | | | | No functional change intended. MFC after: 1 day
* sysctl: Fix usage() and SYNOPSIS section of man pageZhenlei Huang2025-01-232-5/+5
| | | | | | | | | | I forgot to update the usage() and SYNOPSIS section of man page when adding the two options -J and -V. While here, fix the options sort order in SYNOPSIS section. Fixes: 5ec83c660aca sysctl: Add flags to filter jail prison and vnet variables MFC after: 1 day
* sysctl: Add flags to filter jail prison and vnet variablesZhenlei Huang2024-10-292-4/+23
| | | | | | | | | | 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
* sysctl.8: mark sysctls as vars per style.mdoc(7)Alexander Ziaee2024-09-211-76/+78
| | | | | | | | | + while here, fix alignment and tag SPDX MFC after: 3 days Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1421
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* sysctl(8): Fix typo in commentHao-Yu Hou2024-02-131-1/+1
| | | | | | | | Line214: combind -> combine Reviewed by: zlai Event: Advanced UNIX Programming Course (Fall’23) at NTHU Request: https://github.com/freebsd/freebsd-src/pull/966
* sysctl.8: fix format typoIgor Ostapenko2024-01-231-1/+1
| | | | Signed-off-by: Igor Ostapenko <pm@igoro.pro>
* sbin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sbin: Remove ancient SCCS tags.Warner Losh2023-11-272-3/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* sysctl: emit a newline after NULL node descriptionsEd Maste2023-10-101-1/+3
| | | | | | | | | | | Previously when printing the sysctl description (via the -d flag) we omitted the newline if the node provided no description (i.e., NULL). This could be observed via e.g. `sysctl -d dev`. PR: 44034 Reviewed by: zlei Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42112
* sysctl(8): Mention more security.bsd knobs; Refer to security(7)Olivier Certner2023-09-281-2/+7
| | | | | | | Reviewed by: mhorne, pauamma_gundo.com, emaste MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D41113
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-165-5/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* sysctl: tests: fix a couple issuesKyle Evans2023-03-012-6/+11
| | | | | | | | | | The function that sets test case metadata is actually named ${tc}_head rather than ${tc}, so add the suffix. While we're here, hook the tests up to the infrastructure so that they do get run. Sponsored by: Klara, Inc.
* Add -F option to sysctl(8) to display sysctl format.Kirk McKusick2022-12-255-30/+218
| | | | | | | | Also add a test to ensure that it is working correctly. Submitted by: ota_j.email.ne.jp Reviewed by: mckusick Differential Revision: https://reviews.freebsd.org/D34012
* sysctl.8: grammar nitCeri Davies2022-12-131-1/+1
|
* sysctl.8: Reference sysctl(9)Mateusz Piotrowski2022-06-301-2/+3
| | | | MFC after: 1 week
* sysctl(8): Mention CTLFLAG_SKIPColin Percival2022-03-201-2/+5
| | | | | | | | `sysctl -a` does not print values with this flag. Reviewed by: debdrup MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D34615
* sysctl: Small style fixWarner Losh2021-12-061-2/+1
| | | | | | Slightly reorder to make this look better. No functional change. Sponsored by: Netflix
* Fix building sysctl(8) after c78ad20Andrew Turner2021-05-011-2/+2
| | | | | In sysctl we parse an efi header on amd64. Fix this after changing the virtual memory type from a void * to a uint64_t in c78ad20.
* sbin/sysctl: Fix CTLFLAG_SKIP for adjacent nodesRyan Moeller2021-01-271-1/+2
| | | | | | | | | | | | | | The OID is saved when we encounter CTLFLAG_SKIP so that descendants can be skipped as well. We then must not update the skip OID until we are out of the node. This was achieved by resetting the skip OID once the prefix no longer matches, but the case where the OID we reset on has CTLFLAG_SKIP was not accounted for. Reported by: mav Reviewed by: mav MFC after: 2 days Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D28364
* sbin/sysctl: Style fixRyan Moeller2020-12-231-1/+1
| | | | | | | Remove parameter names from function prototype to match other prototypes in the file. Sponsored by: iXsystems, Inc.
* sbin/sysctl: Always honor skip in sysctl_allRyan Moeller2020-12-231-3/+1
| | | | | | | | | | | | | | | | Fix broken CTLFLAG_SKIP when present on the first child of the requested node. We don't need to ignore skip for the first node because in sysctl_all() we've implicitly visited the first node already when oid is specified. The first call to show_var() in here is after we have iterated to the next node. When the command line specifically requests a non-node sysctl we go straight into show_var() without calling sysctl_all(). Reported by: jhb Reviewed by: jhb Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D27674
* Use a dynamic buffer for the copy of a node's new value.John Baldwin2020-10-301-14/+21
| | | | | | | | | | | | | This permits setting a node's value to a string longer than BUFSIZ. Reported by: Sony Arpita Das @ Chelsio Reviewed by: freqlabs MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27027 Notes: svn path=/head/; revision=367188
* Update man-pages to describe the user.localbase variable added in r367179.Stefan Eßer2020-10-301-1/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=367184
* sysctl+kern_sysctl: Honor SKIP for descendant nodesRyan Moeller2020-10-241-2/+15
| | | | | | | | | | | | | | Ensure we also skip descendants of SKIP nodes when iterating through children of an explicitly specified node. Reported by: np Reviewed by: np MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D26833 Notes: svn path=/head/; revision=367009
* sysctl: Misc code cleanupRyan Moeller2020-10-241-113/+120
| | | | | | | | | | | | | | | | | | * Use defined SYS_SYSCTL names * Use memcmp instead of explicit loop * Use NULL instead of 0 for pointer value * Use __FBSDID * Reformat, improve comments in parse() No functional changes. Reviewed by: imp MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D26832 Notes: svn path=/head/; revision=367006
* Enable iterating all sysctls, even ones with CTLFLAG_SKIPRyan Moeller2020-10-051-14/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Add an "nextnoskip" sysctl that allows for listing of sysctls intended to be normally skipped for cost reasons. This makes it so the names/descriptions of those sysctls can be discovered with sysctl -aN/sysctl -ad/sysctl -at. It also makes it so children are visited when a node flagged with CTLFLAG_SKIP is explicitly requested. The intended use case is to mark the root "kstat" node with CTLFLAG_SKIP so that the extensive and expensive stats are skipped by default but may still be easily obtained without having to know them all (which may not even be possible) and request each one-by-one. Reviewed by: jhb MFC after: 2 weeks Relnotes: yes Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D26560 Notes: svn path=/head/; revision=366465
* Add sysctl(8) formatting for hw.pagesizes.Mark Johnston2020-09-021-0/+25
| | | | | | | | | | | | | | | | | | - Change the type of hw.pagesizes to OPAQUE, since it returns an array. - Modify the handler to only truncate the returned length if the caller supplied an output buffer. This allows use of the trick of passing a NULL output buffer to fetch the output size, while preserving compatibility if MAXPAGESIZES is increased. - Add a "S,pagesize" formatter to sysctl(8). Reviewed by: alc, kib MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D26239 Notes: svn path=/head/; revision=365268
* sysctl(8): clarify -n flagFernando Apesteguía2020-08-221-2/+2
| | | | | | | | | | | | | -n omits the name of the variable regardless of the type of information that is requested. Rephrase to clarify this point. PR: 242191 Submitted by: stilezy@gmail.com Approved by: emaste@ Differential Revision: https://reviews.freebsd.org/D26149 Notes: svn path=/head/; revision=364481
* evdev: export event device properties through sysctl interfaceVladimir Kondratyev2019-02-241-0/+19
| | | | | | | | | | | | | | | | | | | A big security advantage of Wayland is not allowing applications to read input devices all the time. Having /dev/input/* accessible to the user account subverts this advantage. libudev-devd was opening the evdev devices to detect their types (mouse, keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible. With the kernel exposing this information as sysctls (kern.evdev.input.*), we can work w/o /dev/input/* access, preserving the Wayland security model. Submitted by: Greg V <greg@unrelenting.technology> Reviewed by: wulf, imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D18694 Notes: svn path=/head/; revision=344494
* Remove -R option which was added to sysctl(8) man page per r244106, but it ↵Guangyuan Yang2019-02-091-3/+3
| | | | | | | | | | | | is not implemented. MFC after: 3 days Submitted by: Alfonso Siciliano <alfix86@gmail.com> Reviewed by: 0mp, imp Differential Revision: https://reviews.freebsd.org/D19012 Notes: svn path=/head/; revision=343930
* sysctl(8): Add a standard exit status section.Mateusz Piotrowski2018-09-241-1/+3
| | | | | | | | | Reviewed by: bcr Approved by: re (gjb), krion (mentor) Differential Revision: https://reviews.freebsd.org/D17147 Notes: svn path=/head/; revision=338920
* Improve handling of the EFI map types[] array.Konstantin Belousov2018-09-081-18/+19
| | | | | | | | | | | | | Use nitems(), do not assume EFI_MD_TYPE_ contiguous allocation, in particular, switch to use designated array initializers. Reviewed by: jhb (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (gjb) Notes: svn path=/head/; revision=338533
* Teach sysctl(8) about the Persistent memory type.Konstantin Belousov2018-09-071-2/+3
| | | | | | | | | | | | Add PersistentMemory to the list of sysctl's known memory types when decoding an EFI memory map. Submitted by: D Scott Phillips <d.scott.phillips@intel.com> MFC after: 1 week Approved by: re (rgrimes) Notes: svn path=/head/; revision=338523
* Trim whitespace.Konstantin Belousov2018-09-071-2/+2
| | | | | | | Approved by: re (gjb) Notes: svn path=/head/; revision=338522
* Move sysctl.conf to sbin/sysctl/ and switch to CONFS.Brad Davis2018-08-112-0/+10
| | | | | | | | | | This helps with pkgbase to tag this config file as a config file. Approved by: allanjude (mentor), will (mentor) Differential Revision: https://reviews.freebsd.org/D16559 Notes: svn path=/head/; revision=337624
* Permit sysctl(8) to set an array of numeric values for a single node.John Baldwin2018-03-092-93/+135
| | | | | | | | | | | | | | | | | | | | Most sysctl nodes only return a single value, but some nodes return an array of values (e.g. kern.cp_time). sysctl(8) understand how to display the values of a node that returns multiple values (it prints out each numeric value separated by spaces). However, until now sysctl(8) has only been able to set sysctl nodes to a single value. This change allows sysctl to accept a new value for a numeric sysctl node that contains multiple values separated by either spaces or commas. sysctl(8) parses this list into an array of values and passes the array as the "new" value to sysctl(2). Reviewed by: rpokala MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D14569 Notes: svn path=/head/; revision=330711
* Improve sysctl(8) pretty printing of some structures.Konstantin Belousov2017-11-261-20/+21
| | | | | | | | | | | | | | | | | | S_vmtotal: Use unsigned format to print unsigned memory counters from struct vmtotal. Remove unneeded cast, style locals declarations. S_efi_map: Make printing of the memory regions descriptions less MD by using uintmax_t formats. Noted by and discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=326226
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* kern.osreldate is an integer, not a stringAllan Jude2017-09-161-1/+1
| | | | | | | | | PR: 217501 Submitted by: Yavuz Tanriverdi <stemix@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=323645
* Don't request CTLTYPE_OPAQUE if we can't print them.Andrew Gallatin2017-07-311-18/+26
| | | | | | | | | | | | | | | | | | | The intent is to skip expensive opaque sysctls like tcp_pcblist unless they are explicitly requested. Sysctl nodes like this don't show up in sysctl -a, but they do generate output that winds up being dropped, unless the user specifically requested binary/hex output or opaques. This reduces the runtime of sysctl in many circumstances on a loaded system. It also reduces the likelihood that simply gathering diagnostics on a sick machine (stuck lock, etc) via sysctl -a might push it over the edge into a total lockup. Reviewed by: jtl Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D11461 Notes: svn path=/head/; revision=321790
* Renumber copyright clause 4Warner Losh2017-02-282-2/+2
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436