diff --git a/Makefile b/Makefile index b1c50ce..bc223c9 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ BINSYMDIR=$(PREFIX)/local/bin/ CRITERION_VERSION=2.4.2 SHUNIT_VERSION=2.1.8 -CURL_VERSION_TAG=8_12_1 +CURL_VERSION_TAG=8_15_0 CURL_VERSION=$(shell echo $(CURL_VERSION_TAG) | sed -e 's/_/./g') OPENSSL_VERSION=3.6.0 ZLIB_VERSION=1.3.1 diff --git a/stns.c b/stns.c index b3f0e19..cff60cd 100644 --- a/stns.c +++ b/stns.c @@ -99,12 +99,36 @@ int stns_load_config(char *filename, stns_conf_t *c) GET_TOML_BYKEY(gid_shift, toml_rtoi, 0, TOML_NULL_OR_INT); GET_TOML_BYKEY(cache_ttl, toml_rtoi, 600, TOML_NULL_OR_INT); GET_TOML_BYKEY(negative_cache_ttl, toml_rtoi, 10, TOML_NULL_OR_INT); - GET_TOML_BYKEY(ssl_verify, toml_rtob, 1, TOML_NULL_OR_INT); + + // Load long type fields via temporary int variables + int tmp_ssl_verify = 1; + int tmp_request_timeout = 10; + int tmp_http_location = 0; + + if (0 != (raw = toml_raw_in(tab, "ssl_verify"))) { + if (0 != toml_rtob(raw, &tmp_ssl_verify)) { + syslog(LOG_ERR, "%s(stns)[L%d] cannot parse toml file:%s key:ssl_verify", __func__, __LINE__, filename); + } + } + c->ssl_verify = (long)tmp_ssl_verify; + + if (0 != (raw = toml_raw_in(tab, "request_timeout"))) { + if (0 != toml_rtoi(raw, &tmp_request_timeout)) { + syslog(LOG_ERR, "%s(stns)[L%d] cannot parse toml file:%s key:request_timeout", __func__, __LINE__, filename); + } + } + c->request_timeout = (long)tmp_request_timeout; + + if (0 != (raw = toml_raw_in(tab, "http_location"))) { + if (0 != toml_rtob(raw, &tmp_http_location)) { + syslog(LOG_ERR, "%s(stns)[L%d] cannot parse toml file:%s key:http_location", __func__, __LINE__, filename); + } + } + c->http_location = (long)tmp_http_location; + GET_TOML_BYKEY(cache, toml_rtob, 1, TOML_NULL_OR_INT); - GET_TOML_BYKEY(request_timeout, toml_rtoi, 10, TOML_NULL_OR_INT); GET_TOML_BYKEY(request_retry, toml_rtoi, 3, TOML_NULL_OR_INT); GET_TOML_BYKEY(request_locktime, toml_rtoi, 60, TOML_NULL_OR_INT); - GET_TOML_BYKEY(http_location, toml_rtob, 0, TOML_NULL_OR_INT); TRIM_SLASH(api_endpoint) TRIM_SLASH(cache_dir) @@ -314,8 +338,8 @@ static CURLcode inner_http_request(stns_conf_t *c, char *path, stns_response_t * } } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, c->ssl_verify); - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, c->ssl_verify); + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)c->ssl_verify); + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)c->ssl_verify); curl_easy_setopt(curl, CURLOPT_USERAGENT, STNS_VERSION_WITH_NAME); if (c->http_location == 1) { curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); @@ -347,13 +371,13 @@ static CURLcode inner_http_request(stns_conf_t *c, char *path, stns_response_t * "http://unix", path); } curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, c->request_timeout); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)c->request_timeout); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, response_callback); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, res); curl_easy_setopt(curl, CURLOPT_HEADERDATA, c); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); #ifdef DEBUG syslog(LOG_ERR, "%s(stns)[L%d] before request http request: %s", __func__, __LINE__, url); diff --git a/stns.h b/stns.h index bdc7a33..4a5f83f 100644 --- a/stns.h +++ b/stns.h @@ -58,7 +58,7 @@ struct stns_conf_t { char *query_wrapper; char *chain_ssh_wrapper; char *http_proxy; - int http_location; + long http_location; char *cache_dir; char *tls_cert; char *tls_key; @@ -68,9 +68,9 @@ struct stns_conf_t { stns_user_httpheaders_t *http_headers; int uid_shift; int gid_shift; - int ssl_verify; + long ssl_verify; int use_cached; - int request_timeout; + long request_timeout; int request_retry; int request_locktime; int cache;