diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-09-05 15:02:06 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-09-05 15:02:06 +0200 |
commit | 727f0d8a8735dd638ff2f714f19c8c23852b99ba (patch) | |
tree | fd43a2d31c0cbebd121c9326c59570b8c2bcf6c9 /src/gns/nss/nss_gns_query.c | |
parent | e111bca33366139f76d6757f55faeb09406febe8 (diff) | |
download | gnunet-727f0d8a8735dd638ff2f714f19c8c23852b99ba.tar.gz gnunet-727f0d8a8735dd638ff2f714f19c8c23852b99ba.zip |
fix gns plugin action on NOTFOUND
Diffstat (limited to 'src/gns/nss/nss_gns_query.c')
-rw-r--r-- | src/gns/nss/nss_gns_query.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c index 867ead624..032b2c93b 100644 --- a/src/gns/nss/nss_gns_query.c +++ b/src/gns/nss/nss_gns_query.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <sys/types.h> | 23 | #include <sys/types.h> |
24 | #include <sys/socket.h> | 24 | #include <sys/socket.h> |
25 | #include <netinet/in.h> | 25 | #include <netinet/in.h> |
26 | #include <errno.h> | ||
26 | 27 | ||
27 | 28 | ||
28 | /** | 29 | /** |
@@ -32,7 +33,10 @@ | |||
32 | * @param af address family | 33 | * @param af address family |
33 | * @param name the name to resolve | 34 | * @param name the name to resolve |
34 | * @param u the userdata (result struct) | 35 | * @param u the userdata (result struct) |
35 | * @return -1 on error else 0 | 36 | * @return -1 on internal error, |
37 | * -2 if request is not for GNS, | ||
38 | * -3 on timeout, | ||
39 | * else 0 | ||
36 | */ | 40 | */ |
37 | int | 41 | int |
38 | gns_resolve_name (int af, | 42 | gns_resolve_name (int af, |
@@ -43,6 +47,7 @@ gns_resolve_name (int af, | |||
43 | char *cmd; | 47 | char *cmd; |
44 | char line[128]; | 48 | char line[128]; |
45 | int ret; | 49 | int ret; |
50 | int es; | ||
46 | 51 | ||
47 | if (AF_INET6 == af) | 52 | if (AF_INET6 == af) |
48 | { | 53 | { |
@@ -62,7 +67,9 @@ gns_resolve_name (int af, | |||
62 | } | 67 | } |
63 | if (NULL == (p = popen (cmd, "r"))) | 68 | if (NULL == (p = popen (cmd, "r"))) |
64 | { | 69 | { |
70 | es = errno; | ||
65 | free (cmd); | 71 | free (cmd); |
72 | errno = es; | ||
66 | return -1; | 73 | return -1; |
67 | } | 74 | } |
68 | while (NULL != fgets (line, | 75 | while (NULL != fgets (line, |
@@ -85,8 +92,9 @@ gns_resolve_name (int af, | |||
85 | } | 92 | } |
86 | else | 93 | else |
87 | { | 94 | { |
88 | pclose (p); | 95 | (void) pclose (p); |
89 | free (cmd); | 96 | free (cmd); |
97 | errno = EINVAL; | ||
90 | return -1; | 98 | return -1; |
91 | } | 99 | } |
92 | } | 100 | } |
@@ -101,8 +109,9 @@ gns_resolve_name (int af, | |||
101 | } | 109 | } |
102 | else | 110 | else |
103 | { | 111 | { |
104 | pclose (p); | 112 | (void) pclose (p); |
105 | free (cmd); | 113 | free (cmd); |
114 | errno = EINVAL; | ||
106 | return -1; | 115 | return -1; |
107 | } | 116 | } |
108 | } | 117 | } |
@@ -110,11 +119,14 @@ gns_resolve_name (int af, | |||
110 | } | 119 | } |
111 | ret = pclose (p); | 120 | ret = pclose (p); |
112 | free (cmd); | 121 | free (cmd); |
113 | if (4 == ret) | 122 | if (! WIFEXITED (ret)) |
123 | return -1; | ||
124 | if (4 == WEXITSTATUS (ret)) | ||
114 | return -2; /* not for GNS */ | 125 | return -2; /* not for GNS */ |
115 | if (3 == ret) | 126 | if (3 == ret) |
116 | return -3; /* timeout -> not found */ | 127 | return -3; /* timeout -> not found */ |
117 | if ( (2 == ret) || (1 == ret) ) | 128 | if ( (2 == WEXITSTATUS (ret)) || |
129 | (1 == WEXITSTATUS (ret)) ) | ||
118 | return -2; /* launch failure -> service unavailable */ | 130 | return -2; /* launch failure -> service unavailable */ |
119 | return 0; | 131 | return 0; |
120 | } | 132 | } |