Skip to content

Instantly share code, notes, and snippets.

@vandorjw
Last active December 25, 2015 21:59
Show Gist options
  • Save vandorjw/7046434 to your computer and use it in GitHub Desktop.
Save vandorjw/7046434 to your computer and use it in GitHub Desktop.
SELinux for /var/www and /var/virtualenvs
As root, set everything under /var/www to httpd_sys_content_t
(sh) # semanage fcontext -a -t httpd_sys_content_t "/var/www(/.*)?"
(sh) # restorecon -R /var/www/
As root, set everything under /var/virtualenvs to lib_t
(sh) # semanage fcontext -a -t lib_t "/var/virtualenvs(/.*)?"
(sh) # restorecon -R /var/virtualenvs/
If you want to apply this to a single file, just specify the file, and on restorecon, remove the "-R"
@vandorjw
Copy link
Author

vandorjw commented Jan 6, 2014

sudo semanage fcontext -a -t httpd_log_t "/var/sites/me/vandorjw/logs(/.*)?"

libsepol.mls_from_string: invalid MLS context None (No such file or directory).
libsepol.mls_from_string: could not construct mls context structure (No such file or directory).
libsepol.context_from_record: could not create context structure (Invalid argument).
libsemanage.validate_handler: invalid context system_u:object_r:httpd_log_t:None specified for /var/sites/ca/vandorjw/logs(/.*)? [ all files ](Invalid argument).
libsemanage.dbase_llist_iterate: could not iterate over records (Invalid argument).
ValueError: Could not commit semanage transaction

sudo semanage fcontext -a -t httpd_log_t -r s0 "/var/sites/me/vandorjw/logs(/.*)?"

Notice: -r s0

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