Skip to content

Enable SELinux Boolean httpd_setrlimit when nginx is configured to set the rlimit. #583

@marshallwp

Description

@marshallwp

Feature Overview

One of the nginx configurations this role lets you set is the worker rlimit. You can change this by setting the property: nginx_config_main_template['config']['main']['worker_rlimit_nofile']. Unfortunately, the setup-selinux.yml tasks do not not enable the httpd_setrlimit seboolean to permit nginx to do this, resulting in setrlimit(RLIMIT_NOFILE, 4096) failed (13: Permission denied) errors on systems with SELinux enabled.

I request the setup-selinux.yml script be updated to permit nginx to perform the configured operation. Possibly via:

- name: Allow SELinux rlimit configuration
  ansible.posix.seboolean:
    name: httpd_setrlimit
    state: "{{ nginx_config_main_template['config']['main']['worker_rlimit_nofile'] is defined }}"

Which would enable this seboolean only when this role configures nginx to modify it and disable it otherwise.

Alternatives Considered

A less opinionated way would be to only run the task when this role configures nginx to set the rlimit, but skip it otherwise.

- name: Allow SELinux rlimit configuration
  when: nginx_config_main_template['config']['main']['worker_rlimit_nofile'] is defined
  ansible.posix.seboolean:
    name: httpd_setrlimit
    state: true

This has the benefit of preserving the httpd_setrlimit value if it had been set to true via means outside of this role.

Finally, we could edit the list of sebooleans enabled by the "Allow SELinux HTTP network connections" task to include httpd_setrlimit.

- name: Allow SELinux HTTP network connections
ansible.posix.seboolean:
name: "{{ item }}"
state: true
persistent: true
loop:
- httpd_can_network_connect
- httpd_can_network_relay

Downside to this being it would always be enabled, which may not be desired.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementEnhance an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions