mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
nss-resolve: allow turning off validation via env var
This commit is contained in:
parent
acc8890a8a
commit
aee9d18c8d
@ -8,6 +8,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "env-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "in-addr-util.h"
|
#include "in-addr-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
@ -184,6 +185,21 @@ static const JsonDispatch address_parameters_dispatch_table[] = {
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint64_t query_flags(void) {
|
||||||
|
uint64_t f = 0;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
/* Allow callers to turn off validation, when we resolve via nss-resolve */
|
||||||
|
|
||||||
|
r = getenv_bool_secure("SYSTEMD_NSS_RESOLVE_VALIDATE");
|
||||||
|
if (r < 0 && r != -ENXIO)
|
||||||
|
log_debug_errno(r, "Failed to parse $SYSTEMD_NSS_RESOLVE_VALIDATE value, ignoring.");
|
||||||
|
else if (r == 0)
|
||||||
|
f |= SD_RESOLVED_NO_VALIDATE;
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
enum nss_status _nss_resolve_gethostbyname4_r(
|
enum nss_status _nss_resolve_gethostbyname4_r(
|
||||||
const char *name,
|
const char *name,
|
||||||
struct gaih_addrtuple **pat,
|
struct gaih_addrtuple **pat,
|
||||||
@ -215,7 +231,8 @@ enum nss_status _nss_resolve_gethostbyname4_r(
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = json_build(&cparams, JSON_BUILD_OBJECT(
|
r = json_build(&cparams, JSON_BUILD_OBJECT(
|
||||||
JSON_BUILD_PAIR("name", JSON_BUILD_STRING(name))));
|
JSON_BUILD_PAIR("name", JSON_BUILD_STRING(name)),
|
||||||
|
JSON_BUILD_PAIR("flags", JSON_BUILD_UNSIGNED(query_flags()))));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -367,7 +384,8 @@ enum nss_status _nss_resolve_gethostbyname3_r(
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = json_build(&cparams, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("name", JSON_BUILD_STRING(name)),
|
r = json_build(&cparams, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("name", JSON_BUILD_STRING(name)),
|
||||||
JSON_BUILD_PAIR("family", JSON_BUILD_INTEGER(af))));
|
JSON_BUILD_PAIR("family", JSON_BUILD_INTEGER(af)),
|
||||||
|
JSON_BUILD_PAIR("flags", JSON_BUILD_UNSIGNED(query_flags()))));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -571,7 +589,8 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = json_build(&cparams, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("address", JSON_BUILD_BYTE_ARRAY(addr, len)),
|
r = json_build(&cparams, JSON_BUILD_OBJECT(JSON_BUILD_PAIR("address", JSON_BUILD_BYTE_ARRAY(addr, len)),
|
||||||
JSON_BUILD_PAIR("family", JSON_BUILD_INTEGER(af))));
|
JSON_BUILD_PAIR("family", JSON_BUILD_INTEGER(af)),
|
||||||
|
JSON_BUILD_PAIR("flags", JSON_BUILD_UNSIGNED(query_flags()))));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user