为什么 gdb 无法附加到使用 inetd 调用的服务器应用程序?

发布于 2024-08-08 08:19:58 字数 848 浏览 12 评论 0原文

我有一个服务器应用程序,可以使用 inetd 为客户端调用。但是,如果我尝试附加到使用 inetd 启动的服务器进程,我会收到以下响应: ptrace:不允许操作。

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) 

I have a server application that can be summoned for the client using inetd. However, if I try to attach to the server process that was launched with inetd, I get the following response: ptrace: Operation not permitted.

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) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

我一直都在从未离去 2024-08-15 08:19:58

我的解决方案是这样的:

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

Solution for me was this:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
驱逐舰岛风号 2024-08-15 08:19:58

显然,当用户 ID 不是 root 时,inetd 的情况会变得很奇怪。您最终会得到一个具有奇怪权限的进程。例如,即使权限为777,您也无法读取/proc/self/exe。我怀疑这个问题更多相同。尽管我是该进程的用户ID,但我没有权限。使用 root 运行 gdb 是一种解决方法。

Apparently, things get funky with inetd where the userid is not root. You end up with a process with weird permissions. For example, you are unable to read /proc/self/exe even though the permissions are 777. I suspect this issue is more of the same. Even though I'm the userid of the process, I don't have permissions. Using root for gdb is a work around.

酒废 2024-08-15 08:19:58

根据 tgoodhart 的说法,其他 ptrace 用户(例如 /usr/bin/strace)也会阻止 gdb。

Further to what tgoodhart said, other ptrace users like /usr/bin/strace will also block gdb.

等待我真够勒 2024-08-15 08:19:58

我还看到当多个 gdb 实例同时运行时会出现此问题,通常是因为我未能正确关闭 gdb。关闭这些泄露的实例解决了问题。

I have also seen this problem occur when multiple instances of gdb are running at the same time, usually because I failed to close gdb correctly. Closing these leaked instances fixed the problem.

月朦胧 2024-08-15 08:19:58

请运行以下命令来解决您的问题:

sudo chmod +s /usr/bin/gdb

Pls run the following command to solve ur problem:

sudo chmod +s /usr/bin/gdb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文