mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 14:47:07 +02:00
BUG/MINOR: hlua: take default-path into account with lua-load-per-thread
As discussed in GH #3051, default-path is not taken into account when loading files using lua-load-per-thread. In fact, the initial hlua_load_state() (performed on first thread which parses the config) is successful, but other threads run hlua_load_state() later based on config hints which were saved by the first thread, and those config hints only contain the file path provided on the lua-load-per-thread config line, not the absolute one. Indeed, `default-path` directive changes the current working directory only for the thread parsing the configuration. To fix the issue, when storing config hints under hlua_load_per_thread() we now make sure to save the absolute file path for `lua-load-per-thread' argument. Thanks to GH user @zhanhb for having reported the issue It may be backported to all stable versions.
This commit is contained in:
parent
83a335f925
commit
2ffe515d97
19
src/hlua.c
19
src/hlua.c
@ -13363,7 +13363,24 @@ static int hlua_load_per_thread(char **args, int section_type, struct proxy *cur
|
||||
return -1;
|
||||
}
|
||||
for (i = 1; *(args[i]) != 0; i++) {
|
||||
per_thread_load[len][i - 1] = strdup(args[i]);
|
||||
/* first arg is filename */
|
||||
if (i == 1 && args[1][0] != '/') {
|
||||
char *curpath;
|
||||
char *fullpath = NULL;
|
||||
|
||||
/* filename is provided using relative path, store the absolute path
|
||||
* to take current chdir into account for other threads file load
|
||||
* which occur later
|
||||
*/
|
||||
curpath = getcwd(trash.area, trash.size);
|
||||
if (!curpath) {
|
||||
memprintf(err, "failed to retrieve cur path");
|
||||
return -1;
|
||||
}
|
||||
per_thread_load[len][i - 1] = memprintf(&fullpath, "%s/%s", curpath, args[1]);
|
||||
}
|
||||
else
|
||||
per_thread_load[len][i - 1] = strdup(args[i]);
|
||||
if (per_thread_load[len][i - 1] == NULL) {
|
||||
memprintf(err, "out of memory error");
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user