Bug 286306 - Feature request: be able to print default value of sysctl writable var
Summary: Feature request: be able to print default value of sysctl writable var
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-23 10:38 UTC by Piotr Smyrak
Modified: 2025-06-11 21:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Smyrak 2025-04-23 10:38:17 UTC
It would be useful to be able to invoke sysctl with an option that allows to show default values of the writable (non statistical) variables.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2025-05-23 15:43:42 UTC
I don't think this is really practical -- sysctls don't record their default values anywhere, and changing them to do so would be quite complex and require extra memory for each sysctl node.

One idea which might be close enough would be to have a "dirty" flag for sysctls which have been modified at some point, e.g., via the command line or sysctl(8) or a tunable.  So you could at least see that the sysctl was modified at some point.  But even this might be quite difficult to define--what if the default value of a sysctl depends on another sysctl's value, and that sysctl was modified.

Do you have some specific scenario where this would be useful?
Comment 2 Piotr Smyrak 2025-06-10 13:21:55 UTC
This FR occurred to me while scripting, and I thought that it would give ability to compare pristine system state vs a running one. 

Note, it was not about the defaults of /etc/defaults/rc.conf or /boot/loader/loader.conf.
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2025-06-11 21:39:14 UTC
Sorry, I think the feature is not likely to be implemented.  As I mentioned, it's quite non-trivial to implement, it has some overhead, and it's hard to define what "pristine system state" means.