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

Various portability fixes #7861

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/providers/fail_over.c
Original file line number Diff line number Diff line change
Expand Up @@ -1333,13 +1333,10 @@ fo_resolve_service_done(struct tevent_req *subreq)
talloc_zfree(subreq);
if (ret != EOK) {
if (resolv_status == ARES_EFILE) {
/* resolv_strerror(resolv_status) provided msg from c-ares lib.
* c-ares lib in most distros will default to /etc/hosts for
* file based host resolving */
DEBUG(SSSDBG_CRIT_FAILURE, "Failed to resolve server '%s': %s [%s]\n",
/* resolv_strerror(resolv_status) provided msg from c-ares lib. */
DEBUG(SSSDBG_CRIT_FAILURE, "Failed to resolve server '%s': %s [local hosts file]\n",
common->name,
resolv_strerror(resolv_status),
_PATH_HOSTS);
resolv_strerror(resolv_status));
} else {
DEBUG(SSSDBG_CRIT_FAILURE, "Failed to resolve server '%s': %s\n",
common->name,
Expand Down
4 changes: 4 additions & 0 deletions src/sss_client/sss_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ typedef int errno_t;
#define EOK 0
#endif

#ifndef NETDB_INTERNAL
#define NETDB_INTERNAL (-1)
Copy link
Member

Choose a reason for hiding this comment

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

What does musl use instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

But how will musl work with 'libnss_sss' if it doesn't expect -1 to be returned?

Copy link
Contributor Author

@fossdd fossdd Mar 6, 2025

Choose a reason for hiding this comment

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

Hmm, do you know where libnss_sss returns NETDB_INTERNAL to musl?

Copy link
Member

Choose a reason for hiding this comment

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

$ grep -rn NETDB_INTERNAL *
nss_hosts.c:233:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:240:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:247:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:282:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:294:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:353:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:360:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:367:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:412:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:424:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:461:        *h_errnop = NETDB_INTERNAL;
nss_hosts.c:479:            *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:204:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:211:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:223:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:246:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:266:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:311:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:318:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:327:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:349:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:372:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:392:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:421:        *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:444:            *h_errnop = NETDB_INTERNAL;
nss_ipnetworks.c:467:        *h_errnop = NETDB_INTERNAL;

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why above patch was so contained.

Copy link
Member

Choose a reason for hiding this comment

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

@fossdd, what is your stance on this?
Do you want to dig deeper or are you fine to merely get code to the state "it compiled with musl"?

@sumit-bose, do you think we could extend 1a1e914 to replace all uses of NETDB_INTERNAL with NO_RECOVERY / HOST_NOT_FOUND (portable)?

@scabrero, do you remember if there was a reason to use NETDB_INTERNAL specifically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me, it's fine. we already ship this code downstream, and afaik this snippet worked fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

@scabrero, do you remember if there was a reason to use NETDB_INTERNAL specifically?

I don't remember if there was a specific reason by that time, but having a look it is probably because it is the way to say "check errno":
# define NETDB_INTERNAL -1 /* See errno. */

Copy link
Member

Choose a reason for hiding this comment

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

For me, it's fine. we already ship this code downstream, and afaik this snippet worked fine.

Ok, if nobody else chimes in in a next day or two, this will be merged "as is".

#endif

#define SSS_NSS_PROTOCOL_VERSION 1
#define SSS_PAM_PROTOCOL_VERSION 3
#define SSS_SUDO_PROTOCOL_VERSION 1
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tools_mc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static errno_t wait_till_nss_responder_invalidate_cache(void)
{
struct stat stat_buf = { 0 };
const time_t max_wait = 1000000; /* 1 second */
const __useconds_t step_time = 5000; /* 5 milliseconds */
const useconds_t step_time = 5000; /* 5 milliseconds */
const size_t steps_count = max_wait / step_time;
int ret;

Expand Down