Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firewall rules #9

Closed
sp1ritCS opened this issue May 18, 2021 · 8 comments
Closed

Firewall rules #9

sp1ritCS opened this issue May 18, 2021 · 8 comments

Comments

@sp1ritCS
Copy link

sp1ritCS commented May 18, 2021

Is it possible for dragit to automatically punch holes into firewalld, if it has to listen to a specific port?

I know that gnome-network-displays are doing something like this, might be a good idea to look at them and how they do it.

@sireliah
Copy link
Owner

It's great idea, I'll research that!

@sireliah
Copy link
Owner

@sp1ritCS
Copy link
Author

But they are changing to that new zone at runtime if it isn't enabled.
https://gitlab.gnome.org/GNOME/gnome-network-displays/-/commit/fed0e1311e89f229cc683abb5c3f9a996fbeb0a3

@sireliah
Copy link
Owner

sireliah commented May 23, 2021

Yeah, I see what they are doing there. They indeed expect the zone to be there and in case it is not, they create it. It seems that they operate on fixed port.

The interface they use to communicate with the firewalld is D-Bus. We could do the same, since there are pretty good D-Bus bindings for Rust, however there are is a gotcha here:

  • Talking to firewalld requires elevated privileges from the user. That is, user will be prompted for a password in case there is a zone config that doesn't allow Dragit to work (I think this is implied by G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION flag. We should be smart here and prompt user only if this is absolutely necessary, so when there are rules that would block libp2p or mdns traffic.
  • We should clearly explain why Dragit demands those privileges and what it will do to the user's computer.
  • Dragit uses random ports for p2p communication. It might be better to use fixed ones to make firewalld integration easier.
  • In context of Flatpak application - maybe it's not an issue, but using D-Bus to change settings of the host system is yet another hole in the sandbox. Docs don't say it's bad, but you know.

Having said that, I'll run some tests with my local firewalld and see if there are any potential problems.

@sp1ritCS
Copy link
Author

there are pretty good D-Bus bindings for Rust

if you're talking about zbus, absolutely. dbus-rs not so much :D

We should clearly explain why Dragit demands those privileges and what it will do to the user's computer.

well, if I remember correctly, gnome-network-displays shows a similar polkit authentication dialog as firewall-config itself:
image
I think it should be fairly obvious with that message that dragit needs to modify the firewall zone.

In context of Flatpak application - maybe it's not an issue, but using D-Bus to change settings of the host system is yet another hole in the sandbox. Docs don't say it's bad, but you know

well, I guess it's better than not working at all
¯\_(ツ)_/¯

@sireliah
Copy link
Owner

@sp1ritCS I'm not quite done with the code yet, but it would be great if you could take a look at this PR and particularly firewall module. I implemented adding mdns service and fixed Dragit port in case it's not available in runtime config.

@sireliah
Copy link
Owner

Closing the issue. The next release (including Flatpak) will contain the change!

@nekohayo
Copy link

Potential follow-up idea in issue #32, in case @sp1ritCS is interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants