Skip to content

Commit

Permalink
Handle FreeBSD 13 changes in State::check() (#31)
Browse files Browse the repository at this point in the history
The racct_enable variable in the kernel changed from an int to a bool in
FreeBSD 13, this results in a different return type for us to handle.
  • Loading branch information
phyber committed Apr 15, 2021
1 parent 8738aab commit 2073c35
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1755,10 +1755,18 @@ impl State {
}

match enable_racct.unwrap().value() {
Ok(sysctl::CtlValue::Uint(v)) => match v {
1 => State::Enabled,
Ok(value) => match value {
// FreeBSD 13 returns a U8 as the kernel variable is a bool.
sysctl::CtlValue::U8(1) => State::Enabled,

// FreeBSD older than 13 returns a Uint as the kernel variable
// is an int.
sysctl::CtlValue::Uint(1) => State::Enabled,

// Other values we assume means RACCT is disabled.
_ => State::Disabled,
},

// If we could not get the sysctl value, assume it to be disabled.
_ => State::NotPresent,
}
Expand Down

0 comments on commit 2073c35

Please sign in to comment.