johalun / sysctl-rs

A simplified Rust interface to the sysctl system call
MIT License
51 stars 23 forks source link

Wrong type on macOS #32

Closed johalun closed 2 years ago

johalun commented 3 years ago

The sysctl security.mac.asp.active_rule_version returns wrong type (integer instead of long unsigned) which is causing tests to fail when the value wraps over to negative value.

sysctl -d security.mac.asp.active_rule_version reports LU as type. Maybe use descriptions as source for types instead of current method?

StephanvanSchaik commented 2 years ago

I ran into this issue myself while writing a kernel extension for Mac OS that exposes sysctls. Mac OS does not define a CTLTYPE_ULONG and instead expects you to use CTLTYPE_INT and specify "LU" as shown in the kernel source code here.

More specifically, the comment here also states that the format string should instead be used to figure out how the value is formatted as a string by the sysctl tool on Mac OS. That means that on Mac OS, the sysctl-rs crate should also use the format string to figure out the integer width of the value.

johalun commented 2 years ago

Fixed with #49