Ask Your Question

Allow Wing IDE to debug non-root code using sudo python as a script

asked 2020-10-13 12:03:09 -0500

mhanuel gravatar image

updated 2020-10-14 08:00:14 -0500

Could you please let me know a template script and configuration steps that allow me to run the python as sudo, I am not sure how to configure the python executable. The remote host already allow sudo without entering password.

I know this is possible but I haven't found where is documented, I am looking at the third option mentioned here link text

Many thanks in advance,

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2020-10-14 15:30:01 -0500

TomBerk gravatar image

updated 2020-10-14 16:51:55 -0500

We faced a similar challenge--except that we needed to use Wing in remote mode. We need some scripts to execute with sudo on the remote host.

We made a copy of the python3 executable file called "python3_privileged". Then we used setcap to set the capabilities we needed on python3_priviledged.

sudo setcap CAP_SYS_ADMIN,CAP_dac_override=eip \~/python3_privileged

adding the capabilities that you need. Then set Wing's project to use python3_privileged instead of python3. It's a bit of a pain to set up, and it requires some maintenance as you update Python.

edit flag offensive delete link more

answered 2020-10-14 09:38:35 -0500

updated 2020-10-14 09:39:17 -0500

It may work to create a shell script with the following contents:

sudo python3 "$@"

Then make that executable on disk with 'chmod +x <filename>' and set it as the Python Executable in Wing's Project Properties (accessed from the Project menu).

This will not send in the environment set in Project Properties or inherited by Wing, and that may not be wanted anyway. If it is, you can use this instead:

sudo -E python3 "$@"

Also, of course, you may want just 'python' and not 'python3' or perhaps the full path of the Python you wish to run.

edit flag offensive delete link more


Hi thanks for your answer, I was trying this solution but it seems now Wing IDE wants to use /root as the script and source code base path instead of my normal user. After trying to copy those files, Wing IDE seems to not be able to connect back to my Host machine. Do you have any idea what might be wrong?

mhanuel gravatar imagemhanuel ( 2020-10-15 11:38:36 -0500 )edit

Are you able to read the files? It should be possible to work with them under /root (root's home directory) or to navigate to other directories such as the full path of the non root user's home directory. Note that you'll want to be careful of file permissions and ownership -- at least in my experience, it's always an issue when using different user accounts.

Wingware Support gravatar imageWingware Support ( 2020-10-15 13:21:37 -0500 )edit

If you're using a remote host configuration, you probably want to add the user name to the Host Name field, for example myuser@ It sounds a bit like it was using the username 'root' but I'm not sure. Also, setting Base Directory under the Options tab may help.

Wingware Support gravatar imageWingware Support ( 2020-10-16 10:35:52 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-10-13 12:03:09 -0500

Seen: 48 times

Last updated: Oct 14