From 30812cdfb92923c8d062a5db989015c676a87f07 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sun, 2 Dec 2012 19:05:44 +0100 Subject: NSS: Fix netgroup midpoint cache refresh https://fedorahosted.org/sssd/ticket/1683 The result of the percent calculation was always 0 as it used plain ints. The patch switches to using explicit floats to avoid reintroducing the bug again even with brackets. --- src/responder/common/responder_cmd.c | 2 +- src/responder/nss/nsssrv_netgroup.c | 2 +- src/responder/nss/nsssrv_services.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/responder/common/responder_cmd.c b/src/responder/common/responder_cmd.c index a9c4e36e..cb57cba1 100644 --- a/src/responder/common/responder_cmd.c +++ b/src/responder/common/responder_cmd.c @@ -257,7 +257,7 @@ sss_cmd_check_cache(struct ldb_message *msg, if(cache_refresh_percent) { midpoint_refresh = lastUpdate + - (cache_expire - lastUpdate)*cache_refresh_percent/100; + (cache_expire - lastUpdate)*cache_refresh_percent/100.0; if (midpoint_refresh - lastUpdate < 10) { /* If the percentage results in an expiration * less than ten seconds after the lastUpdate time, diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c index ae993fac..4b10b181 100644 --- a/src/responder/nss/nsssrv_netgroup.c +++ b/src/responder/nss/nsssrv_netgroup.c @@ -535,7 +535,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx) netgr->found = true; if (step_ctx->nctx->cache_refresh_percent) { lifetime = dom->netgroup_timeout * - (step_ctx->nctx->cache_refresh_percent / 100); + (step_ctx->nctx->cache_refresh_percent / 100.0); } else { lifetime = dom->netgroup_timeout; } diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c index ee847f6d..e56ad93a 100644 --- a/src/responder/nss/nsssrv_services.c +++ b/src/responder/nss/nsssrv_services.c @@ -325,7 +325,7 @@ getserv_send(TALLOC_CTX *mem_ctx, midpoint_refresh = 0; if(nctx->cache_refresh_percent) { midpoint_refresh = lastUpdate + - (cacheExpire - lastUpdate)*nctx->cache_refresh_percent/100; + (cacheExpire - lastUpdate)*nctx->cache_refresh_percent/100.0; if (midpoint_refresh - lastUpdate < 10) { /* If the percentage results in an expiration * less than ten seconds after the lastUpdate time, -- cgit