#include <nss.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
#include "sd-bus.h"
#include "bus-common-errors.h"
+#include "errno-util.h"
#include "in-addr-util.h"
#include "macro.h"
#include "nss-util.h"
#include "resolved-def.h"
-#include "string-util.h"
-#include "util.h"
#include "signal-util.h"
+#include "string-util.h"
NSS_GETHOSTBYNAME_PROTOTYPES(resolve);
NSS_GETHOSTBYADDR_PROTOTYPES(resolve);
return sd_bus_error_has_name(e, SD_BUS_ERROR_SERVICE_UNKNOWN) ||
sd_bus_error_has_name(e, SD_BUS_ERROR_NAME_HAS_NO_OWNER) ||
sd_bus_error_has_name(e, SD_BUS_ERROR_NO_REPLY) ||
- sd_bus_error_has_name(e, SD_BUS_ERROR_ACCESS_DENIED);
+ sd_bus_error_has_name(e, SD_BUS_ERROR_ACCESS_DENIED) ||
+ sd_bus_error_has_name(e, SD_BUS_ERROR_DISCONNECTED) ||
+ sd_bus_error_has_name(e, SD_BUS_ERROR_TIMEOUT);
}
static int count_addresses(sd_bus_message *m, int af, const char **canonical) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
struct gaih_addrtuple *r_tuple, *r_tuple_first = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
- enum nss_status ret = NSS_STATUS_UNAVAIL;
const char *canonical = NULL;
size_t l, ms, idx;
char *r_name;
r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);
if (r < 0) {
- if (sd_bus_error_has_name(&error, _BUS_ERROR_DNS "NXDOMAIN") ||
- !bus_error_shall_fallback(&error))
+ if (!bus_error_shall_fallback(&error))
goto not_found;
/* Return NSS_STATUS_UNAVAIL when communication with systemd-resolved fails,
UNPROTECT_ERRNO;
*errnop = -r;
*h_errnop = NO_RECOVERY;
- return ret;
+ return NSS_STATUS_UNAVAIL;
not_found:
*h_errnop = HOST_NOT_FOUND;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
char *r_name, *r_aliases, *r_addr, *r_addr_list;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
- enum nss_status ret = NSS_STATUS_UNAVAIL;
size_t l, idx, ms, alen;
const char *canonical;
int c, r, i = 0;
r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);
if (r < 0) {
- if (sd_bus_error_has_name(&error, _BUS_ERROR_DNS "NXDOMAIN") ||
- !bus_error_shall_fallback(&error))
+ if (!bus_error_shall_fallback(&error))
goto not_found;
goto fail;
UNPROTECT_ERRNO;
*errnop = -r;
*h_errnop = NO_RECOVERY;
- return ret;
+ return NSS_STATUS_UNAVAIL;
not_found:
*h_errnop = HOST_NOT_FOUND;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
char *r_name, *r_aliases, *r_addr, *r_addr_list;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
- enum nss_status ret = NSS_STATUS_UNAVAIL;
unsigned c = 0, i = 0;
size_t ms = 0, idx;
const char *n;
}
if (len != FAMILY_ADDRESS_SIZE(af)) {
- UNPROTECT_ERRNO;
- *errnop = EINVAL;
- *h_errnop = NO_RECOVERY;
- return NSS_STATUS_UNAVAIL;
+ r = -EINVAL;
+ goto fail;
}
if (avoid_deadlock()) {
r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);
if (r < 0) {
- if (sd_bus_error_has_name(&error, _BUS_ERROR_DNS "NXDOMAIN") ||
- !bus_error_shall_fallback(&error))
+ if (!bus_error_shall_fallback(&error))
goto not_found;
goto fail;
r = sd_bus_message_rewind(reply, false);
if (r < 0)
- return r;
+ goto fail;
if (c <= 0)
goto not_found;
UNPROTECT_ERRNO;
*errnop = -r;
*h_errnop = NO_RECOVERY;
- return ret;
+ return NSS_STATUS_UNAVAIL;
not_found:
*h_errnop = HOST_NOT_FOUND;