This library was written to help my easing into Ada programming, as I struggle with this language so different from all others I've known. This is a package I can be proud of, however. This defines a simple package for OpenBSD's extra facilities, namely pledge and unveil. There is an enumeration type common to both, two more enumeration types, two array types thereof, two exceptions, and then two procedures Pledge and Unveil. This is a simple and high-level interface to OpenBSD's pledge and unveil facilities that came to mind in my errant thought. The procedures are expected and designed to be used exclusively with array aggregates and not with the type names. Here is the example that inspired the library:
with OpenBSD; use OpenBSD; ... Unveil("/tmp/", (Read | Write => Allowed, others => Disallowed)); ... Pledge((Stdio | Fattr => Allowed, others => Disallowed)); ...
These procedures work by fixing Ada's enumeration types over the strings OpenBSD uses to approximate such a language facility. The pledge accepts a simple string of designated keywords separated by spaces and terminated according to the usual C convention. The unveil accepts a filename and string of designated characters terminated according to the usual C convention, as well. Failure cases are invalid pointers, malformed strings, invalid requests, attempts to increase permissions, and so on. Several of these failure cases simply won't occur in Ada; the permission errors are those that are particularly relevant and correspond to the exceptions, with unveil conflating some of the failure cases for simplicity, and this is a reasonable decision given that the precise error can be learned.
I'm, of course, still rather green to Ada and so it can be expected the body of this package will be improved over time. I likely won't change any of the names used in the specification, but this is a reason you should only use array aggregates with it. This library is not currently robust to change as I believe it should be, but I intend to correct this. It has been a valuable learning experience and I expect to update this library as OpenBSD changes the semantics of pledge and unveil or adds new facilities that would be worthwhile to expose to Ada.
Here is the package specification, the package body, and the documentation.