This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Debug application as root

Tags: None
(comma "," separated)
Petross404 (petross)
Registered Member
Posts
16
Karma
0

Debug application as root

Sun Nov 15, 2020 1:46 pm
I am writing an app that needs to be ran as root. How can I debug it without running KDevelop as root but only gdb?
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Debug application as root

Sun Nov 15, 2020 3:24 pm
Hi!

Be a bit more informative. Do all parts need to run as root (as Qt-GUI-Applications do not support running as root )? You can configure custom launches via «run → configure launches…» and create your custom gdb-command with it. I consider using pkexec to start it with appropriate permissions.
Which language do you use?
Petross404 (petross)
Registered Member
Posts
16
Karma
0

Re: Debug application as root

Thu Dec 03, 2020 9:00 am
koffeinfriedhof wrote:Hi!

Be a bit more informative. Do all parts need to run as root (as Qt-GUI-Applications do not support running as root )? You can configure custom launches via «run → configure launches…» and create your custom gdb-command with it. I consider using pkexec to start it with appropriate permissions.
Which language do you use?


I am writing a c application to use some gpio ports with an Adafruit I plugged into my usb. Obviously this needs to be ran as root.

But even this can be bypassed with proper udev rules, still it's some usefull knowledge.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS

Re: Debug application as root  Topic is solved

Thu Dec 03, 2020 12:48 pm
If you are running Raspbian/Ubuntu or use the sudo-package, you could try to use the visudo command to allow an exception for gdb, e.g.
Code: Select all
%coders ALL = NOPASSWD: /usr/bin/gdb
to allow every member of the group coders to run `sudo gdb` without asking for a password. Then use the custom launches and use `sudo gdb` instead of pkexec gdb which will avoid asking for a password.
I'd prefer the udev-method anyway. As a simple approach you can just give everyone on your machine read access to the device (chmod +r /dev/whatever/).


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]