Browse Source

Add AppArmor support

tags/1.0
Timo Röhling 12 years ago
parent
commit
6dd6a525f7
2 changed files with 21 additions and 0 deletions
  1. 9
    0
      CMakeLists.txt
  2. 12
    0
      postsrsd.apparmor.in

+ 9
- 0
CMakeLists.txt View File

2
 project(postsrsd C)
2
 project(postsrsd C)
3
 
3
 
4
 option(GENERATE_SRS_SECRET "Generate a random SRS secret if none exists during install" ON)
4
 option(GENERATE_SRS_SECRET "Generate a random SRS secret if none exists during install" ON)
5
+option(USE_APPARMOR "Enable AppArmor profile" OFF)
5
 
6
 
6
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
7
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
7
 
8
 
28
 
29
 
29
 get_target_property(POSTSRSD ${PROJECT_NAME} LOCATION)
30
 get_target_property(POSTSRSD ${PROJECT_NAME} LOCATION)
30
 get_filename_component(POSTSRSD ${POSTSRSD} NAME_WE)
31
 get_filename_component(POSTSRSD ${POSTSRSD} NAME_WE)
32
+set(APPARMOR_PROFILE "${CMAKE_INSTALL_PREFIX}/sbin/${POSTSRSD}")
33
+string(SUBSTRING "${APPARMOR_PROFILE}" 1 -1 APPARMOR_PROFILE)
34
+string(REPLACE "/" "." APPARMOR_PROFILE "${APPARMOR_PROFILE}")
31
 
35
 
32
 configure_file(${PROJECT_NAME}.init.in ${PROJECT_NAME}.init @ONLY)
36
 configure_file(${PROJECT_NAME}.init.in ${PROJECT_NAME}.init @ONLY)
33
 configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
37
 configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
38
+configure_file(${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
34
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
39
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
35
 
40
 
36
 if(HELP2MAN)
41
 if(HELP2MAN)
41
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.8 DESTINATION "share/man/man8")
46
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.8 DESTINATION "share/man/man8")
42
 endif()
47
 endif()
43
 
48
 
49
+if(USE_APPARMOR)
50
+	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "/etc/apparmor.d" RENAME "${APPARMOR_PROFILE}")
51
+endif()
52
+
44
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
53
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
45
 install(FILES README.md main.cf.ex DESTINATION "share/doc/${PROJECT_NAME}")
54
 install(FILES README.md main.cf.ex DESTINATION "share/doc/${PROJECT_NAME}")
46
 install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")
55
 install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")

+ 12
- 0
postsrsd.apparmor.in View File

1
+#include <tunables/global>
2
+
3
+/usr/sbin/postsrsd {
4
+  #include <abstractions/base>
5
+  #include <abstractions/nameservice>
6
+
7
+  capability setuid,
8
+  capability sys_chroot,
9
+  /etc/postsrsd.secret r,
10
+  @CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ mr,
11
+}
12
+

Loading…
Cancel
Save