saghul / pycares

Python interface for c-ares
https://pypi.org/project/pycares/
MIT License
163 stars 74 forks source link

Is it possible to get rid of ffi.callback() use? #118

Closed Snawoot closed 4 years ago

Snawoot commented 4 years ago

Hello!

Approximately one year ago pycares switched from C backend to cffi backend. Current code utilizes ffi callbacks from native library. There is a problem with ffi.callback interface - it requires to allocate memory pages with W+X permissions: https://cffi.readthedocs.io/en/latest/using.html#callbacks-old-style

It causes issues on NetBSD and MacOS, but also I experienced same problem on Linux with daemon running as restricted systemd unit with MemoryDenyWriteExecute=yes configuration directive.

Is it possible to refactor pycares to use extern "Python" in order to get rid of legacy callbacks interface and W+X mempages usage?

saghul commented 4 years ago

Hi there! That sounds reasonable indeed. I don’t have much time to work on c-area these days, but I’ll keep it in mind for next time I make changes to it.

If you’d like to work on this yourself, you’re more than welcome to send PR and I’ll happily review it, we have pretty good CI integration now, so testing should be easy.