Bug 1269227 - MongoDB logs are directed to incorrect location / incorrect selinux context
MongoDB logs are directed to incorrect location / incorrect selinux context
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Installer (Show other bugs)
6.1.2
Unspecified Linux
high Severity high (vote)
: Beta
: --
Assigned To: Justin Sherrill
Stephen Benjamin
: Triaged
: 1317479 (view as bug list)
Depends On:
Blocks: 1122832 1296845 1317008
  Show dependency treegraph
 
Reported: 2015-10-06 14:05 EDT by Craig Donnelly
Modified: 2017-08-21 03:56 EDT (History)
13 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-07-27 04:57:20 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2067593 None None None Never

  None (edit)
Description Craig Donnelly 2015-10-06 14:05:12 EDT
Description of problem:

Upon installation of Satellite 6.1.2, MongoDB logs are directed to /var/lib/mongodb which automatically assigned them the selinux context: mongod_var_lib_t.
This prevents the logs from being managed by logrotate even though Satellite provides configuration for them to be rotated.

Version-Release number of selected component (if applicable): Satellite 6.1.2

How reproducible: 100%

Steps to Reproduce:
1. Install Satellite 6.1.2.
2. Observe that mongodb logs are placed in /var/lib/mongodb

Actual results: Logs for MongoDB placed in /var/lib/mongodb, wrong selinux context applied. logrotate is setup to control logs in /var/log/mongodb. To have correct logrotate, customer would need to configure the logpath correctly in /etc/mongodb.conf.

They receive selinux context based on this rule: 
/var/lib/mongo.*  all files  system_u:object_r:mongod_var_lib_t:s0
Rule for the logs:
/var/log/mongo.*  all files  system_u:object_r:mongod_log_t:s0

Expected results: MongoDB logs should be pushed to /var/log/mongodb, as this would solve any selinux context issues and work with the current implementation of /etc/logrotate.d/mongodb.

Additional info:

Appears that the logpatch is configured via puppet during install:
  class { 'mongodb':
    logpath     => '/var/lib/mongodb/mongodb.log',
    dbpath      => '/var/lib/mongodb',
    pidfilepath => $mongodb_pidfilepath,
  } ~>
Comment 7 Justin Sherrill 2016-03-14 09:35:47 EDT
This should now be handled properly with the newer pulp puppet module.  I verified on an installation it was logging to the correct place and log rotate was occuring.
Comment 8 Justin Sherrill 2016-03-14 09:44:10 EDT
Also to note, the files in this new location appear to have the correct selinux context:

[root@sat-r220-04 ~]# ls -lZ /var/log/mongodb/
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log.2016-03-12T18-29-57
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log-20160313
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log.2016-03-13T07-14-03
Comment 9 Stephen Benjamin 2016-03-24 12:57:18 EDT
Logs go to right place, with right context:

[root@sat-r220-06 mongodb]# ls -lZ /var/log/mongodb/
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log.2016-03-24T16-12-24
Comment 12 errata-xmlrpc 2016-07-27 04:57:20 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1500
Comment 13 Michael Hrivnak 2017-01-04 16:31:46 EST
*** Bug 1317479 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.