# SELinux - Services Blocked by SELinux

## SELinux Blocked Apache Access to Files

```
setsebool -P httpd_unified 1<br></br>sudo /sbin/restorecon -R /var/www/html
```

## VSFTPD OOPS Error

Issue the following command: `setsebool -P ftp_home_dir 1`

## SSH bind port error permission denied

Issue the following command: `semanage port –a –t ssh_port_t –p tcp 1234`

## Permission denied HTTP Error 403

Issue the following command: `chcon -R --reference=/var/www /path/to/webroot`

## SELinux Denied HTTPD Access to MYSQLD on 127.0.0.1

1. `grep mysqld /var/log/audit/audit.log | audit2allow -M mysqld`
2. `semodule -i mysqld.pp`

## SELinux Denied FTP Access to SMB Share

1. Try to login with [ncftp](http://www.ncftp.com/ "ncftp") first and you will see the error "`OOPS: cannot change directory: /path/to/samba_share`"
2. Execute command: `su -c "grep ftpd_t /var/log/audit/audit.log | allow2audit -M ftpd_smb && semodule -i ftpd_smb"`
3. Try to login again with [ncftp](http://www.ncftp.com/ "ncftp") and ls command will return empty list a although it isn't
4. Execute command: `su -c "grep ftpd_t /var/log/audit/audit.log | allow2audit -M ftpd_smb && semodule -i ftpd_smb"`
5. Execute command =&gt; `sudo setsebool -P allow_ftpd_full_access on`
6. Execute command =&gt; `sudo setsebool -P ftp_home_dir on`

## Owncloud Custom Data Directory Denied

Assume owncloud data directory: `/var/data`

```
Install policycoreutils-python<br></br>/etc/init.d/restorecond start<br></br>chkconfig restorecond on<br></br>semanage fcontext -a -t httpd_sys_content_t '/var/data(/.*)?' <br></br>restorecon -Rv /var/data
```