Bug 512035

Summary: Selinux denial for httpd access to BackupPC log file.
Product: [Fedora] Fedora Reporter: Richard Shaw <hobbes1069>
Component: BackupPCAssignee: Johan Cwiklinski <fedora>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 11CC: dwalsh, fedora, jkubin, mgrepl, uckelman
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 3.1.0-5.fc10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-10-14 01:32:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard Shaw 2009-07-16 01:15:45 UTC
Description of problem:
SELinux is preventing access to the file "/var/log/BackupPC/UserEmailInfo.pl" for httpd. I got this alert after accessing the BackupPC status in Firefox.


Version-Release number of selected component (if applicable):
selinux-policy-3.6.12-62.fc11

How reproducible:
First time this has happened.


Steps to Reproduce:
1. Open BackupPC status on host during active backup.
2.
3.
  
Actual results:
Selinux denial

Expected results:
No denial alert.

Additional info:

Summary:

SELinux is preventing the perl5.10.0 from using potentially mislabeled files
/var/log/BackupPC/UserEmailInfo.pl (var_log_t).

Detailed Description:

SELinux has denied the perl5.10.0 access to potentially mislabeled files
/var/log/BackupPC/UserEmailInfo.pl. This means that SELinux will not allow httpd
to use these files. Many third party apps install html files in directories that
SELinux policy cannot predict. These directories have to be labeled with a file
context which httpd can access.

Allowing Access:

If you want to change the file context of /var/log/BackupPC/UserEmailInfo.pl so
that the httpd daemon can access it, you need to execute it using chcon -t
httpd_sys_content_t '/var/log/BackupPC/UserEmailInfo.pl'. You can look at the
httpd_selinux man page for additional information.

Additional Information:

Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:object_r:var_log_t:s0
Target Objects                /var/log/BackupPC/UserEmailInfo.pl [ file ]
Source                        perl5.10.0
Source Path                   /usr/bin/perl5.10.0
Port                          <Unknown>
Host                          hobbes.localdomain
Source RPM Packages           perl-5.10.0-69.fc11
Target RPM Packages           
Policy RPM                    selinux-policy-3.6.12-62.fc11
Selinux Enabled               True
Policy Type                   targeted
MLS Enabled                   True
Enforcing Mode                Enforcing
Plugin Name                   httpd_bad_labels
Host Name                     hobbes.localdomain
Platform                      Linux hobbes.localdomain 2.6.29.5-191.fc11.x86_64
                              #1 SMP Tue Jun 16 23:23:21 EDT 2009 x86_64 x86_64
Alert Count                   1
First Seen                    Wed 15 Jul 2009 08:07:21 PM CDT
Last Seen                     Wed 15 Jul 2009 08:07:21 PM CDT
Local ID                      12271f50-8744-48b7-81cf-bc8859e92fb2
Line Numbers                  

Raw Audit Messages            

node=hobbes.localdomain type=AVC msg=audit(1247706441.387:43097): avc:  denied  { read } for  pid=19513 comm="perl5.10.0" name="UserEmailInfo.pl" dev=dm-0 ino=117818 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=file

node=hobbes.localdomain type=SYSCALL msg=audit(1247706441.387:43097): arch=c000003e syscall=2 success=no exit=-13 a0=1747048 a1=0 a2=1b6 a3=7ff9f06198d0 items=0 ppid=2105 pid=19513 auid=4294967295 uid=48 gid=48 euid=494 suid=494 fsuid=494 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="perl5.10.0" exe="/usr/bin/perl5.10.0" subj=system_u:system_r:httpd_t:s0 key=(null)

Comment 1 Daniel Walsh 2009-07-19 15:50:03 UTC
Why is a perl script in a log directory?

You can change the context on this file to bin_t and it will work but the location of this file has got to change.

chcon -t bin_t /var/log/BackupPC/UserEmailInfo.pl

If you installed this from a package, what package?

Comment 2 Richard Shaw 2009-07-20 16:13:13 UTC
I'm not at home right now so I can't give you the exact package but I installed the official Fedora package...

Comment 3 Richard Shaw 2009-08-22 03:56:11 UTC
Is there some additional info I can provide? I also noticed the following files in /var/log/BackupPC:

