~ubuntu-branches/ubuntu/dapper/selinux-policy-default/dapper

« back to all changes in this revision

Viewing changes to macros/program/mta_macros.te

  • Committer: Bazaar Package Importer
  • Author(s): Russell Coker
  • Date: 2004-06-10 18:08:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040610180800-gagxr0cdovi7mv2i
Tags: upstream-1.12
ImportĀ upstreamĀ versionĀ 1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Macros for MTA domains.
 
2
#
 
3
 
 
4
#
 
5
# Author:   Russell Coker <russell@coker.com.au>
 
6
# Based on the work of: Stephen Smalley <sds@epoch.ncsc.mil>
 
7
#                       Timothy Fraser 
 
8
#
 
9
 
 
10
#
 
11
# mail_domain(domain_prefix)
 
12
#
 
13
# Define a derived domain for the sendmail program when executed by
 
14
# a user domain to send outgoing mail.  These domains are separate and
 
15
# independent of the domain used for the sendmail daemon process.
 
16
#
 
17
# The type declaration for the executable type for this program is
 
18
# provided separately in domains/program/mta.te. 
 
19
#
 
20
undefine(`mail_domain')
 
21
define(`mail_domain',`
 
22
# Derived domain based on the calling user domain and the program.
 
23
type $1_mail_t, domain, privlog, user_mail_domain;
 
24
 
 
25
ifdef(`sendmail.te', `
 
26
sendmail_user_domain($1)
 
27
')
 
28
 
 
29
can_exec($1_mail_t, sendmail_exec_t)
 
30
allow $1_mail_t sendmail_exec_t:lnk_file { getattr read };
 
31
 
 
32
# The user role is authorized for this domain.
 
33
role $1_r types $1_mail_t;
 
34
 
 
35
uses_shlib($1_mail_t)
 
36
can_network($1_mail_t)
 
37
can_ypbind($1_mail_t)
 
38
allow $1_mail_t self:unix_dgram_socket create_socket_perms;
 
39
allow $1_mail_t self:unix_stream_socket create_socket_perms;
 
40
 
 
41
read_locale($1_mail_t)
 
42
read_sysctl($1_mail_t)
 
43
allow $1_mail_t device_t:dir search;
 
44
allow $1_mail_t { var_t var_spool_t }:dir search;
 
45
allow $1_mail_t self:process { fork signal_perms setrlimit };
 
46
allow $1_mail_t sbin_t:dir search;
 
47
 
 
48
# It wants to check for nscd
 
49
dontaudit $1_mail_t var_run_t:dir search;
 
50
 
 
51
# Use capabilities
 
52
allow $1_mail_t self:capability { setuid setgid chown };
 
53
 
 
54
# Execute procmail.
 
55
can_exec($1_mail_t, bin_t)
 
56
ifdef(`procmail.te',`
 
57
can_exec($1_mail_t, procmail_exec_t)')
 
58
 
 
59
ifelse(`$1', `system', `
 
60
# Transition from a system domain to the derived domain.
 
61
domain_auto_trans(privmail, sendmail_exec_t, system_mail_t)
 
62
allow privmail sendmail_exec_t:lnk_file { getattr read };
 
63
 
 
64
# Read cron temporary files.
 
65
allow system_mail_t system_crond_tmp_t:file { read getattr ioctl };
 
66
allow mta_user_agent system_crond_tmp_t:file { read getattr };
 
67
allow system_mail_t initrc_devpts_t:chr_file { read write getattr };
 
68
 
 
69
', `
 
70
# For when the user wants to send mail via port 25 localhost
 
71
can_tcp_connect($1_t, mail_server_domain)
 
72
 
 
73
# Transition from the user domain to the derived domain.
 
74
domain_auto_trans($1_t, sendmail_exec_t, $1_mail_t)
 
75
allow $1_t sendmail_exec_t:lnk_file { getattr read };
 
76
 
 
77
# Read user temporary files.
 
78
allow $1_mail_t $1_tmp_t:file r_file_perms;
 
79
dontaudit $1_mail_t $1_tmp_t:file append;
 
80
ifdef(`postfix.te', `
 
81
# postfix seems to need write access if the file handle is opened read/write
 
82
allow $1_mail_t $1_tmp_t:file write;
 
83
')dnl end if postfix
 
84
 
 
85
allow mta_user_agent $1_tmp_t:file { read getattr };
 
86
 
 
87
allow mta_user_agent { $1_devpts_t $1_tty_device_t }:chr_file { getattr read write };
 
88
 
 
89
# Write to the user domain tty.
 
90
allow $1_mail_t { $1_tty_device_t $1_devpts_t devtty_t }:chr_file rw_file_perms;
 
91
 
 
92
# Inherit and use descriptors from gnome-pty-helper.
 
93
ifdef(`gnome-pty-helper.te', `allow $1_mail_t $1_gph_t:fd use;')
 
94
allow $1_mail_t { $1_t privfd }:fd use;
 
95
 
 
96
# Create dead.letter in user home directories.
 
97
file_type_auto_trans($1_mail_t, $1_home_dir_t, $1_home_t, file)
 
98
 
 
99
# if you do not want to allow dead.letter then use the following instead
 
100
#allow $1_mail_t { $1_home_dir_t $1_home_t }:dir r_dir_perms;
 
101
#allow $1_mail_t $1_home_t:file r_file_perms;
 
102
 
 
103
# for reading .forward - maybe we need a new type for it?
 
104
# also for delivering mail to maildir
 
105
file_type_auto_trans(mta_delivery_agent, $1_home_dir_t, $1_home_t)
 
106
')dnl end if system
 
107
 
 
108
allow $1_mail_t etc_t:file { getattr read };
 
109
ifdef(`qmail.te', `
 
110
allow $1_mail_t qmail_etc_t:dir search;
 
111
allow $1_mail_t qmail_etc_t:{ file lnk_file } read;
 
112
')dnl end if qmail
 
113
 
 
114
')