startup script: SELinux prevents PM2 from starting up on CentOS 8
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
On CentOS 8, pm2 startup generates a systemd service that is incompatible with the default security policy enforced by SELinux. Because of that, the service won't start.
How could we reproduce this issue?
On CentOS 8, just run pm2 startup. After following the instructions, start the service. It won't be able to start.
Supporting information
I've opened a StackExchange issue that explains the problem. I think the issue is that the PIDFile property of the service is a path to the home directory :
PIDFile=/home/john/.pm2/pm2.pid
I think this drifts away from the convention of having PID files in the /run directory, and this is probably why I get this error when I start the service
SELinux is preventing systemd from read access on the file pm2.pid.
To me, the reason is due to the mismatch between these two contexts
Source Context system_u:system_r:init_t:s0
Target Context system_u:object_r:user_home_t:s0
I believe the problem would be solved by having the PID file generated in the /run directory (actually I checked, and it worked).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the code that generates the systemd service for pm2 startup, then reproduce the issue on CentOS 8 with SELinux enabled and inspect the generated PIDFile path. Done means the generated service starts successfully under the default SELinux policy without reading the PID file from the user home directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, node.js
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100