POL_Test_ptrace

Informations

Creator Message
petch

Information

This installer has been approved by the team.

Informations

Platforms:
Downloads: 8890
Wine: System

Feedbacks

Description

Check whether wineserver process is able to use ptrace().
It may use ptrace():
- if the Linux kernel doesn't include the Yama patch that restricts its use
- if the Yama patch is present but the ptrace() scope is fully opened (/proc/sys/kernel/yama/ptrace_scope is 0)
- if the wineserver process has cap_sys_ptrace capability (setcap cap_sys_ptrace=ep wineserver)

Remarks:
- this script may need to restart wineserver, be sure to call it when no program is supposed to run
- it currently doesn't do anything under Mac OS X

Source code

#!/bin/bash

#  Check Kernel ptrace

#  Without Yama patch, we assume ptrace is allowed from anywhere
if [ -e /proc/sys/kernel/yama/ptrace_scope ]; then
        NEED_WINESERVER_RESTART=''
        while true;
            do [ "$(cat /proc/sys/kernel/yama/ptrace_scope)" = 0 ] && break
                if setcap -q -v cap_sys_ptrace=ep "$(which wineserver)"; then
                        [ -n "$NEED_WINESERVER_RESTART" ] && wineserver -k
                        break
                fi
                NEED_WINESERVER_RESTART=1
                POL_SetupWindow_Init
                POL_SetupWindow_menu_num "$(eval_gettext 'The program needs access to ptrace() to proceed:')" "$TITLE" "$(eval_gettext 'Give the capability to wineserver executable')~$(eval_gettext 'Enable ptrace() globally')~$(eval_gettext 'I fixed it myself, just retest')~$(eval_gettext 'Abort installation')" "~"
                case "$APP_ANSWER" in
                    0)
                        POL_Call POL_Function_RootCommand 'sudo setcap cap_sys_ptrace=ep "'"$(which wineserver)"'"'
                        ;;
                    1)
                        POL_Call POL_Function_RootCommand 'echo 0|sudo tee "/proc/sys/kernel/yama/ptrace_scope"'
                        ;;
                    2)
                        ;;
                    *)
                        NOBUGREPORT="TRUE"
                        POL_Debug_Fatal "$(eval_gettext 'User abort')"
                        ;;
                esac
        done
fi

POL_SetupWindow_Close
exit 0

Contributions

Filters:

Contribute
Member Message

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com