gogs.te 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. policy_module(gogs, 0.2.6)
  2. ########################################
  3. #
  4. # Declarations
  5. #
  6. attribute_role gogs_roles;
  7. type gogs_t;
  8. type gogs_exec_t;
  9. init_daemon_domain(gogs_t, gogs_exec_t)
  10. type gogs_initrc_exec_t;
  11. init_script_file(gogs_initrc_exec_t)
  12. type gogs_opt_t;
  13. files_type(gogs_opt_t)
  14. type gogs_var_lib_t;
  15. files_type(gogs_var_lib_t)
  16. type gogs_tmp_t;
  17. files_tmp_file(gogs_tmp_t);
  18. type gogs_ssh_t;
  19. files_type(gogs_ssh_t)
  20. ########################################
  21. #
  22. # Local policy
  23. #
  24. allow gogs_t self:fifo_file { read write getattr };
  25. allow gogs_t self:process { getsched signal };
  26. allow gogs_t self:tcp_socket { getattr setopt bind create accept listen read write connect getopt };
  27. allow gogs_t self:udp_socket { connect getattr create setopt };
  28. allow gogs_t self:fifo_file ioctl;
  29. allow gogs_t gogs_exec_t:file execute_no_trans;
  30. allow gogs_t gogs_var_lib_t:file { execute execute_no_trans };
  31. manage_dirs_pattern(gogs_t, gogs_opt_t, gogs_opt_t)
  32. manage_files_pattern(gogs_t, gogs_opt_t, gogs_opt_t)
  33. manage_dirs_pattern(gogs_t, gogs_ssh_t, gogs_ssh_t)
  34. manage_files_pattern(gogs_t, gogs_ssh_t, gogs_ssh_t)
  35. manage_lnk_files_pattern(gogs_t, gogs_ssh_t, gogs_ssh_t)
  36. filetrans_pattern(gogs_t, gogs_opt_t, gogs_ssh_t, { file dir lnk_file })
  37. manage_dirs_pattern(gogs_t, gogs_var_lib_t, gogs_var_lib_t)
  38. manage_files_pattern(gogs_t, gogs_var_lib_t, gogs_var_lib_t)
  39. manage_lnk_files_pattern(gogs_t, gogs_var_lib_t, gogs_var_lib_t)
  40. optional_policy(`
  41. gen_require(`
  42. type var_lib_t;
  43. ')
  44. filetrans_pattern(gogs_t, var_lib_t, gogs_var_lib_t, { file dir lnk_file })
  45. ')
  46. manage_dirs_pattern(gogs_t, gogs_var_lib_t, gogs_tmp_t)
  47. manage_files_pattern(gogs_t, gogs_var_lib_t, gogs_tmp_t)
  48. files_tmp_filetrans(gogs_t, gogs_tmp_t, { file dir } )
  49. allow gogs_t gogs_opt_t:file map;
  50. allow gogs_t gogs_var_lib_t:file map;
  51. miscfiles_read_localization(gogs_t)
  52. corenet_tcp_bind_generic_node(gogs_t)
  53. corenet_tcp_bind_ntop_port(gogs_t)
  54. corenet_tcp_connect_smtp_port(gogs_t)
  55. corenet_tcp_connect_ntop_port(gogs_t)
  56. kernel_read_net_sysctls(gogs_t)
  57. kernel_read_system_state(gogs_t)
  58. git_exec(gogs_t)
  59. git_read_usr_t(gogs_t)
  60. corecmd_exec_bin(gogs_t)
  61. files_read_etc_files(gogs_t)
  62. mysql_tcp_connect(gogs_t)
  63. sysnet_read_config(gogs_t)
  64. kernel_read_kernel_sysctls(gogs_t)
  65. kernel_read_vm_sysctls(gogs_t)
  66. dev_read_sysfs(gogs_t)
  67. corecmd_exec_shell(gogs_t)
  68. dev_read_urand(gogs_t)
  69. optional_policy(`
  70. gen_require(`
  71. type sshd_t;
  72. ')
  73. manage_files_pattern(sshd_t, gogs_ssh_t, gogs_ssh_t)
  74. manage_dirs_pattern(sshd_t, gogs_ssh_t, gogs_ssh_t)
  75. search_dirs_pattern(sshd_t, gogs_opt_t, gogs_opt_t)
  76. domain_auto_trans(sshd_t, gogs_exec_t, gogs_t)
  77. ')
  78. optional_policy(`
  79. gen_require(`
  80. type supervisor_t;
  81. ')
  82. supervisor_service_domain(gogs_t, gogs_exec_t)
  83. allow supervisor_t gogs_opt_t:dir search;
  84. ')
  85. optional_policy(`
  86. gen_require(`
  87. type ssh_keygen_exec_t;
  88. ')
  89. allow gogs_t ssh_keygen_exec_t:file { read getattr open execute execute_no_trans };
  90. ')