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

ospect::os::fqdn does not work on macOS #58

Open
panhania opened this issue Oct 24, 2023 · 0 comments
Open

ospect::os::fqdn does not work on macOS #58

panhania opened this issue Oct 24, 2023 · 0 comments

Comments

@panhania
Copy link
Member

panhania commented Oct 24, 2023

Some change recently caused the tests for ospect::os::fqdn to fail. GitHub Actions run for 34441db (run) succeeded but the following 1a39af0 (run) failed. The commit does not touch this function at all.

When testing locally the low-level function used to implement this (getaddrinfo), the same error happens:

#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <netdb.h>

int main(void)
{
    int err;

    long host_name_max = sysconf(_SC_HOST_NAME_MAX);
    char hostname[host_name_max + 1];
    
    err = gethostname(hostname, sizeof(hostname));
    if (err != 0) {
        fprintf(stderr, "failed to get hostname: %d", err);
        return 1;
    }

    printf("hostname: %s\n", hostname);

    struct addrinfo hints = {0};
    hints.ai_family = PF_UNSPEC;
    hints.ai_socktype = 0;
    hints.ai_protocol = 0;
    hints.ai_flags = AI_CANONNAME;

    struct addrinfo *info;

    err = getaddrinfo(hostname, NULL, &hints, &info);
    if (err != 0) {
        fprintf(stderr, "failed to get hostname information: %s\n", gai_strerror(err));
        return 1;
    }

    printf("fqdn: %s\n", info->ai_canonname);

    freeaddrinfo(info);

    return 0;
}

When running this code, the call to getaddrinfo fails with EAI_NONAME ("nodename nor servname provided, or not known"). This indicates that we call this function incorrectly (either nodename or servname must be provided but we are clearly doing so).

The run for commit 34441db was on macOS 12.6.9 whereas the run for commit 1a39af0 was on macOS 12.7. There is a chance that some system-level change was introduced that broke us.

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

1 participant