apparmor.initd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2013 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. description="Load all configured profiles for the AppArmor security module."
  5. description_reload="Reload all profiles"
  6. extra_started_commands="reload"
  7. aa_action() {
  8. local arg=$1
  9. local return
  10. shift
  11. $*
  12. return=$?
  13. if [ ${return} -eq 0 ]; then
  14. aa_log_success_msg $arg
  15. else
  16. aa_log_failure_msg arg
  17. fi
  18. return $return
  19. }
  20. aa_log_action_start() {
  21. ebegin $1
  22. }
  23. aa_log_action_end() {
  24. eend $1
  25. }
  26. aa_log_success_msg() {
  27. einfo $1
  28. }
  29. aa_log_warning_msg() {
  30. ewarn $1
  31. }
  32. aa_log_failure_msg() {
  33. eerror $1
  34. }
  35. aa_log_skipped_msg() {
  36. einfo $1
  37. }
  38. aa_log_daemon_msg() {
  39. einfo $1
  40. }
  41. aa_log_end_msg() {
  42. eend $1
  43. }
  44. . /usr/lib/apparmor/rc.apparmor.functions
  45. start() {
  46. ebegin "Starting AppArmor"
  47. eindent
  48. if ! is_apparmor_loaded ; then
  49. load_module
  50. if [ $? -ne 0 ]; then
  51. eerror "AppArmor kernel support is not present"
  52. eend 1
  53. return 1
  54. fi
  55. fi
  56. parse_profiles load
  57. eoutdent
  58. }
  59. stop() {
  60. ebegin "Stopping AppArmor"
  61. eindent
  62. apparmor_stop
  63. eoutdent
  64. }
  65. reload() {
  66. # todo: split out clean_profiles into its own function upstream
  67. # so we can do parse_profiles reload && clean_profiles
  68. # and do a proper reload instead of restart
  69. apparmor_restart
  70. }