1
# Copyright 2016 Canonical Limited.
3
# This file is part of charm-helpers.
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.
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.
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/>.
17
from charmhelpers.contrib.hardening.audits.file import (
21
from charmhelpers.contrib.hardening import utils
25
"""Get OS hardening access audits.
27
:returns: dictionary of audits
30
settings = utils.get_settings('os')
32
# Remove write permissions from $PATH folders for all regular users.
33
# This prevents changing system-wide commands from normal users.
34
path_folders = {'/usr/local/sbin',
39
extra_user_paths = settings['environment']['extra_user_paths']
40
path_folders.update(extra_user_paths)
41
audits.append(ReadOnly(path_folders))
43
# Only allow the root user to have access to the shadow file.
44
audits.append(FilePermissionAudit('/etc/shadow', 'root', 'root', 0o0600))
46
if 'change_user' not in settings['security']['users_allow']:
47
# su should only be accessible to user and group root, unless it is
48
# expressly defined to allow users to change to root via the
49
# security_users_allow config option.
50
audits.append(FilePermissionAudit('/bin/su', 'root', 'root', 0o750))