~junaidali/charms/trusty/plumgrid-gateway/analyst_opsvm

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/hardening/host/checks/profile.py

  • Committer: bbaqar at plumgrid
  • Date: 2016-04-25 09:21:09 UTC
  • mfrom: (26.1.2 plumgrid-gateway)
  • Revision ID: bbaqar@plumgrid.com-20160425092109-kweey25bx97pmj80
Merge: Liberty/Mitaka support

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2016 Canonical Limited.
 
2
#
 
3
# This file is part of charm-helpers.
 
4
#
 
5
# charm-helpers is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU Lesser General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# charm-helpers is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU Lesser General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public License
 
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
from charmhelpers.contrib.hardening.audits.file import TemplatedFile
 
18
from charmhelpers.contrib.hardening.host import TEMPLATES_DIR
 
19
from charmhelpers.contrib.hardening import utils
 
20
 
 
21
 
 
22
def get_audits():
 
23
    """Get OS hardening profile audits.
 
24
 
 
25
    :returns:  dictionary of audits
 
26
    """
 
27
    audits = []
 
28
 
 
29
    settings = utils.get_settings('os')
 
30
 
 
31
    # If core dumps are not enabled, then don't allow core dumps to be
 
32
    # created as they may contain sensitive information.
 
33
    if not settings['security']['kernel_enable_core_dump']:
 
34
        audits.append(TemplatedFile('/etc/profile.d/pinerolo_profile.sh',
 
35
                                    ProfileContext(),
 
36
                                    template_dir=TEMPLATES_DIR,
 
37
                                    mode=0o0755, user='root', group='root'))
 
38
    return audits
 
39
 
 
40
 
 
41
class ProfileContext(object):
 
42
 
 
43
    def __call__(self):
 
44
        ctxt = {}
 
45
        return ctxt