Author Topic: Debug program that needs root privileges  (Read 6679 times)

Offline Tomás Ó hÉilidhe

  • Single posting newcomer
  • *
  • Posts: 3
Debug program that needs root privileges
« on: December 18, 2008, 03:22:58 pm »

I'm currently writing a program that opens a raw Ethernet socket. I use "sudo" to run it at the commandline.

How can I use the Code::Blocks IDE to debug it? I've tried replacing "gdb" with a script that runs gdb as root, but it didn't work out.

Is there anything I can do to my Linux machine to make it so that anybody can open a raw socket without the need for "sudo"?

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Debug program that needs root privileges
« Reply #1 on: December 18, 2008, 03:34:28 pm »
Hi !

Not at all a Linux expert, but did you try to execute C::B with sudo so that launched gdb inherit rights ?

Dje

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Debug program that needs root privileges
« Reply #2 on: December 18, 2008, 05:23:50 pm »
Did you try to run gdb and/or your program with suid bit set ?
Code
chmod u+s /usr/bin/gdb
or
Code
chmod u+s <your_program>
.

If you have to set it for your program the owner has to be root of course.
« Last Edit: March 22, 2009, 09:52:27 am by jens »