1ec3d1a
###############################################################################
1ec3d1a
#
1ec3d1a
# Copyright (C) 2006, 2010 Red Hat, Inc. All Rights Reserved.
1ec3d1a
# Written by David Howells (dhowells@redhat.com)
1ec3d1a
#            Karl MacMillan (kmacmill@redhat.com)
1ec3d1a
#
1ec3d1a
# This program is free software; you can redistribute it and/or
1ec3d1a
# modify it under the terms of the GNU General Public License
1ec3d1a
# as published by the Free Software Foundation; either version
1ec3d1a
# 2 of the License, or (at your option) any later version.
1ec3d1a
#
1ec3d1a
###############################################################################
1ec3d1a
1ec3d1a
#
1ec3d1a
# This security policy governs access by the CacheFiles kernel module and
1ec3d1a
# userspace management daemon to the files and directories in the on-disk
1ec3d1a
# cache, on behalf of the processes accessing the cache through a network
1ec3d1a
# filesystem such as NFS
1ec3d1a
#
1ec3d1a
policy_module(cachefilesd, 1.0.17)
1ec3d1a
1ec3d1a
###############################################################################
1ec3d1a
#
1ec3d1a
# Declarations
1ec3d1a
#
1ec3d1a
1ec3d1a
#
1ec3d1a
# Files in the cache are created by the cachefiles module with security ID
1ec3d1a
# cachefiles_var_t
1ec3d1a
#
1ec3d1a
type cachefiles_var_t;
1ec3d1a
files_type(cachefiles_var_t)
1ec3d1a
1ec3d1a
#
1ec3d1a
# The /dev/cachefiles character device has security ID cachefiles_dev_t
1ec3d1a
#
1ec3d1a
type cachefiles_dev_t;
1ec3d1a
dev_node(cachefiles_dev_t)
1ec3d1a
1ec3d1a
#
1ec3d1a
# The cachefilesd daemon normally runs with security ID cachefilesd_t
1ec3d1a
#
1ec3d1a
type cachefilesd_t;
1ec3d1a
type cachefilesd_exec_t;
1ec3d1a
init_daemon_domain(cachefilesd_t, cachefilesd_exec_t)
1ec3d1a
1ec3d1a
#
1ec3d1a
# The cachefilesd daemon pid file context
1ec3d1a
#
1ec3d1a
type cachefilesd_var_run_t;
1ec3d1a
files_pid_file(cachefilesd_var_run_t)
1ec3d1a
1ec3d1a
#
1ec3d1a
# The CacheFiles kernel module causes processes accessing the cache files to do
1ec3d1a
# so acting as security ID cachefiles_kernel_t
1ec3d1a
#
1ec3d1a
type cachefiles_kernel_t;
1ec3d1a
domain_type(cachefiles_kernel_t)
1ec3d1a
domain_obj_id_change_exemption(cachefiles_kernel_t)
1ec3d1a
role system_r types cachefiles_kernel_t;
1ec3d1a
1ec3d1a
###############################################################################
1ec3d1a
#
1ec3d1a
# Permit RPM to deal with files in the cache
1ec3d1a
#
1ec3d1a
optional_policy(`
1ec3d1a
	rpm_use_script_fds(cachefilesd_t)
1ec3d1a
')
1ec3d1a
1ec3d1a
###############################################################################
1ec3d1a
#
1ec3d1a
# cachefilesd local policy
1ec3d1a
#
1ec3d1a
# These define what cachefilesd is permitted to do.  This doesn't include very
1ec3d1a
# much: startup stuff, logging, pid file, scanning the cache superstructure and
1ec3d1a
# deleting files from the cache.  It is not permitted to read/write files in
1ec3d1a
# the cache.
1ec3d1a
#
1ec3d1a
# Check in /usr/share/selinux/devel/include/ for macros to use instead of allow
1ec3d1a
# rules.
1ec3d1a
#
1ec3d1a
allow cachefilesd_t self:capability { setuid setgid sys_admin dac_override };
1ec3d1a
1ec3d1a
# Allow manipulation of pid file
1ec3d1a
allow cachefilesd_t cachefilesd_var_run_t:file create_file_perms;
1ec3d1a
manage_files_pattern(cachefilesd_t, cachefilesd_var_run_t, cachefilesd_var_run_t)
1ec3d1a
manage_dirs_pattern(cachefilesd_t, cachefilesd_var_run_t, cachefilesd_var_run_t)
1ec3d1a
files_pid_filetrans(cachefilesd_t, cachefilesd_var_run_t, file)
1ec3d1a
files_create_as_is_all_files(cachefilesd_t)
1ec3d1a
1ec3d1a
# Allow access to cachefiles device file
1ec3d1a
allow cachefilesd_t cachefiles_dev_t:chr_file rw_file_perms;
1ec3d1a
1ec3d1a
# Allow access to cache superstructure
1fe2554
manage_dirs_pattern(cachefilesd_t, cachefiles_var_t, cachefiles_var_t)
1fe2554
manage_files_pattern(cachefilesd_t, cachefiles_var_t, cachefiles_var_t)
1ec3d1a
1ec3d1a
# Permit statfs on the backing filesystem
1ec3d1a
fs_getattr_xattr_fs(cachefilesd_t)
1ec3d1a
1ec3d1a
# Basic access
1ec3d1a
logging_send_syslog_msg(cachefilesd_t)
1ec3d1a
init_dontaudit_use_script_ptys(cachefilesd_t)
1ec3d1a
term_dontaudit_use_generic_ptys(cachefilesd_t)
1ec3d1a
term_dontaudit_getattr_unallocated_ttys(cachefilesd_t)
1ec3d1a
1ec3d1a
###############################################################################
1ec3d1a
#
1ec3d1a
# When cachefilesd invokes the kernel module to begin caching, it has to tell
1ec3d1a
# the kernel module the security context in which it should act, and this
1ec3d1a
# policy has to approve that.
1ec3d1a
#
1ec3d1a
# There are two parts to this:
1ec3d1a
#
1ec3d1a
#   (1) the security context used by the module to access files in the cache,
1ec3d1a
#       as set by the 'secctx' command in /etc/cachefilesd.conf, and
1ec3d1a
#
1ec3d1a
allow cachefilesd_t cachefiles_kernel_t:kernel_service { use_as_override };
1ec3d1a
1ec3d1a
#
1ec3d1a
#   (2) the label that will be assigned to new files and directories created in
1ec3d1a
#       the cache by the module, which will be the same as the label on the
1ec3d1a
#       directory pointed to by the 'dir' command.
1ec3d1a
#
1ec3d1a
allow cachefilesd_t cachefiles_var_t:kernel_service { create_files_as };
1ec3d1a
1ec3d1a
###############################################################################
1ec3d1a
#
1ec3d1a
# cachefiles kernel module local policy
1ec3d1a
#
1ec3d1a
# This governs what the kernel module is allowed to do the contents of the
1ec3d1a
# cache.
1ec3d1a
#
1ec3d1a
allow cachefiles_kernel_t self:capability { dac_override dac_read_search };
1ec3d1a
1ec3d1a
manage_dirs_pattern(cachefiles_kernel_t, cachefiles_var_t, cachefiles_var_t)
1ec3d1a
manage_files_pattern(cachefiles_kernel_t, cachefiles_var_t, cachefiles_var_t)
1ec3d1a
1ec3d1a
fs_getattr_xattr_fs(cachefiles_kernel_t)
1ec3d1a
1ec3d1a
dev_search_sysfs(cachefiles_kernel_t)
1ec3d1a
1ec3d1a
init_sigchld_script(cachefiles_kernel_t)