I am developing some code using the BlueZ Bluetooth stack and running it requires root privileges. As example running hcitool lescan as normal user returns Set scan parameters failed: Operation not permitted, which is also seen from my C++ code where hci_le_set_scan_parameters() functions returns -1.
The question Run a C++ program in Clion as root is about running C++ program as root in CLion on the local machine, which can be as simple as running the CLion as root.
I have configured Full Remote Mode with remote toolchain:
and then I'm using this same configuration for automatic deployment:
and then the Run/Debug Configurations are automatically run as this user on the remote machine.
I could replace Non-superuser user in Deployment configuration with root and probably solve the problem (by also giving root privileges to whole Remote Host Browser) - but is there any other way to achieve this any only run the built executable with sudo?
Related
Is it possible to run a remote debug session targeting Windows with CLion?
The docs say that I can do any system that has gdbserver:
Remote OS: any supporting gdbserver and SSH
However, when I try to run my remote app, I get an error:
10:53 PM Build finished in 3 sec, 44 ms
10:53 PM Error running 'remote'
1: 'env' is not recognized as an internal or external command,
operable program or batch file.
I can't find a place where I could see the whole command that CLion runs that causes this error.
Here is my configuration:
After some investigation, I have come to the conclusion that it is impossible to remote debug a Windows app with CLion 2021.3.1 (regardless of Host platform).
CLion does not support remote debugging when targeting Windows OS using GDB Server (hence targeting Windows is impossible) due to:
CLion does not handle cases when SSH Server is using a non-Unix shell like CMD.exe or PowerShell. Commands like exec, env, chmod can’t be handled. This can be circumvented by using a Unix shell:
a. Unfortunately, connection fails for MSYS2 Bash and Git Bash when Windows OpenSSH Server is configured to use one as a default shell.
b. Windows WSL SSH Server works. Connection is established, Unix commands are recognized. WSL must be installed. It is not easy to configure WSL when Windows itself is running on virtual machine.
c. MinGW64 SSH Server. Didn’t test it.
Uploading binaries via SFTP fails when OpenSSH Service is used. Can be circumvented with 1.b..
CLion doesn’t consider the binary’s file extension. It always assumes that the binary is built for Linux, hence the attempt to transfer fails, when a binary has an .exe extension (fails to find test, though test.exe was built). This is a major bug that prevents remote debugging targeting Windows. There are, however, ways to work around:
a. Manual renaming before running debug. Unacceptable.
b. Adding a conditional custom CMake command. May work but pollutes the CMakeLists.txt
CLion can’t connect to MinGW GDB Server it has started. Connection times out. However, if the Server was started from a terminal, CLion connects successfully and is able to run debug as intended. This can ONLY be worked around MANUALLY:
a. In Edit Configurations… one must put a stub command in GDB Server:, for example ‘sleep’. In GDB Server args: ‘5’. This will give a time to manually run the gdbserver.exe command via an SSH connection in Terminal.
These issues were reproduced for CLion versions for Windows 10 and Ubuntu 20.04.
3. and 4. are very serious and prevent from remote debugging targeting Windows as it was intended to be done.
This happens when CLion connects to the Server it has started:
This is a work around:
As can be seen from the screenshots, with this approach GDB’s console does not catch the output. You must switch to Terminal to see it.
I've read several guides/stackoverflows but not found a similar situation/solution.
I have my remote ssh working (can browse files).
I don't get why I need a local Windows application (although I have a compiled .exe it's not the version I want to debug which is only on the Linux server).
When I try and launch a remote debug session it immediately fails with
Exception occurred during launch
Reason:
Error during file upload.
and below in the details
Could not write file: <my windows exe path>
Permission denied
...
The aforementioned file is writable and in any event I also started eclipse as administrator just in case.
In any event the .exe is irrelevant. I just want to debug code remotely.
(I know all about gdbserver...happy to manually kick that off if need be....don't think I'm there yet though)
Below is the options page I'm presented with:
Had the same experience on TI Code Composer Studio Version: 9.3.0.00012.
This seems to happen while uploading the cross compiled binary from host to target. If you set the check box "Skip download to target path" the error should disappear.
I propose to workaround the upload.
Setup a web server on the host, the line python.exe -m http.server --directory \source\hello\Debug\ would be sufficient
Run wget on the target, see screenshot
I m trying to cross-compiling a simple HelloWorld app in C++ on Win 10 for raspberry pi3. I installed toolchain to configure it out. But till now by creating new ssh connection i got always an Error such as "Access denied" or "No connection could be made bcz the target maschine actively refused it".
I checked many tutorials to cross-compiling but no success till now
I think you are mixing different stuff here.
Cross compiling means compiling (and linking) the software for the embedded target on the host computer (in your case Win10). You don't need to SSH on the target for this. You'll likely need to run your configure your build like this:
./configure --host=arm-linux --build=amd64-pc-linux-gnu
The host argument is where the binary should run, and the build argument is where the binary is built.
However, I suspect that you've successfully built the software on your Win10 computer, and then you're trying to copy it on the embedded device. In that case, you must make sure that:
The embedded device is connected to the network
It's running a SSH daemon (likely opensshd)
It's allowing your user to connect to (typically, on default installation, root is not allowed to connect, you'll need to modify /etc/ssh/sshd_config to PermitRootLogin to yes)
(Optionally) You generate a key pair on the host (via ssh-keygen and copy the public key on your embedded user's .ssh/authorized_keys folder) to allow password-less login
Please refer to SSH man page.
With all the above in place, you can then scp build/mySoftware root#myDevice:/usr/local/bin without the Access Denied message.
I have set up a jenkins slave server with cygwin and I'm launching builds on it via ssh.
The build of our project succeeds if run locally as the slave user both in the windows command prompt and in the cygwin command prompt. I can also ssh into the machine as the slave user and run the build successfully.
However, when jenkins runs the build as that slave, it fails trying to compile the first C++ project with the error: fatal error C1902: Program database manager mismatch; please check your installation.
Visual C++ 2010 express, and Visual C# 2010 express are both installed and required for our project to build.
In my research I found some indications that cygwin does not handle the remote login correctly here: https://java.net/projects/hudson/lists/users/archive/2008-10/message/130
Has anyone else solved this problem?
Try below solution
Use “Launch slave agents via Java Web Start” to add windows slave to jenkins master.
It will launch Jenkins service on windows machine using some local users account. Then change local user to the user you are using to build locally.
The problem with “Launch slave agents on Unix machines as SSH” method is, it runs connection using “cyg_server” user.
Here is the scenario.
I have a C++ application using CMake that has been setup on Ubuntu server machine. I have setup a remote development interface to it using Netbeans 6.9 on client machine, and I have been able to build it.
The problem is that (as per the setup of CMake script) the executables from the program are going to another directory in the server. When I try to run the program, Netbeans asks me for executables which I can't spot out on client machine (as they are residing on server machine).
Is there a way I can get the executables on local machine OR have a way to give their location to my Netbeans application.
Thanks for your help.