How to debug your application with root permissions on VSCODE? - linux

I'm trying to debug dotnet core web app, however it's not possible to do it without having root permissions.
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.Private.CoreLib.dll: 'Permission denied'
The naive approach would be launching VSCode with root permissions, which is generally not a recommended (and I would like to avoid it).
Is there any way to configure launch.json to execute the debugger with root permissions?
I've tried already creating a pre-launch task executing sudo or sudo su commands.
I tried running the application and trying to attach to the process (also got declined because of insufficient permissions)

For C#:
Locate vsdbg-ui (in my case: ~/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.debugger)
Rename "vsdbg-ui" to "vsdbg-ui2"
Create a new file in the same folder called "vsdbg-ui" with following content:
pkexec [yourhomefolder]/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.debugger/vsdbg-ui2
Make the new file "vsdbg-ui" executable
Launch the debugging session in VSCode. You will get a prompt to enter your sudo password. You are debugging with sudo now.

Related

ElectronJS: Operation not permitted

I've been developing an Electron app for Linux. The problem is: I can't execute an instruction because of this:
Error: socket: Operation not permitted
This might mean it needs sudo permissions. But since it is a desktop app, and I want to avoid this when I'll distribute it, is there a way to bypass this error, to execute it without sudo or automatically use it, in both development and production mode? If not, can I write a message which says it requires admin execution when I open its AppImage?
#crimson589
If I run dev mode with sudo npm run electron:serve it returns Error: Failed to get 'appData' path. If I run the AppImage with sudo, it works.

acess a protect folder using sudo in wsl

i'm using linux shell in my windows (wsl) and i'm trying to make a cd to a directory that needs permission.
I've saw some solutions here including using sudo su, to became a super user, but even with this code i'm not sucessful
sudo su
cd ./rootfs
I'm stuck in this problem fro a while, so what's is going on?
root#LAPTOP-FGSL14B2:/mnt/c/Users/giova/Appdata/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState# cd ./rootfs
bash: cd: ./rootfs: Permission denied
It is a special folder, see: superuser.com/a/1446574/1083266
(I wanted to mark the question as a duplicate, but that is only valid for existing answers on stackoverflow)
I suspect that the folder you are trying to access required elevated permissions to view. Is the shell running as admin?
Sudo will not elevate the shell to allow for access to windows folders that the process does not have access to.
In the start menu right click the wsl or bash exe and select "run as admin" see if that works for you.

RStudio cannot reach .Rhistory on Ubuntu

I was working with markdown file on RStudio. I have Ubuntu 14.04 on my laptop. I produce html files using knitr. I decided to clean my enviroment and added rm and gc commands at the end.
Now here is a message in my console window:
Error attempting to read history from ~/.Rhistory: permission denied (is the .Rhistory file owned by root?)
What it means? Is it bad for my code?
You are right - the first time you ran it, you were in sudo mode, and the .Rhistory file was created with root as the owner. Running RStudio as root would remove the symptom, but is not ideal. To be able to run it as a regular user, simply change the owner of the .Rhistory file:
sudo chown -c <user_name> .Rhistory
In the best traditions of stackoverflow I reply to my own question! The problem occurred because when I first started R, I did it as su:
sudo R
so I can load a lot of useful libraries in /usr/lib/R/site-library and not in my account. As result .Rhistory became su file. It is possible for RStudio to see it if it is started as
sudo rstudio
and then all is fine.

Running SoapUI and HermesJMS on headless Linux Server

I'm trying to get SoapUI and HermesJMS to work with each other on a headless Linux server. And by "headless" I do mean headless; the only account we are authorized to use that has any kind of admin privileges is unable to forward an X-server session.
First, the steps I've done so far:
Unpacked the tar.gz containing SoapUI 4.6.0 into a soapui directory.
Using my own account, which has X-server, I ran the HermesJMS installer.
Set 777 permissions so the admin user could work with the files.
I entered the soapui-config.xml and test.xml files and told them where to find the hermes-config.xml
Independently, they both work. I can run a generic SoapUI test and if I use my X-server to run Hermes, I can see the queues I need to be using.
However, when I try to use the testrunner.sh, I get a NullPointer exception on HermesUtils.addHermesJarsToClasspath.
An error occured [java.lang.NullPointerException], see error log for details java.lang.NullPointerException
at com.eviware.soapui.impl.wsdl.submit.transports.jms.util.HermesUtils.addHermesJarsToClasspath(HermesUtils.java:120)
Any ideas on what the issue is? I tried running soapui's GUI the same way I ran Hermes' but I run into a segmentation fault on startup.

Why running sudo to my own account fixes graphical problems in Swing GUI

My swing GUI application starts with a script.
When I run that script under Linux without sudo it gives me unexpected Look and feel and other graphical problems.
Why is running with sudo su to my own account fixes this problem?
One might guess that the program is trying to make use of a file that has permissions that allow root to access it, but not your uid. Perhaps you have a library installed with wrong permissions?
strace will tell you what files your app is trying to access.

Resources