Implementing C API in Rust

Hi,

I want to implement a sudo plugin in Rust. The plugin should implement a C API that specified in man 5 sudo_plugin. It defines some data structures and function signiature.
Is it possible to implement a shared library in Rust that compatible with C API that defined in given header files of sudo plugin?

Regards,

1 Like

Yes! I haven't done so myself, so others would be better able to answer specific questions. But the Rustonomicon entry on FFI will probably have a lot of useful info for you.

3 Likes

Also, you may want to look at bindgen to automatically convert the C headers to Rust type definitions.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.