sysctl-rs makes extensive use of sysctl oidfmt to look up the type and format of sysctls. Unfortunately, this is not allowed on non-jailbroken iOS as any such calls return -EPERM. Instead, we should be using sysctlbyname on iOS, which means that we are way more restricted since we cannot look up the type or format, and as such the user will have to provide these for full iOS support. In addition, the original implementation does work on jailbroken iOS, so we want to keep that option available (e.g. you could first try using Ctl::new() and then fallback to Ctl::new_with_type() to support both).
This PR changes the following things:
Ctl in unix.rs is now an enum that either contains the oid or the name + type + format string.
Ctl in unix.rs implements oid() to return a reference to the oid, in case the underlying Oid variant is used. This is a breaking change (requires a version bump to 0.5.0), as Ctl used to contain a pub oid that now no longer exists.
The Sysctl trait is extended with a new_with_type() function to construct a Ctl from a name, type and format string. On other platforms (i.e. not MacOS or iOS), this function will simply ignore the type and format string and instead fallback to the original oid implementation as that works fine.
To get/set the value for the named Ctl variant, there are now functions that use sysctlbyname + the supplied type and format string instead of sysctl + oidfmtinternally.
CtlIter still uses oids, but that is fine. As on iOS this should just fail gracefully. That does mean that you cannot iterate over the available sysctls on a non-jailbroken iOS.
sysctl-rs makes extensive use of sysctl oidfmt to look up the type and format of sysctls. Unfortunately, this is not allowed on non-jailbroken iOS as any such calls return
-EPERM
. Instead, we should be usingsysctlbyname
on iOS, which means that we are way more restricted since we cannot look up the type or format, and as such the user will have to provide these for full iOS support. In addition, the original implementation does work on jailbroken iOS, so we want to keep that option available (e.g. you could first try usingCtl::new()
and then fallback toCtl::new_with_type()
to support both).This PR changes the following things:
Ctl
inunix.rs
is now an enum that either contains the oid or the name + type + format string.Ctl
inunix.rs
implementsoid()
to return a reference to the oid, in case the underlying Oid variant is used. This is a breaking change (requires a version bump to 0.5.0), asCtl
used to contain apub oid
that now no longer exists.Sysctl
trait is extended with anew_with_type()
function to construct aCtl
from a name, type and format string. On other platforms (i.e. not MacOS or iOS), this function will simply ignore the type and format string and instead fallback to the original oid implementation as that works fine.Ctl
variant, there are now functions that usesysctlbyname
+ the supplied type and format string instead ofsysctl
+oidfmt
internally.CtlIter
still uses oids, but that is fine. As on iOS this should just fail gracefully. That does mean that you cannot iterate over the available sysctls on a non-jailbroken iOS.