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

dnssd.c: Enable service registration on loopback #345

Open
wants to merge 1 commit into
base: v1.4.x
Choose a base branch
from

Conversation

zdohnal
Copy link
Contributor

@zdohnal zdohnal commented Feb 28, 2024

In case users would like to prevent sharing services from printer applications to local network, restrict it to localhost and let CUPS do the sharing.

This can be done by setting listen-hostname in PAPPL API - this prevents accessing the public addresses, but the service is still published on those public addresses. This can be prevented if the machine hostname is changed to localhost, but that's not desired on machines IIUC.

The PR does the following:

  • introduced new pappl system member reghost, which is used for saving listen-hostname,
  • new public accessors for that member, papplSystemSetRegHostName() and papplSystemGetRegHostName() - user can set the member to localhost or to the current hostname
  • dnssd functions will check this member, and if it is localhost, it will use loopback index
  • in case of Avahi it passes NULL as hostname to let Avahi decide what hostname to use (in case of hostname conflicts - and Avahi forbids using localhost if it is not FQDN)

The result is that if reghost is set to localhost, the service is published on .local address, but resolved to loopback because CUPS uses DNS-SD names in URIs.

Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

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

See my other comments. No to "reghost". Yes to fixing localhost/loopback advertising.

@michaelrsweet michaelrsweet self-assigned this Mar 1, 2024
@michaelrsweet michaelrsweet added bug Something isn't working priority-medium platform issue Issue is specific to an OS or desktop labels Mar 1, 2024
@michaelrsweet michaelrsweet added this to the Stable milestone Mar 1, 2024
@zdohnal zdohnal force-pushed the mdns-registration-avahi branch 4 times, most recently from a666fe9 to 0ac1c0d Compare March 14, 2024 08:14
In case users would like to prevent sharing services from printer
applications to local network, restrict it to localhost and let CUPS do
the sharing.

This can be done by setting `listen-hostname` in PAPPL API - this
prevents accessing the public addresses, but the service is still
published on those public addresses.

The PR does the following:

- update system hostname internally in `papplAddListeners()`
- dnssd functions will check system hostname and if it is localhost, it
  will use loopback index
- in case of Avahi it passes NULL as hostname to let Avahi decide what
  hostname to use (in case of hostname conflicts)

The result is that if system hostname is set to localhost internally, the service is
published on `.local` address, but resolved to loopback because CUPS
uses DNS-SD names in URIs.
Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

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

See my comments on the other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform issue Issue is specific to an OS or desktop priority-medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants