News for hackers. Stuff that matters.
Re:OpenBSD's Pledge and Unveil from Python by AndyMcConachie on Wednesday September 15, 2021 @04:24AM (#28536631)
I would check to make sure I was running on an OpenBSD system first before anything else.

You could use sys.platform()

https://docs.python.org/3/library/sys.html#sys.platform

Re:OpenBSD's Pledge and Unveil from Python by codetrotter on Wednesday September 15, 2021 @07:34AM (#28537777)
> I would check to make sure I was running on an OpenBSD system first before anything else.

But SerenityOS has pledge and unveil too.

https://awesomekling.github.io/pledge-and-unveil-in-Serenity...

Dunno if Python runs on SerenityOS or not yet tho

Re:OpenBSD's Pledge and Unveil from Python by jodrellblank on Wednesday September 15, 2021 @09:17AM (#28538692)
Not wanting to tie it to OpenBSD only was the reason he chose feature sniffing. From the article:

> "Systems other than OpenBSD may support these functions, now or in the future, and it would be nice to automatically make use of them when available. This means no checking for OpenBSD specifically but instead feature sniffing for their presence."

Re:OpenBSD's Pledge and Unveil from Python by AndyMcConachie on Wednesday September 15, 2021 @10:45AM (#28539765)
That's a good point. But I would still include a check for OS's that I know support it. This means it wouldn't work on OS's without first explicitly allowing it.

I view this as a feature and not a bug. There's a good chance there are other things to consider when a new OS adds pledge or unveil, and this gives the developer a chance to test support on the new OS before anyone uses it.

Basically, I disagree with the article that you want to implement this in Python in a completely OS agnostic manner.

Re:OpenBSD's Pledge and Unveil from Python by mleonhard on Wednesday September 15, 2021 @02:00PM (#28542285)
Make "failed to find `pledge` function' a hard error on OSes known to have it.