-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: APISIX runs in the /root directory and reports errors
#3220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Makefile
Outdated
| @echo "Non-zero exit status: 1" | ||
| @echo "Error, It is forbidden to run APISIX in the /root directory." | ||
| @echo "Error: It is forbidden to run APISIX in the /root directory." | ||
| @exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add a test for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to add test cases for Makefile. Can you give me some suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See
apisix/.travis/apisix_cli_test/test_main.sh
Line 920 in ebd158a
| out=$(make init 2>&1 || true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got it.
|
I don't think this method can completely solve the permission problem. Can an error be thrown if the code file cannot be found in the init phase of apisix? |
There will be no errors when executing |
Makefile
Outdated
| .PHONY: run | ||
| run: default | ||
| ifeq ("$(wildcard logs/nginx.pid)", "") | ||
| ifeq ("$(findstring /root, ${PWD})", "/root") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a thorough solution, not a temporary patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
|
|
||
| local function start(env, ...) | ||
| if env.is_root_path then | ||
| util.die("Error: It is forbidden to run APISIX in the /root directory.\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don’t understand the permissions issues under Linux at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current way is right, but it is hard to read. @Firstsawyou please add some comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any news? @Firstsawyou
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note has been added here: https://github.com/apache/apisix/pull/3220/files#diff-c25d1a2aac172147aa01feec3fa29bfe6c4625cda4773719a1cf13e67fd54da2R42
I will add more comments here later:
https://github.com/apache/apisix/pull/3220/files#diff-228a51571b53709ad043d1c6c14fc8e508c248a84f8014fe548b5d259cedd5ddR378
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cause of the bug: After APISIX is started, the worker process has the authority of nobody ordinary user. When APISIX is in the /root directory, ordinary users do not have the authority to access the /root directory. Therefore, when APISIX is started, the error log error.log will show the following error message:
init_worker_by_lua error: /root/apisix-2.1/apisix/init.lua:89: module 'resty.worker.events' not found:
no field package.preload['resty.worker.events']
no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events.lua'
no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events/init.lua'
no file '/root/apisix-2.1/resty/worker/events.lua'
no file '/root/apisix-2.1/resty/worker/events/init.lua'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any news? @Firstsawyou
updated.
t/cli/cli.t
Outdated
| === TEST 2: It is forbidden to run APISIX under the /root directory(is_root_path is true). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use shell script to test this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
|
|
||
| local function start(env, ...) | ||
| if env.is_root_path then | ||
| util.die("Error: It is forbidden to run APISIX in the /root directory.\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current way is right, but it is hard to read. @Firstsawyou please add some comment here.
|
@Firstsawyou CI failed, please fix it first |
Okay, I will fix it later. |
|
|
||
| local function start(env, ...) | ||
| if env.is_root_path then | ||
| util.die("Error: It is forbidden to run APISIX in the /root directory.\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any news? @Firstsawyou
/root directory and reports errors
|
ping @moonming |
|
I think this only solves the permission problem of apisix deployed under |
Obviously, this PR solves the problem that APISIX runs under Please submit a new issue describing your problem. |

What this PR does / why we need it:
Cause of the bug: After APISIX is started, the
worker processhas the authority of nobody ordinary user. When APISIX is in the /root directory, ordinary users do not have the authority to access the/rootdirectory. Therefore, when APISIX is started, the error logerror.logwill show the following error message:The solution: it is forbidden to execute make run in the /root directory to run apisix.
close #3207
Pre-submission checklist: