|
|
@@ -2864,6 +2864,33 @@ deployFiles() {
|
|
|
setupAll
|
|
|
createCurrentVersionSymlink
|
|
|
}
|
|
|
+enableRootDropping() {
|
|
|
+ local output=
|
|
|
+ if ! isAvailable setcap; then
|
|
|
+ toConsoleWarn "Failed to enable non-privileged mode, kernel does not support file capabilities. Set NON_ROOT_MODE=false."
|
|
|
+ #== writeParamToConfigFile "${CONF_FIELD_NM_NON_ROOT_MODE}" "false" "${LEGACY_AGENT_CONF_FILE}"
|
|
|
+ #== writeParamToConfigFile "${CONF_FIELD_NM_NON_ROOT_MODE}" "false" "${INSTALLER_CONF_FILE}"
|
|
|
+ #== editScriptFileParam "readonly PARAM_NON_ROOT_MODE" "false" "${AGENT_SCRIPTS_DIR}/${SERVICE_SCRIPT_FILE}"
|
|
|
+ return
|
|
|
+ fi
|
|
|
+
|
|
|
+ #== 设置文件权限 (https://www.cnblogs.com/xzongblogs/p/14106481.html)
|
|
|
+ #== CAP_DAC_OVERRIDE:绕过文件的读,写,和执行权限检查。
|
|
|
+ #== CAP_FOWNER:对于通常要求进程的文件系统 UID 与文件的 UID 匹配的操作,绕过权限检查 (比如,chmod(2),utime(2)),除了那些包含在 CAP_DAC_OVERRIDE 和 CAP_DAC_READ_SEARCH 中的操作
|
|
|
+ #== CAP_IPC_LOCK:允许锁定共享内存片段
|
|
|
+ #== CAP_SYS_PTRACE:允许跟踪任何进程
|
|
|
+ #== CAP_SYS_ADMIN:访问特权 perf 事件信息
|
|
|
+ #== CAP_SYS_RESOURCE:忽略资源限制
|
|
|
+ #== CAP_NET_ADMIN:允许执行多种网络有关的操作
|
|
|
+ commandErrorWrapper setcap cap_dac_override,cap_fowner,cap_ipc_lock,cap_sys_ptrace,cap_sys_admin,cap_sys_resource,cap_net_admin+ep "${AGENT_BIN_DIR}/${AGENT_PROC}"
|
|
|
+ local setCapCwServerAgentExitCode=$?
|
|
|
+ if [ ${setCapCwServerAgentExitCode} -eq 0 ] ; then
|
|
|
+ toConsoleInfo "Set file capabilities [${AGENT_PROC}]"
|
|
|
+ else
|
|
|
+ toConsoleWarn "Failed to enable non-privileged mode. Exit Code : ${setCapCwServerAgentExitCode} . For details, see: ${LOG_FILE}"
|
|
|
+ toLogWarn "Set file capabilities output: ${output}"
|
|
|
+ fi
|
|
|
+}
|
|
|
|
|
|
#== 【5】=配置安装
|
|
|
configureInstallation() {
|
|
|
@@ -2885,6 +2912,7 @@ configureInstallation() {
|
|
|
changeFilesOwnership
|
|
|
fi
|
|
|
#== 设置root权限
|
|
|
+ enableRootDropping
|
|
|
fi
|
|
|
#== 系统配置(策略配置、dump proc、agent 进程配置、自动启动)
|
|
|
# setupAutostart
|