apache.if 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365
  1. ## <summary>Various web servers.</summary>
  2. ########################################
  3. ## <summary>
  4. ## Create a set of derived types for
  5. ## httpd web content.
  6. ## </summary>
  7. ## <param name="prefix">
  8. ## <summary>
  9. ## The prefix to be used for deriving type names.
  10. ## </summary>
  11. ## </param>
  12. #
  13. template(`apache_content_template',`
  14. gen_require(`
  15. attribute httpdcontent, httpd_exec_scripts, httpd_script_exec_type;
  16. attribute httpd_script_domains, httpd_htaccess_type;
  17. attribute httpd_rw_content, httpd_ra_content;
  18. type httpd_t, httpd_suexec_t;
  19. ')
  20. ########################################
  21. #
  22. # Declarations
  23. #
  24. ## <desc>
  25. ## <p>
  26. ## Determine whether the script domain can
  27. ## modify public files used for public file
  28. ## transfer services. Directories/Files must
  29. ## be labeled public_content_rw_t.
  30. ## </p>
  31. ## </desc>
  32. gen_tunable(allow_httpd_$1_script_anon_write, false)
  33. type httpd_$1_content_t, httpdcontent; # customizable
  34. typealias httpd_$1_content_t alias httpd_$1_script_ro_t;
  35. files_type(httpd_$1_content_t)
  36. type httpd_$1_htaccess_t, httpd_htaccess_type; # customizable;
  37. files_type(httpd_$1_htaccess_t)
  38. type httpd_$1_script_t, httpd_script_domains;
  39. domain_type(httpd_$1_script_t)
  40. role system_r types httpd_$1_script_t;
  41. type httpd_$1_script_exec_t, httpd_script_exec_type; # customizable;
  42. corecmd_shell_entry_type(httpd_$1_script_t)
  43. domain_entry_file(httpd_$1_script_t, httpd_$1_script_exec_t)
  44. type httpd_$1_rw_content_t, httpdcontent, httpd_rw_content; # customizable
  45. typealias httpd_$1_rw_content_t alias { httpd_$1_script_rw_t httpd_$1_content_rw_t };
  46. files_type(httpd_$1_rw_content_t)
  47. type httpd_$1_ra_content_t, httpdcontent, httpd_ra_content; # customizable
  48. typealias httpd_$1_ra_content_t alias { httpd_$1_script_ra_t httpd_$1_content_ra_t };
  49. files_type(httpd_$1_ra_content_t)
  50. ########################################
  51. #
  52. # Policy
  53. #
  54. can_exec(httpd_$1_script_t, httpd_$1_script_exec_t)
  55. allow httpd_$1_script_t httpd_$1_ra_content_t:dir { list_dir_perms add_entry_dir_perms setattr_dir_perms };
  56. allow httpd_$1_script_t httpd_$1_ra_content_t:file { append_file_perms read_file_perms create_file_perms setattr_file_perms };
  57. allow httpd_$1_script_t httpd_$1_ra_content_t:lnk_file read_lnk_file_perms;
  58. allow httpd_$1_script_t { httpd_$1_content_t httpd_$1_script_exec_t }:dir list_dir_perms;
  59. allow httpd_$1_script_t httpd_$1_content_t:file read_file_perms;
  60. allow httpd_$1_script_t { httpd_$1_content_t httpd_$1_script_exec_t }:lnk_file read_lnk_file_perms;
  61. manage_dirs_pattern(httpd_$1_script_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  62. manage_files_pattern(httpd_$1_script_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  63. manage_lnk_files_pattern(httpd_$1_script_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  64. manage_fifo_files_pattern(httpd_$1_script_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  65. manage_sock_files_pattern(httpd_$1_script_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  66. files_tmp_filetrans(httpd_$1_script_t, httpd_$1_rw_content_t, { dir file lnk_file sock_file fifo_file })
  67. allow { httpd_t httpd_suexec_t } httpd_$1_content_t:dir list_dir_perms;
  68. allow { httpd_t httpd_suexec_t } { httpd_$1_content_t httpd_$1_htaccess_t }:file read_file_perms;
  69. allow { httpd_t httpd_suexec_t } httpd_$1_content_t:lnk_file read_lnk_file_perms;
  70. tunable_policy(`allow_httpd_$1_script_anon_write',`
  71. miscfiles_manage_public_files(httpd_$1_script_t)
  72. ')
  73. tunable_policy(`httpd_builtin_scripting',`
  74. manage_dirs_pattern(httpd_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  75. manage_files_pattern(httpd_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  76. manage_fifo_files_pattern(httpd_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  77. manage_lnk_files_pattern(httpd_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  78. manage_sock_files_pattern(httpd_t, httpd_$1_rw_content_t, httpd_$1_rw_content_t)
  79. allow httpd_t httpd_$1_ra_content_t:dir { list_dir_perms add_entry_dir_perms setattr_dir_perms };
  80. allow httpd_t httpd_$1_ra_content_t:file { append_file_perms read_file_perms create_file_perms setattr_file_perms };
  81. allow httpd_t httpd_$1_ra_content_t:lnk_file read_lnk_file_perms;
  82. ')
  83. tunable_policy(`httpd_builtin_scripting && httpd_tmp_exec',`
  84. can_exec(httpd_t, httpd_$1_rw_content_t)
  85. ')
  86. tunable_policy(`httpd_enable_cgi',`
  87. allow httpd_$1_script_t httpd_$1_script_exec_t:file entrypoint;
  88. domtrans_pattern({ httpd_t httpd_suexec_t httpd_exec_scripts }, httpd_$1_script_exec_t, httpd_$1_script_t)
  89. ')
  90. tunable_policy(`httpd_enable_cgi && httpd_tmp_exec',`
  91. can_exec(httpd_$1_script_t, httpd_$1_rw_content_t)
  92. ')
  93. tunable_policy(`httpd_enable_cgi && httpd_unified',`
  94. allow httpd_$1_script_t { httpd_$1_content_t httpd_$1_ra_content_t }:file entrypoint;
  95. allow httpd_$1_script_t { httpd_$1_content_t httpd_$1_ra_content_t }:dir manage_dir_perms;
  96. allow httpd_$1_script_t { httpd_$1_content_t httpd_$1_ra_content_t }:file manage_file_perms;
  97. ')
  98. tunable_policy(`httpd_enable_cgi && httpd_unified && httpd_builtin_scripting',`
  99. filetrans_pattern(httpd_t, httpd_$1_content_t, httpd_$1_rw_content_t, { file dir fifo_file lnk_file sock_file })
  100. ')
  101. ')
  102. ########################################
  103. ## <summary>
  104. ## Role access for apache.
  105. ## </summary>
  106. ## <param name="role">
  107. ## <summary>
  108. ## Role allowed access
  109. ## </summary>
  110. ## </param>
  111. ## <param name="domain">
  112. ## <summary>
  113. ## User domain for the role.
  114. ## </summary>
  115. ## </param>
  116. #
  117. interface(`apache_role',`
  118. gen_require(`
  119. attribute httpdcontent;
  120. type httpd_user_content_t, httpd_user_htaccess_t;
  121. type httpd_user_script_t, httpd_user_script_exec_t;
  122. type httpd_user_ra_content_t, httpd_user_rw_content_t;
  123. ')
  124. role $1 types httpd_user_script_t;
  125. allow $2 httpd_user_htaccess_t:file { manage_file_perms relabel_file_perms };
  126. allow $2 httpd_user_content_t:dir { manage_dir_perms relabel_dir_perms };
  127. allow $2 httpd_user_content_t:file { manage_file_perms relabel_file_perms };
  128. allow $2 httpd_user_content_t:lnk_file { manage_lnk_file_perms relabel_lnk_file_perms };
  129. allow $2 httpd_user_ra_content_t:dir { manage_dir_perms relabel_dir_perms };
  130. allow $2 httpd_user_ra_content_t:file { manage_file_perms relabel_file_perms };
  131. allow $2 httpd_user_ra_content_t:lnk_file { manage_lnk_file_perms relabel_lnk_file_perms };
  132. allow $2 httpd_user_rw_content_t:dir { manage_dir_perms relabel_dir_perms };
  133. allow $2 httpd_user_rw_content_t:file { manage_file_perms relabel_file_perms };
  134. allow $2 httpd_user_rw_content_t:lnk_file { manage_lnk_file_perms relabel_lnk_file_perms };
  135. allow $2 httpd_user_script_exec_t:dir { manage_dir_perms relabel_dir_perms };
  136. allow $2 httpd_user_script_exec_t:file { manage_file_perms relabel_file_perms };
  137. allow $2 httpd_user_script_exec_t:lnk_file { manage_lnk_file_perms relabel_lnk_file_perms };
  138. userdom_user_home_dir_filetrans($2, httpd_user_content_t, dir, "public_html")
  139. userdom_user_home_dir_filetrans($2, httpd_user_content_t, dir, "web")
  140. userdom_user_home_dir_filetrans($2, httpd_user_content_t, dir, "www")
  141. filetrans_pattern($2, httpd_user_content_t, httpd_user_htaccess_t, file, ".htaccess")
  142. filetrans_pattern($2, httpd_user_content_t, httpd_user_script_exec_t, dir, "cgi-bin")
  143. filetrans_pattern($2, httpd_user_content_t, httpd_user_ra_content_t, dir, "logs")
  144. tunable_policy(`httpd_enable_cgi',`
  145. domtrans_pattern($2, httpd_user_script_exec_t, httpd_user_script_t)
  146. ')
  147. tunable_policy(`httpd_enable_cgi && httpd_unified',`
  148. domtrans_pattern($2, httpdcontent, httpd_user_script_t)
  149. ')
  150. ')
  151. ########################################
  152. ## <summary>
  153. ## Read user httpd script executable files.
  154. ## </summary>
  155. ## <param name="domain">
  156. ## <summary>
  157. ## Domain allowed access.
  158. ## </summary>
  159. ## </param>
  160. #
  161. interface(`apache_read_user_scripts',`
  162. gen_require(`
  163. type httpd_user_script_exec_t;
  164. ')
  165. allow $1 httpd_user_script_exec_t:dir list_dir_perms;
  166. read_files_pattern($1, httpd_user_script_exec_t, httpd_user_script_exec_t)
  167. read_lnk_files_pattern($1, httpd_user_script_exec_t, httpd_user_script_exec_t)
  168. ')
  169. ########################################
  170. ## <summary>
  171. ## Read user httpd content.
  172. ## </summary>
  173. ## <param name="domain">
  174. ## <summary>
  175. ## Domain allowed access.
  176. ## </summary>
  177. ## </param>
  178. #
  179. interface(`apache_read_user_content',`
  180. gen_require(`
  181. type httpd_user_content_t;
  182. ')
  183. allow $1 httpd_user_content_t:dir list_dir_perms;
  184. read_files_pattern($1, httpd_user_content_t, httpd_user_content_t)
  185. read_lnk_files_pattern($1, httpd_user_content_t, httpd_user_content_t)
  186. ')
  187. ########################################
  188. ## <summary>
  189. ## Execute httpd with a domain transition.
  190. ## </summary>
  191. ## <param name="domain">
  192. ## <summary>
  193. ## Domain allowed to transition.
  194. ## </summary>
  195. ## </param>
  196. #
  197. interface(`apache_domtrans',`
  198. gen_require(`
  199. type httpd_t, httpd_exec_t;
  200. ')
  201. corecmd_search_bin($1)
  202. domtrans_pattern($1, httpd_exec_t, httpd_t)
  203. ')
  204. ########################################
  205. ## <summary>
  206. ## Execute httpd server in the httpd domain.
  207. ## </summary>
  208. ## <param name="domain">
  209. ## <summary>
  210. ## Domain allowed to transition.
  211. ## </summary>
  212. ## </param>
  213. #
  214. interface(`apache_initrc_domtrans',`
  215. gen_require(`
  216. type httpd_initrc_exec_t;
  217. ')
  218. init_labeled_script_domtrans($1, httpd_initrc_exec_t)
  219. ')
  220. #######################################
  221. ## <summary>
  222. ## Send generic signals to httpd.
  223. ## </summary>
  224. ## <param name="domain">
  225. ## <summary>
  226. ## Domain allowed access.
  227. ## </summary>
  228. ## </param>
  229. #
  230. interface(`apache_signal',`
  231. gen_require(`
  232. type httpd_t;
  233. ')
  234. allow $1 httpd_t:process signal;
  235. ')
  236. ########################################
  237. ## <summary>
  238. ## Send null signals to httpd.
  239. ## </summary>
  240. ## <param name="domain">
  241. ## <summary>
  242. ## Domain allowed access.
  243. ## </summary>
  244. ## </param>
  245. #
  246. interface(`apache_signull',`
  247. gen_require(`
  248. type httpd_t;
  249. ')
  250. allow $1 httpd_t:process signull;
  251. ')
  252. ########################################
  253. ## <summary>
  254. ## Send child terminated signals to httpd.
  255. ## </summary>
  256. ## <param name="domain">
  257. ## <summary>
  258. ## Domain allowed access.
  259. ## </summary>
  260. ## </param>
  261. #
  262. interface(`apache_sigchld',`
  263. gen_require(`
  264. type httpd_t;
  265. ')
  266. allow $1 httpd_t:process sigchld;
  267. ')
  268. ########################################
  269. ## <summary>
  270. ## Inherit and use file descriptors
  271. ## from httpd.
  272. ## </summary>
  273. ## <param name="domain">
  274. ## <summary>
  275. ## Domain allowed access.
  276. ## </summary>
  277. ## </param>
  278. #
  279. interface(`apache_use_fds',`
  280. gen_require(`
  281. type httpd_t;
  282. ')
  283. allow $1 httpd_t:fd use;
  284. ')
  285. ########################################
  286. ## <summary>
  287. ## Do not audit attempts to read and
  288. ## write httpd unnamed pipes.
  289. ## </summary>
  290. ## <param name="domain">
  291. ## <summary>
  292. ## Domain to not audit.
  293. ## </summary>
  294. ## </param>
  295. #
  296. interface(`apache_dontaudit_rw_fifo_file',`
  297. gen_require(`
  298. type httpd_t;
  299. ')
  300. dontaudit $1 httpd_t:fifo_file rw_fifo_file_perms;
  301. ')
  302. ########################################
  303. ## <summary>
  304. ## Do not audit attempts to read and
  305. ## write httpd unix domain stream sockets.
  306. ## </summary>
  307. ## <param name="domain">
  308. ## <summary>
  309. ## Domain to not audit.
  310. ## </summary>
  311. ## </param>
  312. #
  313. interface(`apache_dontaudit_rw_stream_sockets',`
  314. gen_require(`
  315. type httpd_t;
  316. ')
  317. dontaudit $1 httpd_t:unix_stream_socket { read write };
  318. ')
  319. ########################################
  320. ## <summary>
  321. ## Do not audit attempts to read and
  322. ## write httpd TCP sockets.
  323. ## </summary>
  324. ## <param name="domain">
  325. ## <summary>
  326. ## Domain to not audit.
  327. ## </summary>
  328. ## </param>
  329. #
  330. interface(`apache_dontaudit_rw_tcp_sockets',`
  331. gen_require(`
  332. type httpd_t;
  333. ')
  334. dontaudit $1 httpd_t:tcp_socket { read write };
  335. ')
  336. ########################################
  337. ## <summary>
  338. ## Read all appendable content
  339. ## </summary>
  340. ## <param name="domain">
  341. ## <summary>
  342. ## Domain allowed access.
  343. ## </summary>
  344. ## </param>
  345. #
  346. interface(`apache_read_all_ra_content',`
  347. gen_require(`
  348. attribute httpd_ra_content;
  349. ')
  350. read_files_pattern($1, httpd_ra_content, httpd_ra_content)
  351. read_lnk_files_pattern($1, httpd_ra_content, httpd_ra_content)
  352. ')
  353. ########################################
  354. ## <summary>
  355. ## Append to all appendable web content
  356. ## </summary>
  357. ## <param name="domain">
  358. ## <summary>
  359. ## Domain allowed access.
  360. ## </summary>
  361. ## </param>
  362. #
  363. interface(`apache_append_all_ra_content',`
  364. gen_require(`
  365. attribute httpd_ra_content;
  366. ')
  367. append_files_pattern($1, httpd_ra_content, httpd_ra_content)
  368. ')
  369. ########################################
  370. ## <summary>
  371. ## Read all read/write content
  372. ## </summary>
  373. ## <param name="domain">
  374. ## <summary>
  375. ## Domain allowed access.
  376. ## </summary>
  377. ## </param>
  378. #
  379. interface(`apache_read_all_rw_content',`
  380. gen_require(`
  381. attribute httpd_rw_content;
  382. ')
  383. read_files_pattern($1, httpd_rw_content, httpd_rw_content)
  384. read_lnk_files_pattern($1, httpd_rw_content, httpd_rw_content)
  385. ')
  386. ########################################
  387. ## <summary>
  388. ## Manage all read/write content
  389. ## </summary>
  390. ## <param name="domain">
  391. ## <summary>
  392. ## Domain allowed access.
  393. ## </summary>
  394. ## </param>
  395. #
  396. interface(`apache_manage_all_rw_content',`
  397. gen_require(`
  398. attribute httpd_rw_content;
  399. ')
  400. manage_dirs_pattern($1, httpd_rw_content, httpd_rw_content)
  401. manage_files_pattern($1, httpd_rw_content, httpd_rw_content)
  402. manage_lnk_files_pattern($1, httpd_rw_content, httpd_rw_content)
  403. ')
  404. ########################################
  405. ## <summary>
  406. ## Read all web content.
  407. ## </summary>
  408. ## <param name="domain">
  409. ## <summary>
  410. ## Domain allowed access.
  411. ## </summary>
  412. ## </param>
  413. #
  414. interface(`apache_read_all_content',`
  415. gen_require(`
  416. attribute httpdcontent, httpd_script_exec_type;
  417. ')
  418. read_files_pattern($1, httpdcontent, httpdcontent)
  419. read_lnk_files_pattern($1, httpdcontent, httpdcontent)
  420. read_files_pattern($1, httpd_script_exec_type, httpd_script_exec_type)
  421. read_lnk_files_pattern($1, httpd_script_exec_type, httpd_script_exec_type)
  422. ')
  423. #######################################
  424. ## <summary>
  425. ## Search all apache content.
  426. ## </summary>
  427. ## <param name="domain">
  428. ## <summary>
  429. ## Domain allowed access.
  430. ## </summary>
  431. ## </param>
  432. #
  433. interface(`apache_search_all_content',`
  434. gen_require(`
  435. attribute httpdcontent;
  436. ')
  437. allow $1 httpdcontent:dir search_dir_perms;
  438. ')
  439. ########################################
  440. ## <summary>
  441. ## Create, read, write, and delete
  442. ## all httpd content.
  443. ## </summary>
  444. ## <param name="domain">
  445. ## <summary>
  446. ## Domain allowed access.
  447. ## </summary>
  448. ## </param>
  449. ## <rolecap/>
  450. #
  451. interface(`apache_manage_all_content',`
  452. gen_require(`
  453. attribute httpdcontent, httpd_script_exec_type;
  454. ')
  455. manage_dirs_pattern($1, httpdcontent, httpdcontent)
  456. manage_files_pattern($1, httpdcontent, httpdcontent)
  457. manage_lnk_files_pattern($1, httpdcontent, httpdcontent)
  458. manage_dirs_pattern($1, httpd_script_exec_type, httpd_script_exec_type)
  459. manage_files_pattern($1, httpd_script_exec_type, httpd_script_exec_type)
  460. manage_lnk_files_pattern($1, httpd_script_exec_type, httpd_script_exec_type)
  461. ')
  462. ########################################
  463. ## <summary>
  464. ## Set attributes httpd cache directories.
  465. ## </summary>
  466. ## <param name="domain">
  467. ## <summary>
  468. ## Domain allowed access.
  469. ## </summary>
  470. ## </param>
  471. #
  472. interface(`apache_setattr_cache_dirs',`
  473. gen_require(`
  474. type httpd_cache_t;
  475. ')
  476. allow $1 httpd_cache_t:dir setattr_dir_perms;
  477. ')
  478. ########################################
  479. ## <summary>
  480. ## List httpd cache directories.
  481. ## </summary>
  482. ## <param name="domain">
  483. ## <summary>
  484. ## Domain allowed access.
  485. ## </summary>
  486. ## </param>
  487. #
  488. interface(`apache_list_cache',`
  489. gen_require(`
  490. type httpd_cache_t;
  491. ')
  492. list_dirs_pattern($1, httpd_cache_t, httpd_cache_t)
  493. ')
  494. ########################################
  495. ## <summary>
  496. ## Read and write httpd cache files.
  497. ## </summary>
  498. ## <param name="domain">
  499. ## <summary>
  500. ## Domain allowed access.
  501. ## </summary>
  502. ## </param>
  503. #
  504. interface(`apache_rw_cache_files',`
  505. gen_require(`
  506. type httpd_cache_t;
  507. ')
  508. allow $1 httpd_cache_t:file rw_file_perms;
  509. ')
  510. ########################################
  511. ## <summary>
  512. ## Delete httpd cache directories.
  513. ## </summary>
  514. ## <param name="domain">
  515. ## <summary>
  516. ## Domain allowed access.
  517. ## </summary>
  518. ## </param>
  519. #
  520. interface(`apache_delete_cache_dirs',`
  521. gen_require(`
  522. type httpd_cache_t;
  523. ')
  524. delete_dirs_pattern($1, httpd_cache_t, httpd_cache_t)
  525. ')
  526. ########################################
  527. ## <summary>
  528. ## Delete httpd cache files.
  529. ## </summary>
  530. ## <param name="domain">
  531. ## <summary>
  532. ## Domain allowed access.
  533. ## </summary>
  534. ## </param>
  535. #
  536. interface(`apache_delete_cache_files',`
  537. gen_require(`
  538. type httpd_cache_t;
  539. ')
  540. delete_files_pattern($1, httpd_cache_t, httpd_cache_t)
  541. ')
  542. ########################################
  543. ## <summary>
  544. ## Read httpd configuration files.
  545. ## </summary>
  546. ## <param name="domain">
  547. ## <summary>
  548. ## Domain allowed access.
  549. ## </summary>
  550. ## </param>
  551. ## <rolecap/>
  552. #
  553. interface(`apache_read_config',`
  554. gen_require(`
  555. type httpd_config_t;
  556. ')
  557. files_search_etc($1)
  558. allow $1 httpd_config_t:dir list_dir_perms;
  559. read_files_pattern($1, httpd_config_t, httpd_config_t)
  560. read_lnk_files_pattern($1, httpd_config_t, httpd_config_t)
  561. ')
  562. ########################################
  563. ## <summary>
  564. ## Search httpd configuration directories.
  565. ## </summary>
  566. ## <param name="domain">
  567. ## <summary>
  568. ## Domain allowed access.
  569. ## </summary>
  570. ## </param>
  571. #
  572. interface(`apache_search_config',`
  573. gen_require(`
  574. type httpd_config_t;
  575. ')
  576. files_search_etc($1)
  577. allow $1 httpd_config_t:dir search_dir_perms;
  578. ')
  579. ########################################
  580. ## <summary>
  581. ## Create, read, write, and delete
  582. ## httpd configuration files.
  583. ## </summary>
  584. ## <param name="domain">
  585. ## <summary>
  586. ## Domain allowed access.
  587. ## </summary>
  588. ## </param>
  589. #
  590. interface(`apache_manage_config',`
  591. gen_require(`
  592. type httpd_config_t;
  593. ')
  594. files_search_etc($1)
  595. manage_dirs_pattern($1, httpd_config_t, httpd_config_t)
  596. manage_files_pattern($1, httpd_config_t, httpd_config_t)
  597. read_lnk_files_pattern($1, httpd_config_t, httpd_config_t)
  598. ')
  599. ########################################
  600. ## <summary>
  601. ## Execute the Apache helper program
  602. ## with a domain transition.
  603. ## </summary>
  604. ## <param name="domain">
  605. ## <summary>
  606. ## Domain allowed access.
  607. ## </summary>
  608. ## </param>
  609. #
  610. interface(`apache_domtrans_helper',`
  611. gen_require(`
  612. type httpd_helper_t, httpd_helper_exec_t;
  613. ')
  614. corecmd_search_bin($1)
  615. domtrans_pattern($1, httpd_helper_exec_t, httpd_helper_t)
  616. ')
  617. ########################################
  618. ## <summary>
  619. ## Execute the Apache helper program with
  620. ## a domain transition, and allow the
  621. ## specified role the Apache helper domain.
  622. ## </summary>
  623. ## <param name="domain">
  624. ## <summary>
  625. ## Domain allowed to transition.
  626. ## </summary>
  627. ## </param>
  628. ## <param name="role">
  629. ## <summary>
  630. ## Role allowed access.
  631. ## </summary>
  632. ## </param>
  633. ## <rolecap/>
  634. #
  635. interface(`apache_run_helper',`
  636. gen_require(`
  637. attribute_role httpd_helper_roles;
  638. ')
  639. apache_domtrans_helper($1)
  640. roleattribute $2 httpd_helper_roles;
  641. ')
  642. ########################################
  643. ## <summary>
  644. ## Read httpd log files.
  645. ## </summary>
  646. ## <param name="domain">
  647. ## <summary>
  648. ## Domain allowed access.
  649. ## </summary>
  650. ## </param>
  651. ## <rolecap/>
  652. #
  653. interface(`apache_read_log',`
  654. gen_require(`
  655. type httpd_log_t;
  656. ')
  657. logging_search_logs($1)
  658. allow $1 httpd_log_t:dir list_dir_perms;
  659. read_files_pattern($1, httpd_log_t, httpd_log_t)
  660. read_lnk_files_pattern($1, httpd_log_t, httpd_log_t)
  661. ')
  662. ########################################
  663. ## <summary>
  664. ## Append httpd log files.
  665. ## </summary>
  666. ## <param name="domain">
  667. ## <summary>
  668. ## Domain allowed access.
  669. ## </summary>
  670. ## </param>
  671. #
  672. interface(`apache_append_log',`
  673. gen_require(`
  674. type httpd_log_t;
  675. ')
  676. logging_search_logs($1)
  677. allow $1 httpd_log_t:dir list_dir_perms;
  678. append_files_pattern($1, httpd_log_t, httpd_log_t)
  679. ')
  680. ########################################
  681. ## <summary>
  682. ## Do not audit attempts to append
  683. ## httpd log files.
  684. ## </summary>
  685. ## <param name="domain">
  686. ## <summary>
  687. ## Domain to not audit.
  688. ## </summary>
  689. ## </param>
  690. #
  691. interface(`apache_dontaudit_append_log',`
  692. gen_require(`
  693. type httpd_log_t;
  694. ')
  695. dontaudit $1 httpd_log_t:file append_file_perms;
  696. ')
  697. ########################################
  698. ## <summary>
  699. ## Create, read, write, and delete
  700. ## httpd log files.
  701. ## </summary>
  702. ## <param name="domain">
  703. ## <summary>
  704. ## Domain allowed access.
  705. ## </summary>
  706. ## </param>
  707. #
  708. interface(`apache_manage_log',`
  709. gen_require(`
  710. type httpd_log_t;
  711. ')
  712. logging_search_logs($1)
  713. manage_dirs_pattern($1, httpd_log_t, httpd_log_t)
  714. manage_files_pattern($1, httpd_log_t, httpd_log_t)
  715. read_lnk_files_pattern($1, httpd_log_t, httpd_log_t)
  716. ')
  717. #######################################
  718. ## <summary>
  719. ## Write apache log files.
  720. ## </summary>
  721. ## <param name="domain">
  722. ## <summary>
  723. ## Domain allowed access.
  724. ## </summary>
  725. ## </param>
  726. #
  727. interface(`apache_write_log',`
  728. gen_require(`
  729. type httpd_log_t;
  730. ')
  731. logging_search_logs($1)
  732. write_files_pattern($1, httpd_log_t, httpd_log_t)
  733. ')
  734. ########################################
  735. ## <summary>
  736. ## Do not audit attempts to search
  737. ## httpd module directories.
  738. ## </summary>
  739. ## <param name="domain">
  740. ## <summary>
  741. ## Domain to not audit.
  742. ## </summary>
  743. ## </param>
  744. #
  745. interface(`apache_dontaudit_search_modules',`
  746. gen_require(`
  747. type httpd_modules_t;
  748. ')
  749. dontaudit $1 httpd_modules_t:dir search_dir_perms;
  750. ')
  751. ########################################
  752. ## <summary>
  753. ## List httpd module directories.
  754. ## </summary>
  755. ## <param name="domain">
  756. ## <summary>
  757. ## Domain allowed access.
  758. ## </summary>
  759. ## </param>
  760. #
  761. interface(`apache_list_modules',`
  762. gen_require(`
  763. type httpd_modules_t;
  764. ')
  765. allow $1 httpd_modules_t:dir list_dir_perms;
  766. ')
  767. ########################################
  768. ## <summary>
  769. ## Execute httpd module files.
  770. ## </summary>
  771. ## <param name="domain">
  772. ## <summary>
  773. ## Domain allowed access.
  774. ## </summary>
  775. ## </param>
  776. #
  777. interface(`apache_exec_modules',`
  778. gen_require(`
  779. type httpd_modules_t;
  780. ')
  781. allow $1 httpd_modules_t:dir list_dir_perms;
  782. allow $1 httpd_modules_t:lnk_file read_lnk_file_perms;
  783. can_exec($1, httpd_modules_t)
  784. ')
  785. ########################################
  786. ## <summary>
  787. ## Read httpd module files.
  788. ## </summary>
  789. ## <param name="domain">
  790. ## <summary>
  791. ## Domain allowed access.
  792. ## </summary>
  793. ## </param>
  794. #
  795. interface(`apache_read_module_files',`
  796. gen_require(`
  797. type httpd_modules_t;
  798. ')
  799. libs_search_lib($1)
  800. read_files_pattern($1, httpd_modules_t, httpd_modules_t)
  801. ')
  802. ########################################
  803. ## <summary>
  804. ## Execute a domain transition to
  805. ## run httpd_rotatelogs.
  806. ## </summary>
  807. ## <param name="domain">
  808. ## <summary>
  809. ## Domain allowed to transition.
  810. ## </summary>
  811. ## </param>
  812. #
  813. interface(`apache_domtrans_rotatelogs',`
  814. gen_require(`
  815. type httpd_rotatelogs_t, httpd_rotatelogs_exec_t;
  816. ')
  817. corecmd_search_bin($1)
  818. domtrans_pattern($1, httpd_rotatelogs_exec_t, httpd_rotatelogs_t)
  819. ')
  820. ########################################
  821. ## <summary>
  822. ## List httpd system content directories.
  823. ## </summary>
  824. ## <param name="domain">
  825. ## <summary>
  826. ## Domain allowed access.
  827. ## </summary>
  828. ## </param>
  829. #
  830. interface(`apache_list_sys_content',`
  831. gen_require(`
  832. type httpd_sys_content_t;
  833. ')
  834. list_dirs_pattern($1, httpd_sys_content_t, httpd_sys_content_t)
  835. files_search_var($1)
  836. ')
  837. ########################################
  838. ## <summary>
  839. ## Create, read, write, and delete
  840. ## httpd system content files.
  841. ## </summary>
  842. ## <param name="domain">
  843. ## <summary>
  844. ## Domain allowed access.
  845. ## </summary>
  846. ## </param>
  847. ## <rolecap/>
  848. #
  849. interface(`apache_manage_sys_content',`
  850. gen_require(`
  851. type httpd_sys_content_t;
  852. ')
  853. files_search_var($1)
  854. manage_dirs_pattern($1, httpd_sys_content_t, httpd_sys_content_t)
  855. manage_files_pattern($1, httpd_sys_content_t, httpd_sys_content_t)
  856. manage_lnk_files_pattern($1, httpd_sys_content_t, httpd_sys_content_t)
  857. ')
  858. ########################################
  859. ## <summary>
  860. ## Create, read, write, and delete
  861. ## httpd system rw content.
  862. ## </summary>
  863. ## <param name="domain">
  864. ## <summary>
  865. ## Domain allowed access.
  866. ## </summary>
  867. ## </param>
  868. #
  869. interface(`apache_manage_sys_rw_content',`
  870. gen_require(`
  871. type httpd_sys_rw_content_t;
  872. ')
  873. apache_search_sys_content($1)
  874. manage_dirs_pattern($1, httpd_sys_rw_content_t, httpd_sys_rw_content_t)
  875. manage_files_pattern($1,httpd_sys_rw_content_t, httpd_sys_rw_content_t)
  876. manage_lnk_files_pattern($1, httpd_sys_rw_content_t, httpd_sys_rw_content_t)
  877. ')
  878. ########################################
  879. ## <summary>
  880. ## Execute all httpd scripts in the
  881. ## system script domain.
  882. ## </summary>
  883. ## <param name="domain">
  884. ## <summary>
  885. ## Domain allowed to transition.
  886. ## </summary>
  887. ## </param>
  888. #
  889. interface(`apache_domtrans_sys_script',`
  890. gen_require(`
  891. attribute httpdcontent;
  892. type httpd_sys_script_t;
  893. ')
  894. tunable_policy(`httpd_enable_cgi && httpd_unified',`
  895. domtrans_pattern($1, httpdcontent, httpd_sys_script_t)
  896. ')
  897. ')
  898. ########################################
  899. ## <summary>
  900. ## Do not audit attempts to read and
  901. ## write httpd system script unix
  902. ## domain stream sockets.
  903. ## </summary>
  904. ## <param name="domain">
  905. ## <summary>
  906. ## Domain to not audit.
  907. ## </summary>
  908. ## </param>
  909. #
  910. interface(`apache_dontaudit_rw_sys_script_stream_sockets',`
  911. gen_require(`
  912. type httpd_sys_script_t;
  913. ')
  914. dontaudit $1 httpd_sys_script_t:unix_stream_socket { read write };
  915. ')
  916. ########################################
  917. ## <summary>
  918. ## Execute all user scripts in the user
  919. ## script domain.
  920. ## </summary>
  921. ## <param name="domain">
  922. ## <summary>
  923. ## Domain allowed to transition.
  924. ## </summary>
  925. ## </param>
  926. #
  927. interface(`apache_domtrans_all_scripts',`
  928. gen_require(`
  929. attribute httpd_exec_scripts;
  930. ')
  931. typeattribute $1 httpd_exec_scripts;
  932. ')
  933. ########################################
  934. ## <summary>
  935. ## Execute all user scripts in the user
  936. ## script domain. Add user script domains
  937. ## to the specified role.
  938. ## </summary>
  939. ## <param name="domain">
  940. ## <summary>
  941. ## Domain allowed to transition.
  942. ## </summary>
  943. ## </param>
  944. ## <param name="role">
  945. ## <summary>
  946. ## Role allowed access.
  947. ## </summary>
  948. ## </param>
  949. #
  950. interface(`apache_run_all_scripts',`
  951. gen_require(`
  952. attribute httpd_exec_scripts, httpd_script_domains;
  953. ')
  954. role $2 types httpd_script_domains;
  955. apache_domtrans_all_scripts($1)
  956. ')
  957. ########################################
  958. ## <summary>
  959. ## Read httpd squirrelmail data files.
  960. ## </summary>
  961. ## <param name="domain">
  962. ## <summary>
  963. ## Domain allowed access.
  964. ## </summary>
  965. ## </param>
  966. #
  967. interface(`apache_read_squirrelmail_data',`
  968. gen_require(`
  969. type httpd_squirrelmail_t;
  970. ')
  971. allow $1 httpd_squirrelmail_t:file read_file_perms;
  972. ')
  973. ########################################
  974. ## <summary>
  975. ## Append httpd squirrelmail data files.
  976. ## </summary>
  977. ## <param name="domain">
  978. ## <summary>
  979. ## Domain allowed access.
  980. ## </summary>
  981. ## </param>
  982. #
  983. interface(`apache_append_squirrelmail_data',`
  984. gen_require(`
  985. type httpd_squirrelmail_t;
  986. ')
  987. allow $1 httpd_squirrelmail_t:file append_file_perms;
  988. ')
  989. ########################################
  990. ## <summary>
  991. ## Search httpd system content.
  992. ## </summary>
  993. ## <param name="domain">
  994. ## <summary>
  995. ## Domain allowed access.
  996. ## </summary>
  997. ## </param>
  998. #
  999. interface(`apache_search_sys_content',`
  1000. gen_require(`
  1001. type httpd_sys_content_t;
  1002. ')
  1003. files_search_var($1)
  1004. allow $1 httpd_sys_content_t:dir search_dir_perms;
  1005. ')
  1006. ########################################
  1007. ## <summary>
  1008. ## Read httpd system content.
  1009. ## </summary>
  1010. ## <param name="domain">
  1011. ## <summary>
  1012. ## Domain allowed access.
  1013. ## </summary>
  1014. ## </param>
  1015. #
  1016. interface(`apache_read_sys_content',`
  1017. gen_require(`
  1018. type httpd_sys_content_t;
  1019. ')
  1020. allow $1 httpd_sys_content_t:dir list_dir_perms;
  1021. read_files_pattern($1, httpd_sys_content_t, httpd_sys_content_t)
  1022. read_lnk_files_pattern($1, httpd_sys_content_t, httpd_sys_content_t)
  1023. ')
  1024. ########################################
  1025. ## <summary>
  1026. ## Search httpd system CGI directories.
  1027. ## </summary>
  1028. ## <param name="domain">
  1029. ## <summary>
  1030. ## Domain allowed access.
  1031. ## </summary>
  1032. ## </param>
  1033. #
  1034. interface(`apache_search_sys_scripts',`
  1035. gen_require(`
  1036. type httpd_sys_content_t, httpd_sys_script_exec_t;
  1037. ')
  1038. search_dirs_pattern($1, httpd_sys_content_t, httpd_sys_script_exec_t)
  1039. ')
  1040. ########################################
  1041. ## <summary>
  1042. ## Create, read, write, and delete all
  1043. ## user httpd content.
  1044. ## </summary>
  1045. ## <param name="domain">
  1046. ## <summary>
  1047. ## Domain allowed access.
  1048. ## </summary>
  1049. ## </param>
  1050. ## <rolecap/>
  1051. #
  1052. interface(`apache_manage_all_user_content',`
  1053. gen_require(`
  1054. type httpd_user_content_t, httpd_user_content_rw_t, httpd_user_content_ra_t;
  1055. type httpd_user_htaccess_t, httpd_user_script_exec_t;
  1056. ')
  1057. manage_dirs_pattern($1, { httpd_user_content_t httpd_user_content_rw_t httpd_user_content_ra_t httpd_user_script_exec_t }, { httpd_user_content_t httpd_user_content_rw_t httpd_user_content_ra_t httpd_user_script_exec_t })
  1058. manage_files_pattern($1, { httpd_user_content_t httpd_user_content_rw_t httpd_user_content_ra_t httpd_user_script_exec_t httpd_user_htaccess_t }, { httpd_user_content_t httpd_user_content_rw_t httpd_user_content_ra_t httpd_user_script_exec_t httpd_user_htaccess_t })
  1059. manage_lnk_files_pattern($1, { httpd_user_content_t httpd_user_content_rw_t httpd_user_content_ra_t httpd_user_script_exec_t }, { httpd_user_content_t httpd_user_content_rw_t httpd_user_content_ra_t httpd_user_script_exec_t })
  1060. ')
  1061. ########################################
  1062. ## <summary>
  1063. ## Search system script state directories.
  1064. ## </summary>
  1065. ## <param name="domain">
  1066. ## <summary>
  1067. ## Domain allowed access.
  1068. ## </summary>
  1069. ## </param>
  1070. #
  1071. interface(`apache_search_sys_script_state',`
  1072. gen_require(`
  1073. type httpd_sys_script_t;
  1074. ')
  1075. allow $1 httpd_sys_script_t:dir search_dir_perms;
  1076. ')
  1077. ########################################
  1078. ## <summary>
  1079. ## Read httpd tmp files.
  1080. ## </summary>
  1081. ## <param name="domain">
  1082. ## <summary>
  1083. ## Domain allowed access.
  1084. ## </summary>
  1085. ## </param>
  1086. #
  1087. interface(`apache_read_tmp_files',`
  1088. gen_require(`
  1089. type httpd_tmp_t;
  1090. ')
  1091. files_search_tmp($1)
  1092. read_files_pattern($1, httpd_tmp_t, httpd_tmp_t)
  1093. ')
  1094. ########################################
  1095. ## <summary>
  1096. ## Do not audit attempts to write
  1097. ## httpd tmp files.
  1098. ## </summary>
  1099. ## <param name="domain">
  1100. ## <summary>
  1101. ## Domain to not audit.
  1102. ## </summary>
  1103. ## </param>
  1104. #
  1105. interface(`apache_dontaudit_write_tmp_files',`
  1106. gen_require(`
  1107. type httpd_tmp_t;
  1108. ')
  1109. dontaudit $1 httpd_tmp_t:file write_file_perms;
  1110. ')
  1111. ########################################
  1112. ## <summary>
  1113. ## Execute CGI in the specified domain.
  1114. ## </summary>
  1115. ## <desc>
  1116. ## <p>
  1117. ## This is an interface to support third party modules
  1118. ## and its use is not allowed in upstream reference
  1119. ## policy.
  1120. ## </p>
  1121. ## </desc>
  1122. ## <param name="domain">
  1123. ## <summary>
  1124. ## Domain run the cgi script in.
  1125. ## </summary>
  1126. ## </param>
  1127. ## <param name="entrypoint">
  1128. ## <summary>
  1129. ## Type of the executable to enter the cgi domain.
  1130. ## </summary>
  1131. ## </param>
  1132. #
  1133. interface(`apache_cgi_domain',`
  1134. gen_require(`
  1135. type httpd_t, httpd_sys_script_exec_t;
  1136. ')
  1137. domtrans_pattern(httpd_t, $2, $1)
  1138. apache_search_sys_scripts($1)
  1139. allow httpd_t $1:process signal;
  1140. ')
  1141. ########################################
  1142. ## <summary>
  1143. ## All of the rules required to
  1144. ## administrate an apache environment.
  1145. ## </summary>
  1146. ## <param name="domain">
  1147. ## <summary>
  1148. ## Domain allowed access.
  1149. ## </summary>
  1150. ## </param>
  1151. ## <param name="role">
  1152. ## <summary>
  1153. ## Role allowed access.
  1154. ## </summary>
  1155. ## </param>
  1156. ## <rolecap/>
  1157. #
  1158. interface(`apache_admin',`
  1159. gen_require(`
  1160. attribute httpdcontent, httpd_script_exec_type;
  1161. attribute httpd_script_domains, httpd_htaccess_type;
  1162. type httpd_t, httpd_config_t, httpd_log_t;
  1163. type httpd_modules_t, httpd_lock_t, httpd_helper_t;
  1164. type httpd_var_run_t, httpd_passwd_t, httpd_suexec_t;
  1165. type httpd_suexec_tmp_t, httpd_tmp_t, httpd_rotatelogs_t;
  1166. type httpd_initrc_exec_t, httpd_keytab_t;
  1167. ')
  1168. allow $1 { httpd_script_domains httpd_t httpd_helper_t }:process { ptrace signal_perms };
  1169. allow $1 { httpd_rotatelogs_t httpd_suexec_t httpd_passwd_t }:process { ptrace signal_perms };
  1170. ps_process_pattern($1, { httpd_script_domains httpd_t httpd_helper_t })
  1171. ps_process_pattern($1, { httpd_rotatelogs_t httpd_suexec_t httpd_passwd_t })
  1172. init_startstop_service($1, $2, httpd_t, httpd_initrc_exec_t)
  1173. apache_manage_all_content($1)
  1174. miscfiles_manage_public_files($1)
  1175. files_search_etc($1)
  1176. admin_pattern($1, { httpd_keytab_t httpd_config_t })
  1177. logging_search_logs($1)
  1178. admin_pattern($1, httpd_log_t)
  1179. admin_pattern($1, httpd_modules_t)
  1180. admin_pattern($1, httpd_lock_t)
  1181. files_lock_filetrans($1, httpd_lock_t, file)
  1182. admin_pattern($1, httpd_var_run_t)
  1183. files_pid_filetrans($1, httpd_var_run_t, file)
  1184. admin_pattern($1, { httpdcontent httpd_script_exec_type httpd_htaccess_type })
  1185. admin_pattern($1, { httpd_tmp_t httpd_suexec_tmp_t })
  1186. apache_run_all_scripts($1, $2)
  1187. apache_run_helper($1, $2)
  1188. ')
  1189. ########################################
  1190. ## <summary>
  1191. ## Unlink httpd_var_lib_t files
  1192. ## </summary>
  1193. ## <param name="domain">
  1194. ## <summary>
  1195. ## Domain that can unlink the files
  1196. ## </summary>
  1197. ## </param>
  1198. #
  1199. interface(`apache_unlink_var_lib',`
  1200. gen_require(`
  1201. type httpd_var_lib_t;
  1202. ')
  1203. files_search_var_lib($1)
  1204. allow $1 httpd_var_lib_t:dir { write remove_name };
  1205. allow $1 httpd_var_lib_t:file unlink;
  1206. ')