-
Notifications
You must be signed in to change notification settings - Fork 27
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
Refs #30803: Allow Apache to connect to Unix socket #113
Conversation
Thanks for the patch. While this will probably work, we should follow good practice.
|
I updated this with the suggestions. Went through the workflow above and I keep running into:
I am not clear what I need to do to resolve that. |
Sorry for the delay, how do I reproduce. |
You need this PR -- theforeman/puppet-foreman#883
|
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.
If the sock file was in /run/foreman directory none of these would be necessary as files do get their parent directories labels automatically. In order to have the file in /run we need to add an extra (transition) rule: files_pid_filetrans.
foreman.te
Outdated
# Allow Apache access to the Unix socket | ||
allow foreman_rails_t httpd_var_run_t:dir search; | ||
allow httpd_t foreman_rails_t:unix_stream_socket { connectto getattr read write }; | ||
|
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.
Replace this with with:
# Socket and PID files transition
files_pid_filetrans(foreman_rails_t, foreman_var_run_t, { file dir sock_file })
# Allow Apache access to the Unix socket
files_search_pids(httpd_t)
stream_connect_pattern(httpd_t, foreman_var_run_t, foreman_var_run_t, foreman_rails_t)
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.
Put the first rule above next to Foreman rules, this is a rule for Foreman app to create the SOCK file in /run
with the correct label. And the remaining two rules can be added next to Apache rules.
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.
Given #113 (comment) (the last part), does the Foreman app need a rule to create the SOCK file? I'm trying to parse the syntax here in the SELinux world with respect to who needs the rule.
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 files_pid_filetrans(foreman_rails_t, foreman_var_run_t, { file dir sock_file })
rule says "when an app running in foreman_rails_t domain creates a pid or a socket in var_run_t give it foreman_var_run_t". I tested this on my install, when I restart "foreman" systemd unit it creates the /var/foreman.sock now with the correct label,
Note that foreman.fc
only defines regular expressions for restorecon
. You still need those transition rules.
Does that put some light on how this works?
Yea, we discussed where to store it. The tricky part is that the socket is owned by Apache and not Foreman which is what allows Apache to send traffic via the reverse proxy and lock down what system users can communicate over the socket (https://github.com/theforeman/puppet-foreman/pull/883/files#diff-d6542e555b7c0207c63c969d650e1036R5). This is the same pattern that gunicorn takes (https://docs.gunicorn.org/en/stable/deploy.html#systemd):
|
More importantly, Apache needs to be able to read/write to the socket. We now keep |
@lzap Updated with your recommendations.. not sure if I got them in the right sections of the |
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.
Looks good. Let's give this a spin.
No description provided.