I'm working on a project, implementing everything in C language. As a part of the project, we need to be able to control and configure firewalld
, firewall of the current system.
firewalld
is implemented in Python and an interface is available. However, we don't want to make Python calls from C or vice versa.- There are command line tools to configure
firewalld
(e.g.firewall-cmd
) but we don't want to make such calls from C either.
I recently started working on firewalld
, I don't know much about its internals. I've read that it uses D-Bus, I also don't know much about D-Bus.
- There is a C library developed by Thomas Woerner:
libfirewall
. However, it's been more than a year and a half since the last commit so it's not maintained. Other thanlibfirewall
, I don't know any firewalld interface in C.- I gave
libfirewall
a shot. It got me some problems when both compiling and running the examples and I still have problems to resolve. Is it worth to continue withlibfirewall
? Should I use it? - Is there any other interface that I'm not aware of?
- I gave
- Possibly naive question due to lack of understanding of D-Bus: I thought, maybe, with a D-Bus interface, I can issue commands to firewalld. Can it be done? (i.e. Does D-Bus work like that?) Can we write a program that mimics, say
firewall-cmd
, and interacts with D-Bus in the same way and at the end allows us to control firewalld?- If this is possible, how to do it and what to use?
libdbus
andGDBus
have relatively good documentation althoughlibdbus
requires good deal of effort. They even said "If you use this low-level API directly, you're signing up for some pain." in the documentation. In any case I'll be in need of examples or any kind of text demonstrating their usage.
- If this is possible, how to do it and what to use?
How should I approach this problem?