Skip to content

Support SELinux via configurations and documentation #4937

Open

Description

@adatum

System details

RStudio Edition : Server
RStudio Version : 1.2.1335
OS Version      : Fedora 30
R Version       : 3.5.3

Steps to reproduce the problem

Install rstudio-server and attempt to log in at localhost:8787 with SELinux in enforcing mode (default on Fedora and others). Login will fail due to SELinux denial.

Describe the problem in detail

SELinux prevents RStudio Server from functioning. Setting SELinux in permissive mode works fine, albeit with dozens of SELinux alerts.

Describe the behavior you expected

RStudio Server allowing user login and working normally with SELinux enabled in enforcing mode.

Activity

  1. jmcphers commented on Jun 12, 2019

    @jmcphers
    Member

    Can you be more specific about the SELinux denial and alerts you're seeing?

  2. adatum commented on Jun 12, 2019

    @adatum
    Author

    There's a long list of them. The first was

    AVC avc: denied { setpgid } for pid=32444 comm="rserver" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=process permissive=0

    Setting SELinux to permissive mode logged a lot more:
    rstudio_selinux

    There is also a Japanese blog that describes this exact issue: https://bitwalk.blogspot.com/2018/08/rstudio-server-selinux-fedora.html

  3. jmkekala commented on Jun 13, 2019

    @jmkekala

    Hi,
    You'll have to permit following policies:

    httpd_can_network_connect
    httpd_can_network_relay
    edit:
    Or was it that httpd_can_network_connect was sufficient.

    BR,
    Juha

  4. adatum commented on Jun 13, 2019

    @adatum
    Author

    I enabled both httpd_can_network_connect and httpd_can_network_relay booleans but it still failed. Also, are those needed for localhost?

    type=AVC msg=audit(1560450139.521:375): avc: denied { create } for pid=9244 comm="rsession" name="[USER]-d" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=sock_file permissive=0

  5. jmcphers commented on Jun 13, 2019

    @jmcphers
    Member

    Using RStudio with SELinux will require you to give RStudio the appropriate privileges to run -- it's not a bug that it e.g. requires network access. If you need help configuring the server with SELinux, please use the R Admins section of our community forum:

    https://community.rstudio.com/c/r-admin

    If you feel that there's a specific SELinux capability that RStudio should not require for operation but does, we're happy to discuss those individually.

  6. adatum commented on Jun 13, 2019

    @adatum
    Author

    If RStudio is missing SELinux policy configuration to have it run properly, I would consider that a bug. I doubt users should be doing that manually, or at least clear instructions could be provided to do it correctly.

    I did already post on the community forum 11 days ago but there has been not a single reply there. https://community.rstudio.com/t/selinux-errors-with-rstudio-server/32229

  7. adatum commented on Jun 27, 2019

    @adatum
    Author

    Thanks to help from the #selinux IRC channel, a solution was found:

    sudo chcon -R -t bin_t /usr/lib/rstudio-server/bin/

    This gives the binaries the right context, since they are for some reason in a directory for libraries. It was pointed out that this step would not be needed at all if Filesystem Hierarchy Standards were followed in packaging RStudio Server.


    However, this solution lets RStudio Server run unconstrained since no targeted policy exists for it. Ideally, a selinux policy should be created to protect system integrity in case the process is compromised.

    It would be good to have the input of RStudio developers, and/or those with a good understanding of how RStudio Server works, in creating a suitable selinux policy. The #selinux IRC channel has shown great willingness to help. I'm happy to help test.

    Needless to say, I do think this issue should be reopened.

  8. jmcphers commented on Jul 3, 2019

    @jmcphers
    Member

    See also: #1750

  9. adatum commented on Mar 13, 2020

    @adatum
    Author

    Some good news, at least for Fedora users.

    Today rstudio, rstudio-desktop, and rstudio-server packages became available in Fedora's repos, thanks to maintainer iucar: https://bodhi.fedoraproject.org/updates/FEDORA-2020-65ff671dba

    It packages binaries into /usr/libexec. I have not tested much yet, but so far RStudio and Rstudio Server seem to be working fine without SELinux issues.

    Hopefully other distro maintainers will follow. Rstudio developers now have a guide to improve their packaging and avoid SELinux issues.

  10. casa-henrym commented on Jun 12, 2020

    @casa-henrym

    I am experiencing the issue - which someone has previously posted on StackOverflow - which is caused by SELinux policy not set properly. I'm using Red Hat Enterprise Linux Server release 7.8 (Maipo), so not too different from the op's setup, and RStudio Version 1.2.5042.

    In Sys.timezone() the call to system("timedatectl", intern = TRUE) waits for about a minute before it returns with an error - this is not nice behaviour. Is it at all possible to check if the action is permitted by the SELinux policy before attempting it???

    Despite the error message the call to Sys.timezone() succeeds because a subsequent step in the function (checking the symlink /etc/localtime) is able to determine the timezone. The timezone value is then cached in the R session so subsequent calls to Sys.timezone() return immediately and without any error message. Higher-level functions Sys.time() and lubridate::now() are affected by this issue.

    The solution posted on SO is to update the SELinux policy. Unfortunately I'm not an administrator so I don't know the details of the policy.

  11. 54 remaining items

  12. j-lubega commented on Oct 2, 2024

    @j-lubega

    ZD ticket affected by this: #110538

  13. pyltime commented on Nov 22, 2024

    @pyltime
    Contributor

    ZD ticket affected by this: #112382

  14. lachlansimpson commented on Feb 20, 2025

    @lachlansimpson

    Hi @MariaSemple @adamhigerd , I can see this is tagged Patch 2024.12.1 - but I'm not seeing this update in the 2024.12.1 NEWS.

    I can see that #15675 is merged already.

    Can we confirm that the change went into the latest patch release? Thanks

  15. gtritchie commented on Feb 20, 2025

    @gtritchie
    Member
  16. MariaSemple commented on Feb 20, 2025

    @MariaSemple
    Collaborator

    Thanks for fixing that Gary! Yes, that's correct. It went into M.O.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions