ソースを参照

Add AppArmor support

tags/1.0
Timo Röhling 12年前
コミット
6dd6a525f7
2個のファイルの変更21行の追加0行の削除
  1. 9
    0
      CMakeLists.txt
  2. 12
    0
      postsrsd.apparmor.in

+ 9
- 0
CMakeLists.txt ファイルの表示

@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.4)
2 2
 project(postsrsd C)
3 3
 
4 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 7
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
7 8
 
@@ -28,9 +29,13 @@ add_executable(${PROJECT_NAME} postsrsd.c sha1.c srs2.c)
28 29
 
29 30
 get_target_property(POSTSRSD ${PROJECT_NAME} LOCATION)
30 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 36
 configure_file(${PROJECT_NAME}.init.in ${PROJECT_NAME}.init @ONLY)
33 37
 configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
38
+configure_file(${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
34 39
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
35 40
 
36 41
 if(HELP2MAN)
@@ -41,6 +46,10 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
41 46
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.8 DESTINATION "share/man/man8")
42 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 53
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
45 54
 install(FILES README.md main.cf.ex DESTINATION "share/doc/${PROJECT_NAME}")
46 55
 install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")

+ 12
- 0
postsrsd.apparmor.in ファイルの表示

@@ -0,0 +1,12 @@
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
+

読み込み中…
キャンセル
保存