A wrapper for the pledge(2) systemcall, used to restrict system operations.
+On systems other than OpenBSD where pledge is not yet implemented, the wrapper has no effect.
+ +Example of making a single promise
In order to pledge to only use the stdio promise as described in the pledge(2) man page, you simply pass the Promise.Stdio to pledge():
+import pledge + +pledge(Promise.Stdio)+
Example of making several promises
In order to pledge to use the stdio and rpath promises as described in the pledge(2) man page, you simply pass the required promises to pledge():
+import pledge + +pledge(Promise.Stdio, Promise.Rpath)+ +
Types
+-
+
Promise* {.
pure.} = enum + Stdio = "stdio", Rpath = "rpath", Wpath = "wpath", Cpath = "cpath", Dpath = "dpath", + Tmppath = "tmppath", Inet = "inet", Mcast = "mcast", Fattr = "fattr", Chown = "chown", + Flock = "flock", Unix = "unix", Dns = "dns", Getpw = "getpw", Sendfd = "sendfd", + Recvfd = "recvfd", Tape = "tape", Tty = "tty", Proc = "proc", Exec = "exec", + ProtExec = "prot_exec", Settime = "settime", Ps = "ps", Vminfo = "vminfo", Id = "id", + Pf = "pf", Audio = "audio", Bpf = "bpf"
+- +The possible operation sets that a program can pledge to be limited to. + Source +Edit + + + +
Procs
+-
+
proc pledge*(promises: varargs[Promise]) {.
raises: [OSError].}
+-
+
Pledge to use only the defined functions. Always returns true on non-OpenBSD systems.
+If no promises are provided, the process will be restricted to the _exit(2) system call.
+If the pledge call is not successful, an OSError will be thrown.
+ + Source +Edit + +
+
+