postfix.if 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. ## <summary>Postfix email server.</summary>
  2. ########################################
  3. ## <summary>
  4. ## Postfix stub interface. No access allowed.
  5. ## </summary>
  6. ## <param name="domain" unused="true">
  7. ## <summary>
  8. ## Domain allowed access.
  9. ## </summary>
  10. ## </param>
  11. #
  12. interface(`postfix_stub',`
  13. gen_require(`
  14. type postfix_master_t;
  15. ')
  16. ')
  17. #######################################
  18. ## <summary>
  19. ## The template to define a postfix domain.
  20. ## </summary>
  21. ## <param name="domain_prefix">
  22. ## <summary>
  23. ## Domain prefix to be used.
  24. ## </summary>
  25. ## </param>
  26. #
  27. template(`postfix_domain_template',`
  28. gen_require(`
  29. attribute postfix_domain;
  30. ')
  31. ########################################
  32. #
  33. # Declarations
  34. #
  35. type postfix_$1_t, postfix_domain;
  36. type postfix_$1_exec_t;
  37. domain_type(postfix_$1_t)
  38. domain_entry_file(postfix_$1_t, postfix_$1_exec_t)
  39. role system_r types postfix_$1_t;
  40. ########################################
  41. #
  42. # Policy
  43. #
  44. can_exec(postfix_$1_t, postfix_$1_exec_t)
  45. auth_use_nsswitch(postfix_$1_t)
  46. ')
  47. #######################################
  48. ## <summary>
  49. ## The template to define a postfix server domain.
  50. ## </summary>
  51. ## <param name="domain_prefix">
  52. ## <summary>
  53. ## Domain prefix to be used.
  54. ## </summary>
  55. ## </param>
  56. #
  57. template(`postfix_server_domain_template',`
  58. gen_require(`
  59. attribute postfix_server_domain, postfix_server_tmp_content;
  60. ')
  61. ########################################
  62. #
  63. # Declarations
  64. #
  65. postfix_domain_template($1)
  66. typeattribute postfix_$1_t postfix_server_domain;
  67. type postfix_$1_tmp_t, postfix_server_tmp_content;
  68. files_tmp_file(postfix_$1_tmp_t)
  69. ########################################
  70. #
  71. # Declarations
  72. #
  73. manage_dirs_pattern(postfix_$1_t, postfix_$1_tmp_t, postfix_$1_tmp_t)
  74. manage_files_pattern(postfix_$1_t, postfix_$1_tmp_t, postfix_$1_tmp_t)
  75. files_tmp_filetrans(postfix_$1_t, postfix_$1_tmp_t, { file dir })
  76. domtrans_pattern(postfix_master_t, postfix_$1_exec_t, postfix_$1_t)
  77. ')
  78. #######################################
  79. ## <summary>
  80. ## The template to define a postfix user domain.
  81. ## </summary>
  82. ## <param name="domain_prefix">
  83. ## <summary>
  84. ## Domain prefix to be used.
  85. ## </summary>
  86. ## </param>
  87. #
  88. template(`postfix_user_domain_template',`
  89. gen_require(`
  90. attribute postfix_user_domains, postfix_user_domtrans;
  91. ')
  92. ########################################
  93. #
  94. # Declarations
  95. #
  96. postfix_domain_template($1)
  97. typeattribute postfix_$1_t postfix_user_domains;
  98. ########################################
  99. #
  100. # Policy
  101. #
  102. allow postfix_$1_t self:capability dac_override;
  103. domtrans_pattern(postfix_user_domtrans, postfix_$1_exec_t, postfix_$1_t)
  104. domain_use_interactive_fds(postfix_$1_t)
  105. ')
  106. ########################################
  107. ## <summary>
  108. ## Read postfix configuration content.
  109. ## </summary>
  110. ## <param name="domain">
  111. ## <summary>
  112. ## Domain allowed access.
  113. ## </summary>
  114. ## </param>
  115. ## <rolecap/>
  116. #
  117. interface(`postfix_read_config',`
  118. gen_require(`
  119. type postfix_etc_t;
  120. ')
  121. files_search_etc($1)
  122. allow $1 postfix_etc_t:dir list_dir_perms;
  123. allow $1 postfix_etc_t:file read_file_perms;
  124. allow $1 postfix_etc_t:lnk_file read_lnk_file_perms;
  125. ')
  126. ########################################
  127. ## <summary>
  128. ## Create specified object in postfix
  129. ## etc directories with a type transition.
  130. ## </summary>
  131. ## <param name="domain">
  132. ## <summary>
  133. ## Domain allowed access.
  134. ## </summary>
  135. ## </param>
  136. ## <param name="private type">
  137. ## <summary>
  138. ## The type of the object to be created.
  139. ## </summary>
  140. ## </param>
  141. ## <param name="object">
  142. ## <summary>
  143. ## The object class of the object being created.
  144. ## </summary>
  145. ## </param>
  146. ## <param name="name" optional="true">
  147. ## <summary>
  148. ## The name of the object being created.
  149. ## </summary>
  150. ## </param>
  151. #
  152. interface(`postfix_config_filetrans',`
  153. gen_require(`
  154. type postfix_etc_t;
  155. ')
  156. filetrans_pattern($1, postfix_etc_t, $2, $3, $4)
  157. ')
  158. ########################################
  159. ## <summary>
  160. ## Do not audit attempts to read and
  161. ## write postfix local delivery
  162. ## TCP sockets.
  163. ## </summary>
  164. ## <param name="domain">
  165. ## <summary>
  166. ## Domain to not audit.
  167. ## </summary>
  168. ## </param>
  169. #
  170. interface(`postfix_dontaudit_rw_local_tcp_sockets',`
  171. gen_require(`
  172. type postfix_local_t;
  173. ')
  174. dontaudit $1 postfix_local_t:tcp_socket { read write };
  175. ')
  176. ########################################
  177. ## <summary>
  178. ## Read and write postfix local pipes.
  179. ## </summary>
  180. ## <param name="domain">
  181. ## <summary>
  182. ## Domain allowed access.
  183. ## </summary>
  184. ## </param>
  185. #
  186. interface(`postfix_rw_local_pipes',`
  187. gen_require(`
  188. type postfix_local_t;
  189. ')
  190. allow $1 postfix_local_t:fifo_file rw_fifo_file_perms;
  191. ')
  192. ########################################
  193. ## <summary>
  194. ## Read postfix local process state files.
  195. ## </summary>
  196. ## <param name="domain">
  197. ## <summary>
  198. ## Domain allowed access.
  199. ## </summary>
  200. ## </param>
  201. #
  202. interface(`postfix_read_local_state',`
  203. gen_require(`
  204. type postfix_local_t;
  205. ')
  206. kernel_search_proc($1)
  207. allow $1 postfix_local_t:dir list_dir_perms;
  208. allow $1 postfix_local_t:file read_file_perms;
  209. allow $1 postfix_local_t:lnk_file read_lnk_file_perms;
  210. ')
  211. ########################################
  212. ## <summary>
  213. ## Read and write inherited postfix master pipes.
  214. ## </summary>
  215. ## <param name="domain">
  216. ## <summary>
  217. ## Domain allowed access.
  218. ## </summary>
  219. ## </param>
  220. #
  221. interface(`postfix_rw_inherited_master_pipes',`
  222. gen_require(`
  223. type postfix_master_t;
  224. ')
  225. allow $1 postfix_master_t:fd use;
  226. allow $1 postfix_master_t:fifo_file { getattr write append lock ioctl read };
  227. ')
  228. ########################################
  229. ## <summary>
  230. ## Read postfix master process state files.
  231. ## </summary>
  232. ## <param name="domain">
  233. ## <summary>
  234. ## Domain allowed access.
  235. ## </summary>
  236. ## </param>
  237. #
  238. interface(`postfix_read_master_state',`
  239. gen_require(`
  240. type postfix_master_t;
  241. ')
  242. kernel_search_proc($1)
  243. allow $1 postfix_master_t:dir list_dir_perms;
  244. allow $1 postfix_master_t:file read_file_perms;
  245. allow $1 postfix_master_t:lnk_file read_lnk_file_perms;
  246. ')
  247. ########################################
  248. ## <summary>
  249. ## Use postfix master file descriptors.
  250. ## </summary>
  251. ## <param name="domain">
  252. ## <summary>
  253. ## Domain allowed access.
  254. ## </summary>
  255. ## </param>
  256. #
  257. interface(`postfix_use_fds_master',`
  258. gen_require(`
  259. type postfix_master_t;
  260. ')
  261. allow $1 postfix_master_t:fd use;
  262. ')
  263. ########################################
  264. ## <summary>
  265. ## Do not audit attempts to use
  266. ## postfix master process file
  267. ## file descriptors.
  268. ## </summary>
  269. ## <param name="domain">
  270. ## <summary>
  271. ## Domain to not audit.
  272. ## </summary>
  273. ## </param>
  274. #
  275. interface(`postfix_dontaudit_use_fds',`
  276. gen_require(`
  277. type postfix_master_t;
  278. ')
  279. dontaudit $1 postfix_master_t:fd use;
  280. ')
  281. ########################################
  282. ## <summary>
  283. ## Execute postfix_map in the postfix_map domain.
  284. ## </summary>
  285. ## <param name="domain">
  286. ## <summary>
  287. ## Domain allowed to transition.
  288. ## </summary>
  289. ## </param>
  290. #
  291. interface(`postfix_domtrans_map',`
  292. gen_require(`
  293. type postfix_map_t, postfix_map_exec_t;
  294. ')
  295. corecmd_search_bin($1)
  296. domtrans_pattern($1, postfix_map_exec_t, postfix_map_t)
  297. ')
  298. ########################################
  299. ## <summary>
  300. ## Execute postfix map in the postfix
  301. ## map domain, and allow the specified
  302. ## role the postfix_map domain.
  303. ## </summary>
  304. ## <param name="domain">
  305. ## <summary>
  306. ## Domain allowed to transition.
  307. ## </summary>
  308. ## </param>
  309. ## <param name="role">
  310. ## <summary>
  311. ## Role allowed access.
  312. ## </summary>
  313. ## </param>
  314. ## <rolecap/>
  315. #
  316. interface(`postfix_run_map',`
  317. gen_require(`
  318. attribute_role postfix_map_roles;
  319. ')
  320. postfix_domtrans_map($1)
  321. roleattribute $2 postfix_map_roles;
  322. ')
  323. ########################################
  324. ## <summary>
  325. ## Execute the master postfix program
  326. ## in the postfix_master domain.
  327. ## </summary>
  328. ## <param name="domain">
  329. ## <summary>
  330. ## Domain allowed to transition.
  331. ## </summary>
  332. ## </param>
  333. #
  334. interface(`postfix_domtrans_master',`
  335. gen_require(`
  336. type postfix_master_t, postfix_master_exec_t;
  337. ')
  338. corecmd_search_bin($1)
  339. domtrans_pattern($1, postfix_master_exec_t, postfix_master_t)
  340. ')
  341. ########################################
  342. ## <summary>
  343. ## Execute the master postfix program
  344. ## in the caller domain.
  345. ## </summary>
  346. ## <param name="domain">
  347. ## <summary>
  348. ## Domain allowed access.
  349. ## </summary>
  350. ## </param>
  351. #
  352. interface(`postfix_exec_master',`
  353. gen_require(`
  354. type postfix_master_exec_t;
  355. ')
  356. corecmd_search_bin($1)
  357. can_exec($1, postfix_master_exec_t)
  358. ')
  359. #######################################
  360. ## <summary>
  361. ## Connect to postfix master process
  362. ## using a unix domain stream socket.
  363. ## </summary>
  364. ## <param name="domain">
  365. ## <summary>
  366. ## Domain allowed access.
  367. ## </summary>
  368. ## </param>
  369. ## <rolecap/>
  370. #
  371. interface(`postfix_stream_connect_master',`
  372. gen_require(`
  373. type postfix_master_t, postfix_public_t;
  374. ')
  375. stream_connect_pattern($1, postfix_public_t, postfix_public_t, postfix_master_t)
  376. ')
  377. ########################################
  378. ## <summary>
  379. ## Read and write postfix master
  380. ## unnamed pipes. (Deprecated)
  381. ## </summary>
  382. ## <param name="domain">
  383. ## <summary>
  384. ## Domain allowed access.
  385. ## </summary>
  386. ## </param>
  387. #
  388. interface(`postfix_rw_master_pipes',`
  389. refpolicywarn(`$0($*) has been deprecated, use postfix_rw_inherited_master_pipes() instead.')
  390. postfix_rw_inherited_master_pipes($1)
  391. ')
  392. ########################################
  393. ## <summary>
  394. ## Execute the master postdrop in the
  395. ## postfix postdrop domain.
  396. ## </summary>
  397. ## <param name="domain">
  398. ## <summary>
  399. ## Domain allowed to transition.
  400. ## </summary>
  401. ## </param>
  402. #
  403. interface(`postfix_domtrans_postdrop',`
  404. gen_require(`
  405. type postfix_postdrop_t, postfix_postdrop_exec_t;
  406. ')
  407. corecmd_search_bin($1)
  408. domtrans_pattern($1, postfix_postdrop_exec_t, postfix_postdrop_t)
  409. ')
  410. ########################################
  411. ## <summary>
  412. ## Execute the master postqueue in the
  413. ## postfix postqueue domain.
  414. ## </summary>
  415. ## <param name="domain">
  416. ## <summary>
  417. ## Domain allowed to transition.
  418. ## </summary>
  419. ## </param>
  420. #
  421. interface(`postfix_domtrans_postqueue',`
  422. gen_require(`
  423. type postfix_postqueue_t, postfix_postqueue_exec_t;
  424. ')
  425. corecmd_search_bin($1)
  426. domtrans_pattern($1, postfix_postqueue_exec_t, postfix_postqueue_t)
  427. ')
  428. #######################################
  429. ## <summary>
  430. ## Execute the master postqueue in
  431. ## the caller domain. (Deprecated)
  432. ## </summary>
  433. ## <param name="domain">
  434. ## <summary>
  435. ## Domain allowed access.
  436. ## </summary>
  437. ## </param>
  438. #
  439. interface(`posftix_exec_postqueue',`
  440. refpolicywarn(`$0($*) has been deprecated.')
  441. postfix_exec_postqueue($1)
  442. ')
  443. #######################################
  444. ## <summary>
  445. ## Execute postfix postqueue in
  446. ## the caller domain.
  447. ## </summary>
  448. ## <param name="domain">
  449. ## <summary>
  450. ## Domain allowed access.
  451. ## </summary>
  452. ## </param>
  453. #
  454. interface(`postfix_exec_postqueue',`
  455. gen_require(`
  456. type postfix_postqueue_exec_t;
  457. ')
  458. corecmd_search_bin($1)
  459. can_exec($1, postfix_postqueue_exec_t)
  460. ')
  461. ########################################
  462. ## <summary>
  463. ## Create postfix private sock files.
  464. ## </summary>
  465. ## <param name="domain">
  466. ## <summary>
  467. ## Domain allowed access.
  468. ## </summary>
  469. ## </param>
  470. #
  471. interface(`postfix_create_private_sockets',`
  472. gen_require(`
  473. type postfix_private_t;
  474. ')
  475. create_sock_files_pattern($1, postfix_private_t, postfix_private_t)
  476. ')
  477. ########################################
  478. ## <summary>
  479. ## Create, read, write, and delete
  480. ## postfix private sock files.
  481. ## </summary>
  482. ## <param name="domain">
  483. ## <summary>
  484. ## Domain allowed access.
  485. ## </summary>
  486. ## </param>
  487. #
  488. interface(`postfix_manage_private_sockets',`
  489. gen_require(`
  490. type postfix_private_t;
  491. ')
  492. manage_sock_files_pattern($1, postfix_private_t, postfix_private_t)
  493. ')
  494. ########################################
  495. ## <summary>
  496. ## Execute the smtp postfix program
  497. ## in the postfix smtp domain.
  498. ## </summary>
  499. ## <param name="domain">
  500. ## <summary>
  501. ## Domain allowed to transition.
  502. ## </summary>
  503. ## </param>
  504. #
  505. interface(`postfix_domtrans_smtp',`
  506. gen_require(`
  507. type postfix_smtp_t, postfix_smtp_exec_t;
  508. ')
  509. corecmd_search_bin($1)
  510. domtrans_pattern($1, postfix_smtp_exec_t, postfix_smtp_t)
  511. ')
  512. ########################################
  513. ## <summary>
  514. ## Get attributes of all postfix mail
  515. ## spool files.
  516. ## </summary>
  517. ## <param name="domain">
  518. ## <summary>
  519. ## Domain allowed access.
  520. ## </summary>
  521. ## </param>
  522. #
  523. interface(`postfix_getattr_all_spool_files',`
  524. gen_require(`
  525. attribute postfix_spool_type;
  526. ')
  527. files_search_spool($1)
  528. getattr_files_pattern($1, postfix_spool_type, postfix_spool_type)
  529. ')
  530. ########################################
  531. ## <summary>
  532. ## Search postfix mail spool directories.
  533. ## </summary>
  534. ## <param name="domain">
  535. ## <summary>
  536. ## Domain allowed access.
  537. ## </summary>
  538. ## </param>
  539. #
  540. interface(`postfix_search_spool',`
  541. gen_require(`
  542. type postfix_spool_t;
  543. ')
  544. files_search_spool($1)
  545. allow $1 postfix_spool_t:dir search_dir_perms;
  546. ')
  547. ########################################
  548. ## <summary>
  549. ## List postfix mail spool directories.
  550. ## </summary>
  551. ## <param name="domain">
  552. ## <summary>
  553. ## Domain allowed access.
  554. ## </summary>
  555. ## </param>
  556. #
  557. interface(`postfix_list_spool',`
  558. gen_require(`
  559. type postfix_spool_t;
  560. ')
  561. files_search_spool($1)
  562. allow $1 postfix_spool_t:dir list_dir_perms;
  563. ')
  564. ########################################
  565. ## <summary>
  566. ## Read postfix mail spool files.
  567. ## </summary>
  568. ## <param name="domain">
  569. ## <summary>
  570. ## Domain allowed access.
  571. ## </summary>
  572. ## </param>
  573. #
  574. interface(`postfix_read_spool_files',`
  575. gen_require(`
  576. type postfix_spool_t;
  577. ')
  578. files_search_spool($1)
  579. read_files_pattern($1, postfix_spool_t, postfix_spool_t)
  580. ')
  581. ########################################
  582. ## <summary>
  583. ## Create, read, write, and delete
  584. ## postfix mail spool files.
  585. ## </summary>
  586. ## <param name="domain">
  587. ## <summary>
  588. ## Domain allowed access.
  589. ## </summary>
  590. ## </param>
  591. #
  592. interface(`postfix_manage_spool_files',`
  593. gen_require(`
  594. type postfix_spool_t;
  595. ')
  596. files_search_spool($1)
  597. manage_files_pattern($1, postfix_spool_t, postfix_spool_t)
  598. ')
  599. ########################################
  600. ## <summary>
  601. ## Execute postfix user mail programs
  602. ## in their respective domains.
  603. ## </summary>
  604. ## <param name="domain">
  605. ## <summary>
  606. ## Domain allowed access.
  607. ## </summary>
  608. ## </param>
  609. #
  610. interface(`postfix_domtrans_user_mail_handler',`
  611. gen_require(`
  612. attribute postfix_user_domtrans;
  613. ')
  614. typeattribute $1 postfix_user_domtrans;
  615. ')
  616. ########################################
  617. ## <summary>
  618. ## All of the rules required to
  619. ## administrate an postfix environment.
  620. ## </summary>
  621. ## <param name="domain">
  622. ## <summary>
  623. ## Domain allowed access.
  624. ## </summary>
  625. ## </param>
  626. ## <param name="role">
  627. ## <summary>
  628. ## Role allowed access.
  629. ## </summary>
  630. ## </param>
  631. ## <rolecap/>
  632. #
  633. interface(`postfix_admin',`
  634. gen_require(`
  635. attribute postfix_domain, postfix_spool_type, postfix_server_tmp_content;
  636. type postfix_initrc_exec_t, postfix_prng_t, postfix_etc_t;
  637. type postfix_data_t, postfix_var_run_t, postfix_public_t;
  638. type postfix_private_t, postfix_map_tmp_t, postfix_exec_t;
  639. type postfix_keytab_t;
  640. ')
  641. allow $1 postfix_domain:process { ptrace signal_perms };
  642. ps_process_pattern($1, postfix_domain)
  643. init_startstop_service($1, $2, postfix_t, postfix_initrc_exec_t)
  644. files_search_etc($1)
  645. admin_pattern($1, { postfix_prng_t postfix_etc_t postfix_exec_t postfix_keytab_t })
  646. files_search_spool($1)
  647. admin_pattern($1, { postfix_public_t postfix_private_t postfix_spool_type })
  648. files_search_var_lib($1)
  649. admin_pattern($1, postfix_data_t)
  650. files_search_pids($1)
  651. admin_pattern($1, postfix_var_run_t)
  652. files_search_tmp($1)
  653. admin_pattern($1, { postfix_server_tmp_content postfix_map_tmp_t })
  654. postfix_exec_master($1)
  655. postfix_exec_postqueue($1)
  656. postfix_stream_connect_master($1)
  657. postfix_run_map($1, $2)
  658. ')