mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
ignore glob no match error
This commit is contained in:
parent
8443360bac
commit
a13b3b97ea
@ -645,10 +645,18 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strpbrk((char *) file.data, "*?[") == NULL) {
|
||||||
|
|
||||||
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
|
||||||
|
|
||||||
|
return ngx_conf_parse(cf, &file);
|
||||||
|
}
|
||||||
|
|
||||||
ngx_memzero(&gl, sizeof(ngx_glob_t));
|
ngx_memzero(&gl, sizeof(ngx_glob_t));
|
||||||
|
|
||||||
gl.pattern = file.data;
|
gl.pattern = file.data;
|
||||||
gl.log = cf->log;
|
gl.log = cf->log;
|
||||||
|
gl.test = 1;
|
||||||
|
|
||||||
if (ngx_open_glob(&gl) != NGX_OK) {
|
if (ngx_open_glob(&gl) != NGX_OK) {
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
||||||
|
@ -257,7 +257,15 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
|
|||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_open_glob(ngx_glob_t *gl)
|
ngx_open_glob(ngx_glob_t *gl)
|
||||||
{
|
{
|
||||||
if (glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob) == 0) {
|
int n;
|
||||||
|
|
||||||
|
n = glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob);
|
||||||
|
|
||||||
|
if (n == 0) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == GLOB_NOMATCH && gl->test) {
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ typedef struct {
|
|||||||
glob_t pglob;
|
glob_t pglob;
|
||||||
u_char *pattern;
|
u_char *pattern;
|
||||||
ngx_log_t *log;
|
ngx_log_t *log;
|
||||||
|
ngx_uint_t test;
|
||||||
} ngx_glob_t;
|
} ngx_glob_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,6 +361,12 @@ ngx_open_glob(ngx_glob_t *gl)
|
|||||||
gl->dir = FindFirstFile((const char *) gl->pattern, &gl->finddata);
|
gl->dir = FindFirstFile((const char *) gl->pattern, &gl->finddata);
|
||||||
|
|
||||||
if (gl->dir == INVALID_HANDLE_VALUE) {
|
if (gl->dir == INVALID_HANDLE_VALUE) {
|
||||||
|
|
||||||
|
if (ngx_errno == ERROR_FILE_NOT_FOUND && gl->test) {
|
||||||
|
gl->no_match = 1;
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,6 +400,10 @@ ngx_read_glob(ngx_glob_t *gl, ngx_str_t *name)
|
|||||||
size_t len;
|
size_t len;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
|
|
||||||
|
if (gl->no_match) {
|
||||||
|
return NGX_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
if (gl->ready) {
|
if (gl->ready) {
|
||||||
*name = gl->name;
|
*name = gl->name;
|
||||||
|
|
||||||
@ -443,6 +453,10 @@ ngx_close_glob(ngx_glob_t *gl)
|
|||||||
ngx_free(gl->name.data);
|
ngx_free(gl->name.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gl->dir == INVALID_HANDLE_VALUE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (FindClose(gl->dir) == 0) {
|
if (FindClose(gl->dir) == 0) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, gl->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, gl->log, ngx_errno,
|
||||||
"FindClose(%s) failed", gl->pattern);
|
"FindClose(%s) failed", gl->pattern);
|
||||||
|
@ -184,7 +184,11 @@ ngx_int_t ngx_de_link_info(u_char *name, ngx_dir_t *dir);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
HANDLE dir;
|
HANDLE dir;
|
||||||
WIN32_FIND_DATA finddata;
|
WIN32_FIND_DATA finddata;
|
||||||
ngx_int_t ready;
|
|
||||||
|
unsigned ready:1;
|
||||||
|
unsigned test:1;
|
||||||
|
unsigned no_match:1;
|
||||||
|
|
||||||
u_char *pattern;
|
u_char *pattern;
|
||||||
ngx_str_t name;
|
ngx_str_t name;
|
||||||
size_t last;
|
size_t last;
|
||||||
|
Loading…
Reference in New Issue
Block a user