2009-10-19 59 views
3

我有一個服務器應用程序,可以使用inetd爲客戶端召喚。但是,如果我嘗試附加到使用inetd啓動的服務器進程,則會得到以下響應:ptrace:Operation not permitted。爲什麼gdb無法附加到使用inetd召喚的服務器應用程序?

gdb --annotate=3 /my/app/here <processId> 

Current directory is /usr/local/bin/ 
GNU gdb 6.8 
Copyright (C) 2008 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "i686-pc-linux-gnu"... 
Reading symbols from /usr/local/bin/flumed...done. 
Using host libthread_db library "/lib/tls/libthread_db.so.1". 
Attaching to program: /my/app/here, process <processId> 
ptrace: Operation not permitted. 
/usr/local/bin/<processId>: No such file or directory. 
(gdb) 
+0

你運行GDB的根源? – 2009-10-19 03:17:13

+1

'ptrace:不允許操作.'正如Alex建議的那樣,將GDB作爲與服務相同的UID或以root身份運行。 – ephemient 2009-10-19 03:39:32

+0

不,不是root,但ps顯示我自己擁有的pid。 – WilliamKF 2009-10-19 14:43:14

回答

2

很明顯,事情變得非常時髦,其中userid不是root用戶。你最終得到一個具有奇怪權限的進程。例如,即使權限是777,您也無法讀取/ proc/self/exe。我懷疑這個問題更多。儘管我是流程的用戶名,但我沒有權限。使用root用於gdb是一種解決方法。

7

解決方案對我來說是這樣的:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope 
+2

據我所知,這是一個可以在Ubuntu上運行但在Debian上運行的解決方案。請參閱http://blog.mellenthin.de/archives/2010/10/18/gdb-attach-fails-with-ptrace-operation-not-permitted/和https://wiki.ubuntu.com/SecurityTeam/Roadmap/ KernelHardening#ptrace%20Protection – Ztyx 2011-07-14 08:21:17

0

我也看到了,因爲我沒有正確關閉時GDB GDB的多個實例同時運行出現這個問題,通常。關閉這些泄漏的實例解決了這個問題。

2

除了tgoodhart說的,其他ptrace用戶喜歡/usr/bin/strace也會阻止gdb

+0

雖然這不是發生在這種情況下。 – WilliamKF 2013-03-24 12:09:00

-1

請運行下面的命令來解決問題烏爾:

須藤搭配chmod + S在/ usr /斌/ GDB

相關問題