普通用户无法读取/proc/net/dev

发布于 2024-12-28 12:08:35 字数 1394 浏览 0 评论 0原文

我很确定我在这里遗漏了一些东西,但我不确定到底是什么:

这是 root 可以看到的内容:

root@opteron16:/# ls -l | grep proc
dr-xr-xr-x 290 root root     0 2012-01-14 02:03 proc
root@opteron16:/# ls -l proc | grep net
lrwxrwxrwx  1 root       root        8 2012-01-21 03:29 net -> self/net
root@opteron16:/# ls -l proc/net/ | grep dev
-r--r--r-- 1 root root 0 2012-01-14 02:05 dev

这是 ganglia 用户:

root@opteron16:/# cat /etc/passwd | grep ganglia
ganglia:x:111:119:Ganglia Monitor:/var/lib/ganglia:/bin/false

当我尝试使用此用户访问 /proc/net/dev 时:

root@opteron16:/# su -s /bin/bash ganglia
ganglia@opteron16:/$ ls -l /proc | grep net
lrwxrwxrwx  1 root    root     8 2012-01-21 19:49 net -> self/net
ganglia@opteron16:/$ ls -l /proc/net/
ls: reading directory /proc/net/: Invalid argument
total 0
ganglia@opteron16:/$ cat /proc/net/dev
cat: /proc/net/dev: No such file or directory

如果不觉得自己很愚蠢就太好了:)。


编辑

这是我注意到的事情,我以前从未见过这样的行为:

root@opteron16:/proc# ls -l | grep "self -"
lrwxrwxrwx  1 root       root       64 2012-01-22 00:01 self -> 29095
root@opteron16:/proc# ls -l | grep "self -"
lrwxrwxrwx  1 root       root       64 2012-01-22 00:01 self -> 29097
root@opteron16:/proc# ls -l | grep "self -"
lrwxrwxrwx  1 root       root       64 2012-01-22 00:01 self -> 29099

I'm pretty sure that I'm missing something here, but I'm not sure exactly what:

This is what root can see:

root@opteron16:/# ls -l | grep proc
dr-xr-xr-x 290 root root     0 2012-01-14 02:03 proc
root@opteron16:/# ls -l proc | grep net
lrwxrwxrwx  1 root       root        8 2012-01-21 03:29 net -> self/net
root@opteron16:/# ls -l proc/net/ | grep dev
-r--r--r-- 1 root root 0 2012-01-14 02:05 dev

This is the ganglia user:

root@opteron16:/# cat /etc/passwd | grep ganglia
ganglia:x:111:119:Ganglia Monitor:/var/lib/ganglia:/bin/false

When I try to access /proc/net/dev with this user:

root@opteron16:/# su -s /bin/bash ganglia
ganglia@opteron16:/$ ls -l /proc | grep net
lrwxrwxrwx  1 root    root     8 2012-01-21 19:49 net -> self/net
ganglia@opteron16:/$ ls -l /proc/net/
ls: reading directory /proc/net/: Invalid argument
total 0
ganglia@opteron16:/$ cat /proc/net/dev
cat: /proc/net/dev: No such file or directory

Would be great to not feel this stupid : ).


Edit

This is something which I've noticed and I've never seen such a behaviour before:

root@opteron16:/proc# ls -l | grep "self -"
lrwxrwxrwx  1 root       root       64 2012-01-22 00:01 self -> 29095
root@opteron16:/proc# ls -l | grep "self -"
lrwxrwxrwx  1 root       root       64 2012-01-22 00:01 self -> 29097
root@opteron16:/proc# ls -l | grep "self -"
lrwxrwxrwx  1 root       root       64 2012-01-22 00:01 self -> 29099

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

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

发布评论

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

评论(2

彩扇题诗 2025-01-04 12:08:35

这很可能是由于您的内核是用 grsec 编译的。即

$ uname -a
Linux xxxx 3.2.13-grsec-xxxx-grs-ipv6-64 #1 SMP Thu Mar 29 09:48:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

我已经在 ovh 托管的服务器上看到这种情况发生,因为这是他们为您安装的默认内核,以便通过他们的管理工具启用网络启动。

总而言之,你可以执行以下操作之一:

  1. 以 root 身份运行你的程序(+1 用于安全 ovh!)
  2. 在这个盒子上安装默认的 ubuntu 内核
  3. 尖叫一会儿(我最喜欢的)

Most likely, this is due to your kernel that has been compiled with grsec. i.e.

$ uname -a
Linux xxxx 3.2.13-grsec-xxxx-grs-ipv6-64 #1 SMP Thu Mar 29 09:48:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

I have seen this happen on servers hosted by ovh since this is the default kernel they install for you to enable netboot through their admin tools.

To summarize, you can do one of:

  1. run your program as root (+1 for security ovh !)
  2. install the default ubuntu kernel on this box
  3. scream for a while (my favorite)
記柔刀 2025-01-04 12:08:35

我无法在我的 ubuntu 上复制这个

也许你的系统有某种 chroot'd shell?

cat /proc/self/net/dev 对您的“ganglia”用户有用吗?

I can't replicate this on my ubuntu

Maybe your system has some kind of chroot'd shells?

Does cat /proc/self/net/dev work for your "ganglia" user?

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