[nginx] GeoIP: fixed database file names to be resolved from pre...
    Maxim Dounin 
    mdounin at mdounin.ru
       
    Fri Oct 31 20:43:15 UTC 2025
    
    
  
details:   http://freenginx.org/hg/nginx/rev/ffc824e2c50f
branches:  
changeset: 9432:ffc824e2c50f
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri Oct 31 08:08:01 2025 +0300
description:
GeoIP: fixed database file names to be resolved from prefix.
Previously, relative database file names set by the geoip_country,
geoip_city, and geoip_org configuration directives were not processed
with ngx_conf_full_name() and therefore resolved from the process current
working directory, leading to changes in behaviour depending on the current
directory during startup.  This also differs from the expected behaviour
of configuration directives, where relative paths are expected to be
resolved either from prefix or from configuration prefix.
Fix is to use ngx_conf_full_name() to resolve relative database file names
from prefix.
diffstat:
 src/http/modules/ngx_http_geoip_module.c |  12 ++++++++++++
 src/stream/ngx_stream_geoip_module.c     |  12 ++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
diffs (72 lines):
diff --git a/src/http/modules/ngx_http_geoip_module.c b/src/http/modules/ngx_http_geoip_module.c
--- a/src/http/modules/ngx_http_geoip_module.c
+++ b/src/http/modules/ngx_http_geoip_module.c
@@ -686,6 +686,10 @@ ngx_http_geoip_country(ngx_conf_t *cf, n
 
     value = cf->args->elts;
 
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+        return NGX_CONF_ERROR;
+    }
+
     gcf->country = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
 
     if (gcf->country == NULL) {
@@ -741,6 +745,10 @@ ngx_http_geoip_org(ngx_conf_t *cf, ngx_c
 
     value = cf->args->elts;
 
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+        return NGX_CONF_ERROR;
+    }
+
     gcf->org = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
 
     if (gcf->org == NULL) {
@@ -802,6 +810,10 @@ ngx_http_geoip_city(ngx_conf_t *cf, ngx_
 
     value = cf->args->elts;
 
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+        return NGX_CONF_ERROR;
+    }
+
     gcf->city = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
 
     if (gcf->city == NULL) {
diff --git a/src/stream/ngx_stream_geoip_module.c b/src/stream/ngx_stream_geoip_module.c
--- a/src/stream/ngx_stream_geoip_module.c
+++ b/src/stream/ngx_stream_geoip_module.c
@@ -635,6 +635,10 @@ ngx_stream_geoip_country(ngx_conf_t *cf,
 
     value = cf->args->elts;
 
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+        return NGX_CONF_ERROR;
+    }
+
     gcf->country = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
 
     if (gcf->country == NULL) {
@@ -690,6 +694,10 @@ ngx_stream_geoip_org(ngx_conf_t *cf, ngx
 
     value = cf->args->elts;
 
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+        return NGX_CONF_ERROR;
+    }
+
     gcf->org = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
 
     if (gcf->org == NULL) {
@@ -751,6 +759,10 @@ ngx_stream_geoip_city(ngx_conf_t *cf, ng
 
     value = cf->args->elts;
 
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
+        return NGX_CONF_ERROR;
+    }
+
     gcf->city = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
 
     if (gcf->city == NULL) {
    
    
More information about the nginx-devel
mailing list