From 1737780ead8496123dd5fd55a51f0980fda636b4 Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Wed, 17 May 2017 08:27:27 +0200 Subject: [PATCH] Set mldr & mldr32 file capabilities at install time --- cmake/setcap.cmake | 18 ++++++++++++++++++ src/startup/CMakeLists.txt | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 cmake/setcap.cmake diff --git a/cmake/setcap.cmake b/cmake/setcap.cmake new file mode 100644 index 000000000..d42b80f12 --- /dev/null +++ b/cmake/setcap.cmake @@ -0,0 +1,18 @@ +include(FindSetcap) + +function(setcap file caps) +install(CODE "execute_process( + COMMAND + ${SETCAP_EXECUTABLE} + cap_sys_rawio+ep + ${CMAKE_INSTALL_PREFIX}/${file} + RESULT_VARIABLE + _SETCAP_RESULT + ) + if( _SETCAP_RESULT ) + message( WARNING \"setcap failed (${_SETCAP_RESULT}).\") + endif()" +) + +endfunction(setcap) + diff --git a/src/startup/CMakeLists.txt b/src/startup/CMakeLists.txt index a305a6f59..fd0a59983 100644 --- a/src/startup/CMakeLists.txt +++ b/src/startup/CMakeLists.txt @@ -46,3 +46,8 @@ install(TARGETS darling DESTINATION bin GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID) + +include(setcap) +setcap(libexec/darling/bin/mldr cap_sys_rawio+ep) +setcap(libexec/darling/bin/mldr32 cap_sys_rawio+ep) +