Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
GDB needs root?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
GeekOfSpades
Guest





PostPosted: Mon Jul 15, 2002 12:06 am    Post subject: GDB needs root? Reply with quote

I'm having some trouble with running GDB as non-root.

Given an executable /home/hawkeye/c/tx/tx compiled with -ggdb3 -Wall -pipe

% ls -l /home/hawkeye/c/tx/tx
-rwxr-xr-x 1 hawkeye users 702042 Jul 16 00:01 my_exe

% gdb /home/hawkeye/c/tx/tx
* SNIP GDB OUTPUT *
(gdb) run
Starting program: /home/hawkeye/c/tx/tx
Cannot exec : No such file or directory.

Program exited with code 0177.
You can't do that without a process to debug.
(gdb)

Now when root attempts the same thing, gdb runs with no complaints. Even chmod a+s /usr/bin/gdb doesn't do the trick?

Can anybody provide any insight? (gdb was compiled with -O2 -pipe, but I don't see how that could affect it...)

Thanks
Back to top
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Mon Jul 15, 2002 1:56 am    Post subject: Re: GDB needs root? Reply with quote

gdb does not like its sticky bit changed. You need to do "chmod a-s..." first. The "You can't do that without a process to debug" error is because of the sticky bit.

The exec error may come from an "execv." or "execl." function call in the program itself that tries to launch an executable that it cannot "find".

GeekOfSpades wrote:
I'm having some trouble with running GDB as non-root.

Given an executable /home/hawkeye/c/tx/tx compiled with -ggdb3 -Wall -pipe

% ls -l /home/hawkeye/c/tx/tx
-rwxr-xr-x 1 hawkeye users 702042 Jul 16 00:01 my_exe

% gdb /home/hawkeye/c/tx/tx
* SNIP GDB OUTPUT *
(gdb) run
Starting program: /home/hawkeye/c/tx/tx
Cannot exec : No such file or directory.

Program exited with code 0177.
You can't do that without a process to debug.
(gdb)

Now when root attempts the same thing, gdb runs with no complaints. Even chmod a+s /usr/bin/gdb doesn't do the trick?

Can anybody provide any insight? (gdb was compiled with -O2 -pipe, but I don't see how that could affect it...)

Thanks
Back to top
View user's profile Send private message
GeekOfSpades
Guest





PostPosted: Mon Jul 15, 2002 5:36 am    Post subject: K... tried that... Reply with quote

Removing the stick bit didn't change the error message at all. In regards the exec* call, under what circumstances do you think root would be able to run a program, whereas a normal user would be unable to even locate the file?

I might guess that it's a permission problem. IE, gdb doesn't have access to the file, therefore can not find it. I'd assume though gdb would be more forthcoming with that information (a la "Permission Denied") On top of that, the permissions seem quite fine. My non-root self has no problem cd'ing into the directory and running the executable. Or any executable on the system for that matter.

I must say this has me confounded...
Back to top
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Mon Jul 15, 2002 2:12 pm    Post subject: Re: K... tried that... Reply with quote

I tried gdb on a simple program just to make sure things are OK. On my box, there are no problems. Re: exec*: you may not have permissions to the read the file, list files in the directory, execute permissions to the file, etc. If you see something like:
-rwxr-xr-- root root ...
for the directory permissions, you will not be able to list files in the directory nor run them. You can do "chmod ..." to ensure that the files and/or directory have right permissions.

Try compiling a simple hello.c in the user directory and then see whether you can debug it.
GeekOfSpades wrote:
Removing the stick bit didn't change the error message at all. In regards the exec* call, under what circumstances do you think root would be able to run a program, whereas a normal user would be unable to even locate the file?

I might guess that it's a permission problem. IE, gdb doesn't have access to the file, therefore can not find it. I'd assume though gdb would be more forthcoming with that information (a la "Permission Denied") On top of that, the permissions seem quite fine. My non-root self has no problem cd'ing into the directory and running the executable. Or any executable on the system for that matter.

I must say this has me confounded...
Back to top
View user's profile Send private message
GeekOfSpades
Guest





PostPosted: Mon Jul 15, 2002 3:21 pm    Post subject: Permissions don't seem to be the problem... Reply with quote

Permissions don't seem to be the problem... observe...

Code:

bash-2.05a$ whoami
hawkeye
bash-2.05a$ pwd
/
bash-2.05a$ ls -l
 ...
drwxr-xr-x    4 root     root           44 Jul 14 05:20 home
 ...
bash-2.05a$ cd home
bash-2.05a$ ls -l
drwxr-xr-x   14 hawkeye  users        4096 Jul 16 15:09 hawkeye
bash-2.05a$5a$ cd hawkeye
bash-2.0bash-2.05a$ ls -l
 ...
drwxr-xr-x   25 hawkeye  users        4096 Jul 14 19:55 c
 ...
bash-2.05a$ cd c
bash-2.05a$ ls -l
 ...
drwxr-xr-x    2 hawkeye  users        4096 Jul 16 00:01 tx
bash-2.05a$ cd tx
cbash-2.05a$ ls -l
  ...
-rwxr-xr-x    1 hawkeye  users      702042 Jul 16 00:01 tx
  ...
bash-2.05a$


And there you have it. Doesn't seem to be any permissions problems, like I said, but I'm incapable of debugging tx, or anything, anywhere, unless I'm root.[/i]
Back to top
AstroBoy
n00b
n00b


Joined: 18 Nov 2002
Posts: 8

PostPosted: Sat Mar 01, 2003 7:33 pm    Post subject: I know why Reply with quote

The same problem is described here: https://forums.gentoo.org/viewtopic.php?t=9857&highlight=gdb+cannot+run
They solved it with setting $SHELL. It even worked for me.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum