Allow pulpcore_server_t to manage gunicorn control socket in pulpcore…#96
Allow pulpcore_server_t to manage gunicorn control socket in pulpcore…#96
Conversation
…_server_var_lib_t
Gunicorn >= 25.1.0 introduces a control socket, defaulting to
$HOME/gunicorn.ctl. For the pulp user, HOME is /var/lib/pulp, so the
socket lands at /var/lib/pulp/gunicorn.ctl.
pulpcore-api and pulpcore-content run as pulpcore_server_t, which had
no policy rule covering sock_files in /var/lib/pulp. This caused AVC
denials on { create setattr getattr unlink } operations. All denials
are permissive=1 so nothing breaks at runtime, but ausearch catches
them and fb-verify-selinux.bats fails as a result.
Fix: extend the existing filetrans_pattern to transition sock_files
created by pulpcore_server_t in pulpcore_var_lib_t to the more
specific pulpcore_server_var_lib_t label, then add
manage_sock_files_pattern on that type. This is narrower than allowing
sock_file operations on pulpcore_var_lib_t directly, which would
cover all of /var/lib/pulp including GPG sockets.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Odilhao
left a comment
There was a problem hiding this comment.
Review
Overall: looks correct and the approach is sound — a few notes below.
What the PR does
gunicorn >= 25.1.0 creates a control socket at $HOME/gunicorn.ctl. For the pulp user that resolves to /var/lib/pulp/gunicorn.ctl. pulpcore_server_t (the domain for pulpcore-api/content) had no sock_file permission in /var/lib/pulp, causing AVC denials on { create setattr getattr unlink }.
The fix:
- Extends the existing
filetrans_patternto includesock_file— so sockets created bypulpcore_server_tinpulpcore_var_lib_tare labeledpulpcore_server_var_lib_tinstead. - Adds
manage_sock_files_patternon that narrower type.
What's good
- Correct scoping: using the file transition to
pulpcore_server_var_lib_trather than grantingsock_fileaccess directly onpulpcore_var_lib_tis the right call — it avoids accidentally covering GPG sockets and other unrelated sock_files under/var/lib/pulp. - Consistent style:
manage_sock_files_patternmatches the macro convention used throughout the rest of the file. - Good comment: the inline explanation of why this is needed is useful.
Notes
-
managevs. minimum necessary: the AVC denials only list{ create setattr getattr unlink }, butmanage_sock_files_patterngrants a superset (alsoread write rename link). This is fine —manageis the idiomatic level used everywhere else in this file and avoids chasing individual permissions if gunicorn's socket usage widens. -
$HOMEvs.$XDG_RUNTIME_DIR: the comment says the socket lands at/var/lib/pulp/gunicorn.ctl, which is correct for systemd services that don't setXDG_RUNTIME_DIR. Worth noting that gunicorn's actual lookup order is$XDG_RUNTIME_DIR/gunicorn.ctl→$HOME/.gunicorn/gunicorn.ctl→ working directory. For standard bare-metal/VM deployments this path is correct. -
Complementary fix upstream: we've also opened theforeman/puppet-pulpcore#403 to explicitly pass
--control-socket /run/pulpcore-{api,content}/gunicorn.ctlto gunicorn in the systemd service templates. That routes the socket to theRuntimeDirectory-managed/run/paths (already labeledpulpcore_server_var_run_twith existingsock_filetransitions), keeping runtime sockets out of/var/lib/pulpfor puppet-managed deployments. This SELinux fix is still needed as a safety net for other deployment methods (installer, manual, etc.).
Verdict
The change is minimal, correctly scoped, and fixes a real gap in the policy. Good to merge.
|
closing in favor of theforeman/puppet-pulpcore#403 |
…_server_var_lib_t
Gunicorn >= 25.1.0 introduces a control socket, defaulting to $HOME/gunicorn.ctl. For the pulp user, HOME is /var/lib/pulp, so the socket lands at /var/lib/pulp/gunicorn.ctl.
pulpcore-api and pulpcore-content run as pulpcore_server_t, which had no policy rule covering sock_files in /var/lib/pulp. This caused AVC denials on { create setattr getattr unlink } operations. All denials are permissive=1 so nothing breaks at runtime, but ausearch catches them and fb-verify-selinux.bats fails as a result.
Fix: extend the existing filetrans_pattern to transition sock_files created by pulpcore_server_t in pulpcore_var_lib_t to the more specific pulpcore_server_var_lib_t label, then add manage_sock_files_pattern on that type. This is narrower than allowing sock_file operations on pulpcore_var_lib_t directly, which would cover all of /var/lib/pulp including GPG sockets.