1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
|
## <summary>Policy common to all email tranfer agents.</summary>
########################################
## <summary>
## MTA stub interface. No access allowed.
## </summary>
## <param name="domain" unused="true">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_stub',`
gen_require(`
type sendmail_exec_t;
')
')
#######################################
## <summary>
## Basic mail transfer agent domain template.
## </summary>
## <desc>
## <p>
## This template creates a derived domain which is
## a email transfer agent, which sends mail on
## behalf of the user.
## </p>
## <p>
## This is the basic types and rules, common
## to the system agent and user agents.
## </p>
## </desc>
## <param name="domain_prefix">
## <summary>
## The prefix of the domain (e.g., user
## is the prefix for user_t).
## </summary>
## </param>
#
template(`mta_base_mail_template',`
gen_require(`
attribute user_mail_domain;
type sendmail_exec_t;
')
##############################
#
# $1_mail_t declarations
#
type $1_mail_t, user_mail_domain;
application_domain($1_mail_t, sendmail_exec_t)
type $1_mail_tmp_t;
files_tmp_file($1_mail_tmp_t)
##############################
#
# $1_mail_t local policy
#
allow $1_mail_t self:capability { setuid setgid chown };
allow $1_mail_t self:process { signal_perms setrlimit };
allow $1_mail_t self:tcp_socket create_socket_perms;
# re-exec itself
can_exec($1_mail_t, sendmail_exec_t)
allow $1_mail_t sendmail_exec_t:lnk_file read_lnk_file_perms;
kernel_read_system_state($1_mail_t)
kernel_read_kernel_sysctls($1_mail_t)
corenet_all_recvfrom_unlabeled($1_mail_t)
corenet_all_recvfrom_netlabel($1_mail_t)
corenet_tcp_sendrecv_generic_if($1_mail_t)
corenet_tcp_sendrecv_generic_node($1_mail_t)
corenet_tcp_sendrecv_all_ports($1_mail_t)
corenet_tcp_connect_all_ports($1_mail_t)
corenet_tcp_connect_smtp_port($1_mail_t)
corenet_sendrecv_smtp_client_packets($1_mail_t)
corecmd_exec_bin($1_mail_t)
files_read_etc_files($1_mail_t)
files_search_spool($1_mail_t)
# It wants to check for nscd
files_dontaudit_search_pids($1_mail_t)
auth_use_nsswitch($1_mail_t)
init_dontaudit_rw_utmp($1_mail_t)
logging_send_syslog_msg($1_mail_t)
miscfiles_read_localization($1_mail_t)
kernel_read_system_state($1_mail_t)
optional_policy(`
exim_read_log($1_mail_t)
exim_append_log($1_mail_t)
exim_manage_spool_files($1_mail_t)
')
optional_policy(`
postfix_domtrans_user_mail_handler($1_mail_t)
# for postalias - role stops unpriv user from doing it
postfix_domtrans_master($1_mail_t)
')
optional_policy(`
procmail_exec($1_mail_t)
')
optional_policy(`
qmail_domtrans_inject($1_mail_t)
')
optional_policy(`
gen_require(`
type etc_mail_t, mail_spool_t, mqueue_spool_t;
')
manage_dirs_pattern($1_mail_t, $1_mail_tmp_t, $1_mail_tmp_t)
manage_files_pattern($1_mail_t, $1_mail_tmp_t, $1_mail_tmp_t)
files_tmp_filetrans($1_mail_t, $1_mail_tmp_t, { file dir })
allow $1_mail_t etc_mail_t:dir search_dir_perms;
# Write to /var/spool/mail and /var/spool/mqueue.
manage_files_pattern($1_mail_t, mail_spool_t, mail_spool_t)
manage_files_pattern($1_mail_t, mqueue_spool_t, mqueue_spool_t)
# Check available space.
fs_getattr_xattr_fs($1_mail_t)
files_read_etc_runtime_files($1_mail_t)
# Write to /var/log/sendmail.st
sendmail_manage_log($1_mail_t)
sendmail_create_log($1_mail_t)
')
optional_policy(`
uucp_manage_spool($1_mail_t)
')
')
########################################
## <summary>
## Role access for mta
## </summary>
## <param name="role">
## <summary>
## Role allowed access
## </summary>
## </param>
## <param name="domain">
## <summary>
## User domain for the role
## </summary>
## </param>
#
interface(`mta_role',`
gen_require(`
attribute mta_user_agent;
type user_mail_t, sendmail_exec_t;
')
role $1 types { user_mail_t mta_user_agent };
# Transition from the user domain to the derived domain.
domtrans_pattern($2, sendmail_exec_t, user_mail_t)
allow $2 sendmail_exec_t:lnk_file { getattr read };
allow mta_user_agent $2:fd use;
allow mta_user_agent $2:process sigchld;
allow mta_user_agent $2:fifo_file { read write };
')
########################################
## <summary>
## Make the specified domain usable for a mail server.
## </summary>
## <param name="type">
## <summary>
## Type to be used as a mail server domain.
## </summary>
## </param>
## <param name="entry_point">
## <summary>
## Type of the program to be used as an entry point to this domain.
## </summary>
## </param>
#
interface(`mta_mailserver',`
gen_require(`
attribute mailserver_domain;
')
init_daemon_domain($1, $2)
typeattribute $1 mailserver_domain;
')
########################################
## <summary>
## Make the specified type a MTA executable file.
## </summary>
## <param name="type">
## <summary>
## Type to be used as a mail client.
## </summary>
## </param>
#
interface(`mta_agent_executable',`
gen_require(`
attribute mta_exec_type;
')
typeattribute $1 mta_exec_type;
application_executable_file($1)
')
########################################
## <summary>
## Make the specified type by a system MTA.
## </summary>
## <param name="type">
## <summary>
## Type to be used as a mail client.
## </summary>
## </param>
#
interface(`mta_system_content',`
gen_require(`
attribute mailcontent_type;
')
typeattribute $1 mailcontent_type;
')
########################################
## <summary>
## Modified mailserver interface for
## sendmail daemon use.
## </summary>
## <desc>
## <p>
## A modified MTA mail server interface for
## the sendmail program. It's design does
## not fit well with policy, and using the
## regular interface causes a type_transition
## conflict if direct running of init scripts
## is enabled.
## </p>
## <p>
## This interface should most likely only be used
## by the sendmail policy.
## </p>
## </desc>
## <param name="domain">
## <summary>
## The type to be used for the mail server.
## </summary>
## </param>
#
interface(`mta_sendmail_mailserver',`
gen_require(`
attribute mailserver_domain;
type sendmail_exec_t;
')
init_system_domain($1, sendmail_exec_t)
typeattribute $1 mailserver_domain;
')
#######################################
## <summary>
## Make a type a mailserver type used
## for sending mail.
## </summary>
## <param name="domain">
## <summary>
## Mail server domain type used for sending mail.
## </summary>
## </param>
#
interface(`mta_mailserver_sender',`
gen_require(`
attribute mailserver_sender;
')
typeattribute $1 mailserver_sender;
')
#######################################
## <summary>
## Make a type a mailserver type used
## for delivering mail to local users.
## </summary>
## <param name="domain">
## <summary>
## Mail server domain type used for delivering mail.
## </summary>
## </param>
#
interface(`mta_mailserver_delivery',`
gen_require(`
attribute mailserver_delivery;
type mail_spool_t;
')
typeattribute $1 mailserver_delivery;
')
#######################################
## <summary>
## Make a type a mailserver type used
## for sending mail on behalf of local
## users to the local mail spool.
## </summary>
## <param name="domain">
## <summary>
## Mail server domain type used for sending local mail.
## </summary>
## </param>
#
interface(`mta_mailserver_user_agent',`
gen_require(`
attribute mta_user_agent;
')
typeattribute $1 mta_user_agent;
optional_policy(`
# apache should set close-on-exec
apache_dontaudit_rw_stream_sockets($1)
apache_dontaudit_rw_sys_script_stream_sockets($1)
')
')
########################################
## <summary>
## Send mail from the system.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`mta_send_mail',`
gen_require(`
attribute mta_user_agent;
type system_mail_t;
attribute mta_exec_type;
')
allow $1 mta_exec_type:lnk_file read_lnk_file_perms;
corecmd_read_bin_symlinks($1)
domtrans_pattern($1, mta_exec_type, system_mail_t)
allow mta_user_agent $1:fd use;
allow mta_user_agent $1:process sigchld;
allow mta_user_agent $1:fifo_file rw_fifo_file_perms;
')
########################################
## <summary>
## Execute send mail in a specified domain.
## </summary>
## <desc>
## <p>
## Execute send mail in a specified domain.
## </p>
## <p>
## No interprocess communication (signals, pipes,
## etc.) is provided by this interface since
## the domains are not owned by this module.
## </p>
## </desc>
## <param name="source_domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
## <param name="target_domain">
## <summary>
## Domain to transition to.
## </summary>
## </param>
#
interface(`mta_sendmail_domtrans',`
gen_require(`
type sendmail_exec_t;
')
files_search_usr($1)
corecmd_read_bin_symlinks($1)
domain_auto_trans($1, sendmail_exec_t, $2)
')
########################################
## <summary>
## Send system mail client a signal
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
#
interface(`mta_signal_system_mail',`
gen_require(`
type system_mail_t;
')
allow $1 system_mail_t:process signal;
')
########################################
## <summary>
## Execute sendmail in the caller domain.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_sendmail_exec',`
gen_require(`
type sendmail_exec_t;
')
can_exec($1, sendmail_exec_t)
')
########################################
## <summary>
## Read mail server configuration.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
## <rolecap/>
#
interface(`mta_read_config',`
gen_require(`
type etc_mail_t;
')
files_search_etc($1)
allow $1 etc_mail_t:dir list_dir_perms;
read_files_pattern($1, etc_mail_t, etc_mail_t)
read_lnk_files_pattern($1, etc_mail_t, etc_mail_t)
')
########################################
## <summary>
## write mail server configuration.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
## <rolecap/>
#
interface(`mta_write_config',`
gen_require(`
type etc_mail_t;
')
write_files_pattern($1, etc_mail_t, etc_mail_t)
')
########################################
## <summary>
## Read mail address aliases.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_read_aliases',`
gen_require(`
type etc_aliases_t;
')
files_search_etc($1)
allow $1 etc_aliases_t:file read_file_perms;
')
########################################
## <summary>
## Create, read, write, and delete mail address aliases.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_manage_aliases',`
gen_require(`
type etc_aliases_t;
')
files_search_etc($1)
manage_files_pattern($1, etc_aliases_t, etc_aliases_t)
manage_lnk_files_pattern($1, etc_aliases_t, etc_aliases_t)
')
########################################
## <summary>
## Type transition files created in /etc
## to the mail address aliases type.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_etc_filetrans_aliases',`
gen_require(`
type etc_aliases_t;
')
files_etc_filetrans($1, etc_aliases_t, file)
')
########################################
## <summary>
## Read and write mail aliases.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
## <rolecap/>
#
interface(`mta_rw_aliases',`
gen_require(`
type etc_aliases_t;
')
files_search_etc($1)
allow $1 etc_aliases_t:file { rw_file_perms setattr };
')
#######################################
## <summary>
## Do not audit attempts to read and write TCP
## sockets of mail delivery domains.
## </summary>
## <param name="domain">
## <summary>
## Domain to not audit.
## </summary>
## </param>
#
interface(`mta_dontaudit_rw_delivery_tcp_sockets',`
gen_require(`
attribute mailserver_delivery;
')
dontaudit $1 mailserver_delivery:tcp_socket { read write };
')
#######################################
## <summary>
## Do not audit attempts to read a symlink
## in the mail spool.
## </summary>
## <param name="domain">
## <summary>
## Domain to not audit.
## </summary>
## </param>
#
interface(`mta_dontaudit_read_spool_symlinks',`
gen_require(`
type mail_spool_t;
')
dontaudit $1 mail_spool_t:lnk_file read;
')
########################################
## <summary>
## Get the attributes of mail spool files.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_getattr_spool',`
gen_require(`
type mail_spool_t;
')
files_search_spool($1)
allow $1 mail_spool_t:dir list_dir_perms;
getattr_files_pattern($1, mail_spool_t, mail_spool_t)
read_lnk_files_pattern($1, mail_spool_t, mail_spool_t)
')
########################################
## <summary>
## Do not audit attempts to get the attributes
## of mail spool files.
## </summary>
## <param name="domain">
## <summary>
## Domain to not audit.
## </summary>
## </param>
#
interface(`mta_dontaudit_getattr_spool_files',`
gen_require(`
type mail_spool_t;
')
files_dontaudit_search_spool($1)
dontaudit $1 mail_spool_t:dir search_dir_perms;
dontaudit $1 mail_spool_t:lnk_file read;
dontaudit $1 mail_spool_t:file getattr;
')
#######################################
## <summary>
## Create private objects in the
## mail spool directory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
## <param name="private type">
## <summary>
## The type of the object to be created.
## </summary>
## </param>
## <param name="object">
## <summary>
## The object class of the object being created.
## </summary>
## </param>
#
interface(`mta_spool_filetrans',`
gen_require(`
type mail_spool_t;
')
files_search_spool($1)
filetrans_pattern($1, mail_spool_t, $2, $3)
')
########################################
## <summary>
## Read and write the mail spool.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_rw_spool',`
gen_require(`
type mail_spool_t;
')
files_search_spool($1)
allow $1 mail_spool_t:dir list_dir_perms;
allow $1 mail_spool_t:file setattr;
rw_files_pattern($1, mail_spool_t, mail_spool_t)
read_lnk_files_pattern($1, mail_spool_t, mail_spool_t)
')
#######################################
## <summary>
## Create, read, and write the mail spool.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_append_spool',`
gen_require(`
type mail_spool_t;
')
files_search_spool($1)
allow $1 mail_spool_t:dir list_dir_perms;
create_files_pattern($1, mail_spool_t, mail_spool_t)
write_files_pattern($1, mail_spool_t, mail_spool_t)
read_lnk_files_pattern($1, mail_spool_t, mail_spool_t)
')
#######################################
## <summary>
## Delete from the mail spool.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_delete_spool',`
gen_require(`
type mail_spool_t;
')
files_search_spool($1)
delete_files_pattern($1, mail_spool_t, mail_spool_t)
')
########################################
## <summary>
## Create, read, write, and delete mail spool files.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_manage_spool',`
gen_require(`
type mail_spool_t;
')
files_search_spool($1)
manage_dirs_pattern($1, mail_spool_t, mail_spool_t)
manage_files_pattern($1, mail_spool_t, mail_spool_t)
manage_lnk_files_pattern($1, mail_spool_t, mail_spool_t)
')
########################################
## <summary>
## Search mail queue dirs.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_search_queue',`
gen_require(`
type mqueue_spool_t;
')
files_search_spool($1)
allow $1 mqueue_spool_t:dir search_dir_perms;
')
#######################################
## <summary>
## List the mail queue.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_list_queue',`
gen_require(`
type mqueue_spool_t;
')
allow $1 mqueue_spool_t:dir list_dir_perms;
files_search_spool($1)
')
#######################################
## <summary>
## Read the mail queue.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_read_queue',`
gen_require(`
type mqueue_spool_t;
')
read_files_pattern($1, mqueue_spool_t, mqueue_spool_t)
files_search_spool($1)
')
#######################################
## <summary>
## Do not audit attempts to read and
## write the mail queue.
## </summary>
## <param name="domain">
## <summary>
## Domain to not audit.
## </summary>
## </param>
#
interface(`mta_dontaudit_rw_queue',`
gen_require(`
type mqueue_spool_t;
')
dontaudit $1 mqueue_spool_t:dir search_dir_perms;
dontaudit $1 mqueue_spool_t:file { getattr read write };
')
########################################
## <summary>
## Create, read, write, and delete
## mail queue files.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_manage_queue',`
gen_require(`
type mqueue_spool_t;
')
files_search_spool($1)
manage_dirs_pattern($1, mqueue_spool_t, mqueue_spool_t)
manage_files_pattern($1, mqueue_spool_t, mqueue_spool_t)
')
#######################################
## <summary>
## Read sendmail binary.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
# cjp: added for postfix
interface(`mta_read_sendmail_bin',`
gen_require(`
type sendmail_exec_t;
')
allow $1 sendmail_exec_t:file read_file_perms;
')
#######################################
## <summary>
## Read and write unix domain stream sockets
## of user mail domains.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`mta_rw_user_mail_stream_sockets',`
gen_require(`
attribute user_mail_domain;
')
allow $1 user_mail_domain:unix_stream_socket rw_socket_perms;
')
########################################
## <summary>
## Allow system_mail_t to access files of specified types
## </summary>
## <param name="private type">
## <summary>
## File type that system_mail_t can access
## </summary>
## </param>
#
interface(`system_mail_file_access',`
gen_require(`
type system_mail_t;
')
allow system_mail_t $1:file { read write };
')
|