gogs.te 2.7 KB

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