chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
networkd: gracefully handle failure to emit signals when dbus is not connected
[elogind.git]
/
src
/
nss-mymachines
/
nss-mymachines.c
diff --git
a/src/nss-mymachines/nss-mymachines.c
b/src/nss-mymachines/nss-mymachines.c
index 09c5d05f2ecd98da008301013c1d434cf654c5de..9476ad1694f2be8d52a6613e46692786c5541b6b 100644
(file)
--- a/
src/nss-mymachines/nss-mymachines.c
+++ b/
src/nss-mymachines/nss-mymachines.c
@@
-32,17
+32,17
@@
NSS_GETHOSTBYNAME_PROTOTYPES(mymachines);
NSS_GETHOSTBYNAME_PROTOTYPES(mymachines);
-static int count_addresses(sd_bus_message *m,
unsigned
af, unsigned *ret) {
+static int count_addresses(sd_bus_message *m,
int
af, unsigned *ret) {
unsigned c = 0;
int r;
assert(m);
assert(ret);
unsigned c = 0;
int r;
assert(m);
assert(ret);
- while ((r = sd_bus_message_enter_container(m, 'r', "
y
ay")) > 0) {
-
unsigned char
family;
+ while ((r = sd_bus_message_enter_container(m, 'r', "
i
ay")) > 0) {
+
int
family;
- r = sd_bus_message_read(m, "
y
", &family);
+ r = sd_bus_message_read(m, "
i
", &family);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-79,7
+79,7
@@
enum nss_status _nss_mymachines_gethostbyname4_r(
struct gaih_addrtuple *r_tuple, *r_tuple_first = NULL;
_cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
struct gaih_addrtuple *r_tuple, *r_tuple_first = NULL;
_cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
- _cleanup_bus_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_
close_
unref_ sd_bus *bus = NULL;
_cleanup_free_ int *ifindices = NULL;
_cleanup_free_ char *class = NULL;
size_t l, ms, idx;
_cleanup_free_ int *ifindices = NULL;
_cleanup_free_ char *class = NULL;
size_t l, ms, idx;
@@
-122,7
+122,7
@@
enum nss_status _nss_mymachines_gethostbyname4_r(
if (r < 0)
goto fail;
if (r < 0)
goto fail;
- r = sd_bus_message_enter_container(reply, 'a', "(
y
ay)");
+ r = sd_bus_message_enter_container(reply, 'a', "(
i
ay)");
if (r < 0)
goto fail;
if (r < 0)
goto fail;
@@
-151,12
+151,12
@@
enum nss_status _nss_mymachines_gethostbyname4_r(
/* Second, append addresses */
r_tuple_first = (struct gaih_addrtuple*) (buffer + idx);
/* Second, append addresses */
r_tuple_first = (struct gaih_addrtuple*) (buffer + idx);
- while ((r = sd_bus_message_enter_container(reply, 'r', "
y
ay")) > 0) {
-
unsigned char
family;
+ while ((r = sd_bus_message_enter_container(reply, 'r', "
i
ay")) > 0) {
+
int
family;
const void *a;
size_t sz;
const void *a;
size_t sz;
- r = sd_bus_message_read(reply, "
y
", &family);
+ r = sd_bus_message_read(reply, "
i
", &family);
if (r < 0)
goto fail;
if (r < 0)
goto fail;
@@
-205,6
+205,11
@@
enum nss_status _nss_mymachines_gethostbyname4_r(
if (ttlp)
*ttlp = 0;
if (ttlp)
*ttlp = 0;
+ /* Explicitly reset all error variables */
+ *errnop = 0;
+ *h_errnop = NETDB_SUCCESS;
+ h_errno = 0;
+
return NSS_STATUS_SUCCESS;
fail:
return NSS_STATUS_SUCCESS;
fail:
@@
-223,7
+228,7
@@
enum nss_status _nss_mymachines_gethostbyname3_r(
char **canonp) {
_cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
char **canonp) {
_cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
- _cleanup_bus_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_
close_
unref_ sd_bus *bus = NULL;
_cleanup_free_ char *class = NULL;
unsigned c = 0, i = 0;
char *r_name, *r_aliases, *r_addr, *r_addr_list;
_cleanup_free_ char *class = NULL;
unsigned c = 0, i = 0;
char *r_name, *r_aliases, *r_addr, *r_addr_list;
@@
-267,7
+272,7
@@
enum nss_status _nss_mymachines_gethostbyname3_r(
if (r < 0)
goto fail;
if (r < 0)
goto fail;
- r = sd_bus_message_enter_container(reply, 'a', "(
y
ay)");
+ r = sd_bus_message_enter_container(reply, 'a', "(
i
ay)");
if (r < 0)
goto fail;
if (r < 0)
goto fail;
@@
-284,10
+289,7
@@
enum nss_status _nss_mymachines_gethostbyname3_r(
alen = FAMILY_ADDRESS_SIZE(af);
l = strlen(name);
alen = FAMILY_ADDRESS_SIZE(af);
l = strlen(name);
- ms = ALIGN(l+1) +
- sizeof(char*) +
- (c > 0 ? c : 1) * ALIGN(alen) +
- (c > 0 ? c+1 : 2) * sizeof(char*);
+ ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
if (buflen < ms) {
*errnop = ENOMEM;
if (buflen < ms) {
*errnop = ENOMEM;
@@
-307,12
+309,12
@@
enum nss_status _nss_mymachines_gethostbyname3_r(
/* Third, append addresses */
r_addr = buffer + idx;
/* Third, append addresses */
r_addr = buffer + idx;
- while ((r = sd_bus_message_enter_container(reply, 'r', "
y
ay")) > 0) {
-
unsigned char
family;
+ while ((r = sd_bus_message_enter_container(reply, 'r', "
i
ay")) > 0) {
+
int
family;
const void *a;
size_t sz;
const void *a;
size_t sz;
- r = sd_bus_message_read(reply, "
y
", &family);
+ r = sd_bus_message_read(reply, "
i
", &family);
if (r < 0)
goto fail;
if (r < 0)
goto fail;
@@
-365,6
+367,11
@@
enum nss_status _nss_mymachines_gethostbyname3_r(
if (canonp)
*canonp = r_name;
if (canonp)
*canonp = r_name;
+ /* Explicitly reset all error variables */
+ *errnop = 0;
+ *h_errnop = NETDB_SUCCESS;
+ h_errno = 0;
+
return NSS_STATUS_SUCCESS;
fail:
return NSS_STATUS_SUCCESS;
fail: