Author Topic: Help Running/Debugging "root" programs  (Read 11221 times)

Offline michelinok

  • Single posting newcomer
  • *
  • Posts: 4
Help Running/Debugging "root" programs
« on: August 23, 2008, 10:28:24 am »
Hi there!
I'm new to C and codeblocks, but i find codeblocks excellent!
I've s "simple" question.... my program needs to be run/debugged as root, but i'm developing as a normal user; is there a way to run/debug as root inside codeblocks? (something like "when run/debug" ask for root password and proceed).

Many thanks!
Great job!

Offline Barking_Mad

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: Help Running/Debugging "root" programs
« Reply #1 on: August 29, 2008, 07:21:13 am »
Just change the terminal/shell to a root/admin one in the environment options of CB. Its in the general options section.
WooF! WooF! - Ubuntu 8.10 & CB 5432 & GCC 4.3.2
To see the world in a grain of sand and heaven in a wild flower
To hold infinity in the palm of your hand and eternity in an hour - W.B

Offline michelinok

  • Single posting newcomer
  • *
  • Posts: 4
Re: Help Running/Debugging "root" programs
« Reply #2 on: August 29, 2008, 03:49:49 pm »
Just change the terminal/shell to a root/admin one in the environment options of CB. Its in the general options section.
Ok, found the 2 entryes:

Shell to run commands in:                        /bin/sh -c
Terminal to launch console programs:     xterm -T %TITLE -e

How should i change those entryes?

(I'm a newbie,sorry for the stupid question!)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Help Running/Debugging "root" programs
« Reply #3 on: August 29, 2008, 04:23:27 pm »
Hi there!
I'm new to C and codeblocks, but i find codeblocks excellent!
I've s "simple" question.... my program needs to be run/debugged as root, but i'm developing as a normal user; is there a way to run/debug as root inside codeblocks? (something like "when run/debug" ask for root password and proceed).

Many thanks!
Great job!


Afaik there is no option included in C::B.

You can try to start C::B from a console window with "sudo codeblocks" .

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Help Running/Debugging "root" programs
« Reply #4 on: August 29, 2008, 05:02:10 pm »
maybe you should use a chroot/fakeroot/scratchbox approach...

Offline michelinok

  • Single posting newcomer
  • *
  • Posts: 4
Re: Help Running/Debugging "root" programs
« Reply #5 on: August 29, 2008, 07:04:58 pm »
maybe you should use a chroot/fakeroot/scratchbox approach...

Please,can you explain what you mean?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Help Running/Debugging "root" programs
« Reply #6 on: August 29, 2008, 07:47:30 pm »
ideally you should try to avoid testing/debugging code as the root user on your system, as bad things could happen to the system leaving you up the proverbial creek without a paddle. chroot/fakeroot allow you to create a "fake" file system that looks like the real thing to the application. scratchbox goes one step further and lets you fake entire platforms, which allows you to test code for embedded systems (mobile phones, settop boxes etc) without having the hardware. the tools can even support gui apps using utils such as Xephyr. google any of these for more info. can you gives us more info about the sort of app you are trying to test/debug?

Offline michelinok

  • Single posting newcomer
  • *
  • Posts: 4
Re: Help Running/Debugging "root" programs
« Reply #7 on: August 29, 2008, 09:15:15 pm »
ideally you should try to avoid testing/debugging code as the root user on your system, as bad things could happen to the system leaving you up the proverbial creek without a paddle. chroot/fakeroot allow you to create a "fake" file system that looks like the real thing to the application. scratchbox goes one step further and lets you fake entire platforms, which allows you to test code for embedded systems (mobile phones, settop boxes etc) without having the hardware. the tools can even support gui apps using utils such as Xephyr. google any of these for more info. can you gives us more info about the sort of app you are trying to test/debug?

yes, i need only to perform iwconfig,ifconfig and use the printk function.
That's all! (it's just an AP hopper, if someone is interested, i'm gonna publish my work on sourceforge very soon!).

Offline wwwnuwan

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help Running/Debugging "root" programs
« Reply #8 on: March 22, 2009, 10:32:24 am »
yes. start codeblocks with sudo in terminal. it works