From: Michael Adam Date: Wed, 11 Nov 2015 11:47:15 +0000 (+0100) Subject: nwrap: use the error code from nwrap_files_cache_reload() in callers X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=6078126eb5d60053811582c2f7bc267bc3bd41c9;p=obnox%2Fsamba%2Fsamba-obnox.git nwrap: use the error code from nwrap_files_cache_reload() in callers Signed-off-by: Michael Adam Reviewed-by: Andreas Schneider --- diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c index bcf92a4b140..9767a5e941c 100644 --- a/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -2929,12 +2929,17 @@ static struct passwd *nwrap_files_getpwnam(struct nwrap_backend *b, const char *name) { int i; + bool ok; (void) b; /* unused */ NWRAP_LOG(NWRAP_LOG_DEBUG, "Lookup user %s in files", name); - nwrap_files_cache_reload(nwrap_pw_global.cache); + ok = nwrap_files_cache_reload(nwrap_pw_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading passwd file"); + return NULL; + } for (i=0; i= nwrap_pw_global.num) { @@ -3084,7 +3099,13 @@ static struct spwd *nwrap_files_getspent(void) struct spwd *sp; if (nwrap_sp_global.idx == 0) { - nwrap_files_cache_reload(nwrap_sp_global.cache); + bool ok; + + ok = nwrap_files_cache_reload(nwrap_sp_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading shadow file"); + return NULL; + } } if (nwrap_sp_global.idx >= nwrap_sp_global.num) { @@ -3110,10 +3131,15 @@ static void nwrap_files_endspent(void) static struct spwd *nwrap_files_getspnam(const char *name) { int i; + bool ok; NWRAP_LOG(NWRAP_LOG_DEBUG, "Lookup user %s in files", name); - nwrap_files_cache_reload(nwrap_sp_global.cache); + ok = nwrap_files_cache_reload(nwrap_sp_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading shadow file"); + return NULL; + } for (i=0; i= nwrap_gr_global.num) { @@ -3352,8 +3394,13 @@ static int nwrap_files_gethostbyname(const char *name, int af, char canon_name[DNS_NAME_MAX] = { 0 }; size_t name_len; bool he_found = false; + bool ok; - nwrap_files_cache_reload(nwrap_he_global.cache); + ok = nwrap_files_cache_reload(nwrap_he_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "error loading hosts file"); + goto no_ent; + } name_len = strlen(name); if (name_len < sizeof(canon_name) && name[name_len - 1] == '.') { @@ -3514,8 +3561,13 @@ static struct addrinfo *nwrap_files_getaddrinfo(const char *name, bool skip_canonname = false; ENTRY e = { 0 }; ENTRY *e_p = NULL; + bool ok; - nwrap_files_cache_reload(nwrap_he_global.cache); + ok = nwrap_files_cache_reload(nwrap_he_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "error loading hosts file"); + return NULL; + } name_len = strlen(name); if (name_len < DNS_NAME_MAX && name[name_len - 1] == '.') { @@ -3588,10 +3640,15 @@ static struct hostent *nwrap_files_gethostbyaddr(const void *addr, struct nwrap_entdata *ed; const char *a; size_t i; + bool ok; (void) len; /* unused */ - nwrap_files_cache_reload(nwrap_he_global.cache); + ok = nwrap_files_cache_reload(nwrap_he_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "error loading hosts file"); + return NULL; + } a = inet_ntop(type, addr, ip, sizeof(ip)); if (a == NULL) { @@ -3663,7 +3720,13 @@ static struct hostent *nwrap_files_gethostent(void) struct hostent *he; if (nwrap_he_global.idx == 0) { - nwrap_files_cache_reload(nwrap_he_global.cache); + bool ok; + + ok = nwrap_files_cache_reload(nwrap_he_global.cache); + if (!ok) { + NWRAP_LOG(NWRAP_LOG_ERROR, "Error loading hosts file"); + return NULL; + } } if (nwrap_he_global.idx >= nwrap_he_global.num) {