Bug 670557

Summary: clamsmtpd cannot write to /var/lib/clamd.clamsmtp (SElinux)
Product: [Fedora] Fedora Reporter: Jan "Yenya" Kasprzak <kas>
Component: clamsmtpAssignee: Dan Williams <dcbw>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: domg444, dwalsh, mgrepl, nathanael
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-16 21:51:40 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jan "Yenya" Kasprzak 2011-01-18 16:56:58 UTC
Description of problem:
clamsmtpd in its default configuration (/etc/clamd.d/clamsmtp.conf) uses
/var/lib/clamd.clamsmtp as the data directory. This directory is labeled by default with var_lib_t type, and SELinux prevents clamd to write its temporary
data there.

Version-Release number of selected component (if applicable):
clamsmtp-1.10-1.fc14.x86_64
clamav-0.96.5-1400.fc14.x86_64
clamav-server-0.96.5-1400.fc14.x86_64
postfix-2.7.1-1.fc14.x86_64
selinux-policy-targeted-3.9.7-20.fc14.noarch


How reproducible:
100 %

Steps to Reproduce:
1. Install F14 with the above packages, and without sendmail. 
2. Configure postfix to use clamav/clamsmtpd - for example using this howto: http://www.debian-administration.org/articles/259
3. label the port 10026 as smtp_port_t using the following command: semanage port -a -t smtp_port_t -p tcp 10026
4. start postfix, clamav, clamsmtpd
5. telnet localhost 10025, and send a test e-mail using SMTP

  
Actual results:
internal server error with the following line in /var/log/maillog:
clamav error: /var/lib/clamd.clamsmtp/clamsmtpd.SgR8xa: lstat() failed: Permission denied. ERROR

Expected results:
The verified e-mail should be passed back to postfix.

Additional info:
Labeling the files the following way fixes the problem:
semanage fcontext -a  -t clamd_var_lib_t /var/lib/clamd.clamsmtp/'(.*)'
semanage fcontext -a  -t clamd_var_lib_t /var/lib/clamd.clamsmtp
I think the above two settings should be added to the default policy for clamd.

The label of port 10026 (smtp_port_t) can be also added to the policy.

Comment 1 Nathanael Noblet 2011-01-18 17:20:41 UTC
Looks like we need a policy update for this. @dwalsh, the package installs the directory as part of the spec.

The ports 10025 and 10026 are user configurable but the config file uses those by default, so I'm not sure if they should be labeled or not.

Comment 2 Dominick Grift 2011-01-18 17:31:52 UTC
clamsmtp needs selinux-policy. Currently is runs unprotected so we should write policy for it.

Comment 3 Daniel Walsh 2011-01-18 19:20:19 UTC
Miroslav lets add

/var/lib/clamd.*			gen_context(system_u:object_r:clamd_var_lib_t,s0)


for now to F13 and F14

10025 is labeled 

network_port(amavisd_send, tcp,10025,s0)

Comment 4 Jan "Yenya" Kasprzak 2011-01-18 19:52:41 UTC
10025 is OK, but 10026 should probably be labeled smtp_port_t. At least this is what worked for me.

Comment 5 Nathanael Noblet 2011-09-13 02:01:10 UTC
Just assigning to Dan Williams who is likely more able to handle this.

Comment 6 Fedora End Of Life 2012-08-16 21:51:42 UTC
This message is a notice that Fedora 14 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 14. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained.  At this time, all open bugs with a Fedora 'version'
of '14' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this 
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen 
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we were unable to fix it before Fedora 14 reached end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" (top right of this page) and open it against that 
version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping