Skip to content

Commit

Permalink
[mod_authn_sasl] use HOSTNAME for fqdn on _WIN32
Browse files Browse the repository at this point in the history
use HOSTNAME for fqdn on _WIN32,
or require config specify "fqdn" in auth.backend.sasl.opts
  • Loading branch information
gstrauss committed Jan 17, 2024
1 parent ed06386 commit 22ba45f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mod_authn_sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* - database query is synchronous and blocks waiting for response
*/

#ifndef _WIN32
#include <sys/utsname.h>
#endif
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -118,6 +120,7 @@ static plugin_config * mod_authn_sasl_parse_opts(server *srv, const array * cons
array_get_element_klen(opts, CONST_STR_LEN("fqdn"));
if (NULL != ds) fqdn = ds->value.ptr;
if (NULL == fqdn) {
#ifndef _WIN32
static struct utsname uts;
if (uts.nodename[0] == '\0') {
if (0 != uname(&uts)) {
Expand All @@ -126,6 +129,14 @@ static plugin_config * mod_authn_sasl_parse_opts(server *srv, const array * cons
}
}
fqdn = uts.nodename;
#else
fqdn = getenv("HOSTNAME");
if (NULL == fdqn) {
log_error(srv->errh, __FILE__, __LINE__,
"auth.backend.sasl.opts missing fqdn");
return NULL;
}
#endif
}

ds = (const data_string *)
Expand Down

0 comments on commit 22ba45f

Please sign in to comment.