-r--r--r--. 1 backuppc backuppc     4 2009-08-11 21:58 BackupPC.pid
srwxr-x---. 1 backuppc backuppc     0 2009-08-11 21:58 BackupPC.sock
-rw-r-----. 1 backuppc backuppc     0 2009-06-17 22:20 LOCK
-rw-r-----. 1 backuppc backuppc  2309 2009-08-21 22:00 LOG
-rw-r-----. 1 backuppc backuppc   636 2009-08-21 01:00 LOG.0.z
-rw-r-----. 1 backuppc backuppc   639 2009-08-11 01:00 LOG.10.z
-rw-r-----. 1 backuppc backuppc   637 2009-08-10 01:00 LOG.11.z
-rw-r-----. 1 backuppc backuppc   639 2009-08-09 01:00 LOG.12.z
-rw-r-----. 1 backuppc backuppc   741 2009-08-08 01:00 LOG.13.z
-rw-r-----. 1 backuppc backuppc   640 2009-08-20 01:00 LOG.1.z
-rw-r-----. 1 backuppc backuppc   638 2009-08-19 01:00 LOG.2.z
-rw-r-----. 1 backuppc backuppc   634 2009-08-18 01:00 LOG.3.z
-rw-r-----. 1 backuppc backuppc   635 2009-08-17 01:00 LOG.4.z
-rw-r-----. 1 backuppc backuppc   639 2009-08-16 01:00 LOG.5.z
-rw-r-----. 1 backuppc backuppc   654 2009-08-15 01:00 LOG.6.z
-rw-r-----. 1 backuppc backuppc   639 2009-08-14 01:00 LOG.7.z
-rw-r-----. 1 backuppc backuppc   642 2009-08-13 01:00 LOG.8.z
-rw-r-----. 1 backuppc backuppc   724 2009-08-12 01:00 LOG.9.z
-rw-r-----. 1 backuppc backuppc 12464 2009-08-21 22:00 status.pl
-rw-r-----. 1 backuppc backuppc 12464 2009-08-21 21:00 status.pl.old
-rw-r-----. 1 backuppc backuppc   196 2009-08-21 01:00 UserEmailInfo.pl

Comment 4 Daniel Walsh 2009-08-22 11:32:36 UTC
Why does apache want to look at this file?  Does it want to execute it?

Comment 5 Daniel Walsh 2009-08-22 11:35:12 UTC
You can label this directory httpd_sys_content_t and apache will be able to read it.

But this will cause other problems.  Or you can add a rule to allow apache to read the content using audit2allow.  But that will allow apache to read /var/log/messages.

Comment 6 Richard Shaw 2009-08-22 13:04:08 UTC
(In reply to comment #4)
> Why does apache want to look at this file?  Does it want to execute it?  

I don't have all the answers but I assume apache wants access to the files because the BackupPC interface is completely web driven. I assumed the fault was with why BackupPC wants those files in the /var/log directory.

Comment 7 Johan Cwiklinski 2009-09-18 12:55:07 UTC
BackupPC's web interface gives user possibility of reading several logs files, including UserEmailInfo.pl (it is indeed a simple log file).

That's why these should be labelled 'httpd_sys_content_t', you should use :
# semanage fcontext -a -t httpd_sys_content_t /var/log/BackupPC/UserEmailInfo.pl

Comment 8 Daniel Walsh 2009-09-18 13:11:39 UTC
The BackupPC.fc file should look like

/etc/BackupPC(/.*)?		gen_context(system_u:object_r:httpd_sys_content_t,s0)
/etc/BackupPC/pc(/.*)?		gen_context(system_u:object_r:httpd_sys_content_rw_t,s0)
/var/log/BackupPC(/.*)?		gen_context(system_u:object_r:httpd_sys_content_t,s0)


Which will set the default labeling for the directory and all subdirs to the correct label.  Then Restorecon will label the files correctly.

Comment 9 Johan Cwiklinski 2009-09-18 13:38:31 UTC
I've missed the regular expression in the .fc file embedded in the package :/

Thanks Daniel for the correct rules, I'll do some tests and push an update very soon.

Comment 10 Johan Cwiklinski 2009-09-18 13:40:04 UTC
*** Bug 456387 has been marked as a duplicate of this bug. ***

Comment 11 Fedora Update System 2009-09-18 21:25:47 UTC
BackupPC-3.1.0-6.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/BackupPC-3.1.0-6.fc11

Comment 12 Fedora Update System 2009-09-18 21:25:54 UTC
BackupPC-3.1.0-5.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/BackupPC-3.1.0-5.fc10

Comment 13 Fedora Update System 2009-09-24 05:06:14 UTC
BackupPC-3.1.0-5.fc10 has been pushed to the Fedora 10 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update BackupPC'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2009-9800

Comment 14 Fedora Update System 2009-09-24 05:21:25 UTC
BackupPC-3.1.0-6.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update BackupPC'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-9893

Comment 15 Fedora Update System 2009-10-14 01:32:54 UTC
BackupPC-3.1.0-6.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2009-10-14 01:54:34 UTC
BackupPC-3.1.0-5.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.