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

feat: Add socket-activated systemd service for discovery #218

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

aleasto
Copy link
Contributor

@aleasto aleasto commented Oct 9, 2024

Introduce a system-wide daemon listening on /run/wsdd.socket, which is managed by systemd.
When a client first connects to the socket the daemon is started. Multiple clients can connect and safely use the API simultaneously.

The service runs in discovery-only mode.

Uses multicast source-port 37020.

@aleasto
Copy link
Contributor Author

aleasto commented Oct 9, 2024

  • Increases the security of services like gvfs which rely discovery mode by integrating with all the security confinement features
  • Allows us to standardize one --source-port
  • Only one daemon per system
  • systemd-specific but non-intrusive

Comment on lines 7 to 11
[Service]
Type=simple
; The service is put into an empty runtime directory chroot,
; i.e. the runtime directory which usually resides under /run
ExecStart=/usr/bin/wsdd --shortlog --chroot=/run/wsdd --source-port=37020 --no-host --discovery
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use the same flags from /etc/default/wsdd here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might help in some minor use-cases, I think (including verbosity for debugging, e.g.), so why not. But I propose to use a different environment file.

I also propose to use a different run/chroot directory for the wsdd-discovery service in order to separate it from a regular host instance. Maybe even a different (dynamic) username might be good, although I'm not sure if dynamic users are inherently distinct (due to different namespace) even when sharing the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although I'm not sure if dynamic users are inherently distinct (due to different namespace) even when sharing the same name.

They're using the same UID/GID here, so no

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's this?
I've used the same env file but a different variable name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--source-port 37020 could also be set in the environment file instead of hard-coded inthe systemd unit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to make that configurable from the environmental file, but it is hardcoded in the firewall configuration anyway...

@aleasto
Copy link
Contributor Author

aleasto commented Oct 11, 2024

TODO: systemctl stop wsdd-discovery hangs if there are processes (gvfsd) listening on /run/wsdd.socket. We should probably close the connection.

@aleasto
Copy link
Contributor Author

aleasto commented Oct 11, 2024

TODO: systemctl stop wsdd-discovery hangs if there are processes (gvfsd) listening on /run/wsdd.socket. We should probably close the connection.

That's #219

@christgau
Copy link
Owner

@aleasto I split the UFW rules because I think enabling discovering other devices on the network should not open ports for the host itself to be discoverable. AFAIK, Windows actually has two services as well (fdPHost and FDResPub on Win11).

WDYT?

@aleasto
Copy link
Contributor Author

aleasto commented Dec 28, 2024

Yeah I think I agree.

Shouldn't you do the same for firewalld?

@christgau
Copy link
Owner

Shouldn't you do the same for firewalld?

Good point. Done

Introduce a system-wide daemon listening on /run/wsdd.socket,
which is managed by systemd.
When a client first connects to the socket the daemon is started.
Multiple clients can connect and safely use the API simultaneously.

The service runs in discovery-only mode.

Uses a fixed multicast source-port 37020, which is used by the
socket-activated discovery daemon.

Allow port 37020 in firewall profiles and split configurations for
discovery (client) and host roles.

Co-Authored-by: Steffen Christgau <[email protected]>
@christgau christgau merged commit 13d2b0f into christgau:master Jan 5, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants