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

Host names truncated to 64 chars #1252

Open
morille opened this issue Jun 7, 2024 · 3 comments
Open

Host names truncated to 64 chars #1252

morille opened this issue Jun 7, 2024 · 3 comments

Comments

@morille
Copy link

morille commented Jun 7, 2024

I have an OpenSMTPD 6.6.4p1 instance running on an Ubuntu 20.04.6 LTS machine, installed using package manager.
When receiving emails from hosts with a name longer than 64 characters, the name used for the fc-rDNS check is truncated to 64 chars, and the connection is discarded.
It seems that is because HOST_NAME_MAX defaults to 64 on most linux distros.

getconf HOST_NAME_MAX
64

Is there an "easy" way to change this ?

@omar-polo
Copy link
Contributor

omar-polo commented Jun 9, 2024

Hello, thanks for the report.

Is this a glibc-thing? on alpine limits.h defines HOST_NAME_MAX to 255, but I can see that on debian is 64. (the VERSION section of gethostname(2) on linux seem have some commentary.)

I guess we'll have to use _POSIX_HOST_NAME_MAX which is 255 on all the systems I managed to get my hands on (OpenBSD, FreeBSD, alpine and debian)

@morille
Copy link
Author

morille commented Jun 11, 2024

In limits.h there is an interesting note saying that the minimum acceptable value for HOST_NAME_MAX is _POSIX_HOST_NAME_MAX.
So when both are defined, smtpd should use the bigger one.
Is this something you could do ? (I did not put my hands on C for almost 20 years...)

morille pushed a commit to morille/OpenSMTPD that referenced this issue Jun 24, 2024
Debian based systems have an HOST_NAME_MAX lower than _POSIX_HOST_NAME_MAX and it causes the issue OpenSMTPD#1252
Clamp HOST_NAME_MAX in the sysconf way: https://manpages.ubuntu.com/manpages/trusty/fr/man3/sysconf.3.html
@s4uliu5
Copy link

s4uliu5 commented Jul 2, 2024

I'm using OpenSMTPD 7.5.0p0, on Funtoo Linux with glibc-2.33, with rdns and fcrdns filters enabled.

And my system is affected by this issue.

Before applying morille@b9a09d6, I had a lot of fcrdns errors similar to this

Jul  1 08:56:15 smtp01 smtpd[7838]: 33c297056fc0b7f5 smtp connected address=40.107.149.96 host=mail-germanywestcentralazon11022096.outbound.protection.outlook.
Jul  1 08:56:15 smtp01 smtpd[7838]: 33c297056fc0b7f5 smtp failed-command command="" result="550 fcrDNS error"

as host names longer than 64 chars were truncated that caused fcrdns filter to fail, e.g. from mail-germanywestcentralazon11022096.outbound.protection.outlook.com to mail-germanywestcentralazon11022096.outbound.protection.outlook.

morille pushed a commit to morille/OpenSMTPD that referenced this issue Aug 20, 2024
Debian based systems have an HOST_NAME_MAX lower than _POSIX_HOST_NAME_MAX and it causes the issue OpenSMTPD#1252
It is usually clamped by sysconf: https://manpages.ubuntu.com/manpages/trusty/fr/man3/sysconf.3.html
Using a new SMTPD_HOST_NAME_MAX define to hold the correct value without redefining HOST_NAME_MAX
morille pushed a commit to morille/OpenSMTPD that referenced this issue Aug 20, 2024
Debian based systems have an HOST_NAME_MAX lower than _POSIX_HOST_NAME_MAX and it causes the issue OpenSMTPD#1252
It is usually clamped by sysconf: https://manpages.ubuntu.com/manpages/trusty/fr/man3/sysconf.3.html
Using a new SMTPD_HOST_NAME_MAX define to hold the correct value without redefining HOST_NAME_MAX
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