Run C ++ program in Clion as root

I am trying to run a program written in C ++ using CLion v1.2 as root. Does anyone know how to run it as root? I am using CMake.

+5
source share
3 answers

I solved this by remote debugging on the local machine. I run gdbserver with root privileges and connect to it from CLion.

To run gdbserver sudo gdbserver :port myapp , configure the remote GDB debugger using port

+1
source

Workaround:

From https://www.jetbrains.com/help/clion/attaching-to-local-process.html#prereq-ubuntu

If you use CLion on Ubuntu (or probably another Linux distribution), the first time you try to connect to a local process, you can get the ptrace: Operation not allowed command. error message. To disable it and enable binding to the local function of the process, follow these steps:

To temporarily disable this restriction, enter the command:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

To disable this restriction permanently, open the file /etc/sysctl.d/10-ptrace.conf for editing and change the line kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0 . To apply the changes, enter: sudo service procps restart or reboot the system of your choice.

0
source

If you ask to run the debugger as sudo / administrator, I had the same problem. On Linux, you can open CLion, since sudo and gdb will not have root rights issues executing the executable:

 sudo ./clion.sh 

I would suggest that you can right-click on Windows and run as administrator to get the same result.

JetBrains has a property request to run the debugger as root, which could use more votes.

-1
source

Source: https://habr.com/ru/post/1241144/


All Articles