Skip to content

cmdeploy: error out if port 53 is taken#537

Merged
missytake merged 3 commits intomainfrom
stop-nsd
Apr 10, 2025
Merged

cmdeploy: error out if port 53 is taken#537
missytake merged 3 commits intomainfrom
stop-nsd

Conversation

@missytake
Copy link
Copy Markdown
Contributor

oops, we never created an issue for this. But in some cases cmdeploy fails to install unbound because nsd is already running on port 53. I made sure that this PR also works if nsd isn't installed and the nsd service doesn't exist.

Copy link
Copy Markdown
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

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

i don't quite understand why NSD can be running. That's not the case in a standard debian 12 install, is it? If someone runs additional services, does it make sense to disable them "just in case"?

@feld
Copy link
Copy Markdown
Collaborator

feld commented Apr 2, 2025

I think it would be better to detect if some process other than unbound is binding to port 53 and throw an error message. People should not be running other software on their Chatmail servers unless they really know what they're doing, and if we take this step we probably also need to detect: powerdns, bind, maradns, dnsmaq, tinydns/djbdns, etc.

You can detect the process name bound to port 127.0.0.1:53 with this one-liner:

> sudo ss -lptn 'src 127.0.0.1:53' | awk 'NR>1 {print $6,$7}' | sed 's/users:(("//;s/".*//'
unbound

@missytake
Copy link
Copy Markdown
Contributor Author

You can detect the process name bound to port 127.0.0.1:53 with this one-liner:

> sudo ss -lptn 'src 127.0.0.1:53' | awk 'NR>1 {print $6,$7}' | sed 's/users:(("//;s/".*//'
unbound

Thanks! Now I learned how to write pyinfra facts :) we can now check which service is running on a port, and use this to make sure other ports aren't occupied either. But that's for a future PR.

@missytake missytake requested a review from hpk42 April 10, 2025 09:46
@missytake missytake changed the title cmdeploy: disable nsd so it doesn't block port 53 cmdeploy: error out if port 53 is taken Apr 10, 2025
Copy link
Copy Markdown
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

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

looks good, nice "fact" hack :)

@missytake
Copy link
Copy Markdown
Contributor Author

looks good, nice "fact" hack :)

tbh it's not really a hack, but how you're supposed to use pyinfra :D I'm thinking about upstreaming it to pyinfra.facts.server, it's quite useful I think

@missytake missytake merged commit 21f9885 into main Apr 10, 2025
6 checks passed
@missytake missytake deleted the stop-nsd branch April 10, 2025 13:12
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