pledge and unveil on OpenBSD#2366
Conversation
|
Upon further testing I believe this still has some issues. In my first commit, I was lacking some additional paths that may have conditionally needed to be unveiled based on given arguments. Yet even still there are some strange issues that I believe are a result of some arguments not being initialized to their default fallback options until after we've finished unveiling. For example, I created this error while testing: I believe at the time I unveil the |
|
daemon/Daemon.cpp:317:76: error: function definition is not allowed here Please refrain from using nested functions. |
|
suppose it'd be best to go the "official" way:
|
daviduhden
left a comment
There was a problem hiding this comment.
Thanks for working on OpenBSD hardening. I agree with the issue reported by orignal, and here is the precise correction.
C++ does not allow defining a named function inside another function. In this patch, static void UnveilConfigOption(...) is defined inside Daemon::init, which causes the compile error: function definition is not allowed here.
Please move that helper out of Daemon::init, for example to anonymous namespace file scope, or replace it with a local lambda and keep the rest of the logic unchanged.
Also please fix the PR text typo: privledge -> privilege.
This patch implements native OpenBSD hardening for the i2pd daemon with
unveil(2)andpledge(2)by placing a privledge restriction block at the end ofDaemon::init. We get paths fortunconf,tunnelsdir,datadir, andcertsdirfrom the config map.Paths for name resolution (
/etc/resolv.confand/etc/hosts) are automatically unveiled by thednspromise.