Bug 268101

Summary: Inconsistent use of errno in cap_sysctl.h
Product: Base System Reporter: Alan Somers <asomers>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me CC: emaste, oshogbo
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Alan Somers freebsd_committer freebsd_triage 2022-12-01 16:59:07 UTC
If WITH_CASPER is defined, then all of the functions in cap_sysctl.h will set errno on failure.  However, if it is not defined, then all of those functions' stubs will fail yet not set errno.  errno will be populated with some stale value.

Instead, the stubs should set errno.  Perhaps EOPNOTSUPP?  Or even EDOOFUS because the caller shouldn't be using those functions without defining WITH_CASPER?

In fact, I think it would've been a better design decision if those functions would succeed whenever capability mode is disabled, much like caph_enter.  But that horse has left the barn.