-
Notifications
You must be signed in to change notification settings - Fork 271
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
Fixes #30803: Bind to socket for Puma and Apache #883
Conversation
Combines with theforeman/foreman#7972 |
Note: I expect tests to fail but I want feedback on the approach before I do a bunch of updates. |
1437eaf
to
a308294
Compare
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.
Since the current implementation depends on a Foreman change, we'll need to be careful about compatibility. Right now the module is compatible with Foreman 2.0, as specified in README.md. We want to support current stable + development.
Ideally we'd write any Foreman patch in such a way that it's compatible with both the old FOREMAN_BIND
(without a protocol + port) and the new (with). Then cherry pick that into a stable branch. In the compatibility notes we'd then write that you need at least Foreman 2.1.x (2.1.2 at the time of writing?). I'd also like to cherry pick this specific patch to 2.1 when it's finished.
80ba3dc
to
e5c2e03
Compare
Unit tests are now passing but the acceptance tests won't pass until theforeman/foreman#7972 is available as an RPM |
Unintentionally I just reproduced this on Fedora 32. I had a |
Was it running localhost:3000 and then switched to Unix Socket? Or it was simply running and you restart |
From my journal:
I was working on a different patch, but I think what's similar is that a file descriptor was open for the correct bind ( |
I think, from some testing, the fundamental problem I am running into is that |
I think this happens here: docs: https://manpages.debian.org/testing/debhelper/dh_systemd_enable.1.en.html I am not sure if passing |
However, I don't exactly understand what the problem with the service vs the socket is. |
Maybe we want |
So, I think what happens is:
The annoying part is, on Debian 10 the above happens if the |
I'm starting to wonder if we should wait for Puma 5.1.0 which should include puma/puma#2362. That will simplify the configuration required. However, it may complicate support for older versions. |
I think Puma 5.1.0 will clean things up but @ekohl you have expressed the hardening this provides and I think that's a good thing to have. I am less familiar in this area, but if I look at how EL and Debian states are post install, pre-installer run, we have variation there and I think we'd benefit from commonality: On EL7, both
On Debian 10 and Ubuntu 18.04, the
|
Yes. The ever lasting struggle.
I think it makes sense not to start the service by default. We have an installer and there are no migration scripts to create the PostgreSQL DB. While it's normally the Debian policy to automatically start services, we're sufficiently different that it makes sense not to. I would also suggest to cherry pick that to 2.2 if it works in nightly. Not starting a service by default is the default on Red Hat based systems so the installer should handle it perfectly well. |
This PR seems to be hitting this -- #897 |
Woohoo, the Debian 10 tests passed with the packaging updates |
I rebased this on latest to re-run the tests given it has sat for a bit. |
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 installed nightly on centos7 with this PR using Forklift. Playing around with it a bit, I can see the socket at /run/foreman.sock
and the drop in configuration with expected values at /etc/systemd/system/foreman.socket.d/installer.conf
(I had to read some docs to understand the purpose of the blank ListenStream=
). I tested basic functionality and everything seems working as expected.
I couldn't install nightly on ubuntu 1804 but the failure is with redis.service
and seems wholly unrelated to changes here.
I think this broke EL8 installs: % grep 'AVC.*foreman.sock' var/log/audit/audit.log
type=AVC msg=audit(1606342776.512:2783): avc: denied { getattr } for pid=15093 comm="rails" path="/run/foreman.sock" dev="tmpfs" ino=121834 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=0
type=AVC msg=audit(1606342862.770:2796): avc: denied { write } for pid=14897 comm="httpd" name="foreman.sock" dev="tmpfs" ino=121834 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=0
type=AVC msg=audit(1606342862.804:2797): avc: denied { write } for pid=14900 comm="httpd" name="foreman.sock" dev="tmpfs" ino=121834 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=0 there are also other denials: % grep 'AVC.*vda' var/log/audit/audit.log
type=AVC msg=audit(1606342756.671:2781): avc: denied { write } for pid=15093 comm="rails" name="home" dev="vda1" ino=100696036 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=unconfined_u:object_r:rpm_script_tmp_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1606342756.671:2782): avc: denied { write } for pid=15093 comm="rails" name="home" dev="vda1" ino=100696036 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=unconfined_u:object_r:rpm_script_tmp_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1606342815.244:2789): avc: denied { write } for pid=15466 comm="sidekiq" name="home" dev="vda1" ino=100696036 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=unconfined_u:object_r:rpm_script_tmp_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1606342815.244:2790): avc: denied { write } for pid=15466 comm="sidekiq" name="home" dev="vda1" ino=100696036 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=unconfined_u:object_r:rpm_script_tmp_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1606342839.039:2792): avc: denied { write } for pid=15574 comm="sidekiq" name="home" dev="vda1" ino=100696036 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=unconfined_u:object_r:rpm_script_tmp_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1606342839.039:2793): avc: denied { write } for pid=15574 comm="sidekiq" name="home" dev="vda1" ino=100696036 scontext=system_u:system_r:foreman_rails_t:s0 tcontext=unconfined_u:object_r:rpm_script_tmp_t:s0 tclass=dir permissive=0 |
why is |
hah, |
The goal of this change is to switch to using local unix sockets to bind Puma to, and also to have Apache reverse proxy to increasing the security of the communication from the reverse proxy to the socket.
I am looking to understand if I need to enforce permissions and user-group on the socket to enhance security. There is also currently SELinux denials that are associated with this change we will need to account for. On my test system they are:
SELinux policy changes needed to address -- theforeman/foreman-selinux#113