1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
*** nss.c.orig 2021-05-11 02:25:39.000000000 +0100
--- nss.c 2022-08-02 08:35:23.090458158 +0100
***************
*** 81,86 ****
--- 81,104 ----
}
}
+ static enum nss_status _convert_avahi_result(avahi_resolve_result_t r, int* errnop, int* h_errnop) {
+ switch (r) {
+ case AVAHI_RESOLVE_RESULT_SUCCESS:
+ return NSS_STATUS_SUCCESS;
+
+ case AVAHI_RESOLVE_RESULT_HOST_NOT_FOUND:
+ *errnop = ETIMEDOUT;
+ *h_errnop = HOST_NOT_FOUND;
+ return NSS_STATUS_NOTFOUND;
+
+ case AVAHI_RESOLVE_RESULT_UNAVAIL:
+ default:
+ *errnop = ETIMEDOUT;
+ *h_errnop = NO_RECOVERY;
+ return NSS_STATUS_UNAVAIL;
+ }
+ }
+
enum nss_status _nss_mdns_gethostbyname_impl(const char* name, int af,
userdata_t* u, int* errnop,
int* h_errnop) {
***************
*** 123,150 ****
if (mdns_allow_file)
fclose(mdns_allow_file);
#endif
-
if (!name_allowed) {
*errnop = EINVAL;
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
}
! switch (do_avahi_resolve_name(af, name, u)) {
! case AVAHI_RESOLVE_RESULT_SUCCESS:
! return NSS_STATUS_SUCCESS;
!
! case AVAHI_RESOLVE_RESULT_HOST_NOT_FOUND:
! *errnop = ETIMEDOUT;
! *h_errnop = HOST_NOT_FOUND;
! return NSS_STATUS_NOTFOUND;
!
! case AVAHI_RESOLVE_RESULT_UNAVAIL:
! default:
! *errnop = ETIMEDOUT;
! *h_errnop = NO_RECOVERY;
! return NSS_STATUS_UNAVAIL;
! }
}
#ifndef __FreeBSD__
--- 141,166 ----
if (mdns_allow_file)
fclose(mdns_allow_file);
#endif
if (!name_allowed) {
+ if (!strstr(name, ".")) {
+ const char *p="local";
+ int fullnamesize;
+ char *fullname;
+ fullnamesize = strlen(name) + strlen(p) + 2;
+ if ((fullname = malloc(fullnamesize))){
+ avahi_resolve_result_t r;
+ snprintf(fullname, fullnamesize, "%s.%s", name, p);
+ r = do_avahi_resolve_name(af, fullname, u);
+ free(fullname);
+ return _convert_avahi_result(r, errnop, h_errnop);
+ }
+ }
*errnop = EINVAL;
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
}
! return _convert_avahi_result(do_avahi_resolve_name(af, name, u), errnop, h_errnop);
}
#ifndef __FreeBSD__
|