linux Capability.h 如何对 34 个元素使用 32 位掩码?
/usr/include/linux/capability.h
中的文件#定义了 34 种可能的功能。 它是这样的:
#define CAP_CHOWN 0
#define CAP_DAC_OVERRIDE 1
.....
#define CAP_MAC_ADMIN 33
#define CAP_LAST_CAP CAP_MAC_ADMIN
每个进程都有这样定义的功能
typedef struct __user_cap_data_struct {
__u32 effective;
__u32 permitted;
__u32 inheritable;
} * cap_user_data_t;
我很困惑 - 一个进程可以有 32 位的有效功能,但在 Capability.h 中定义的功能总数是 34。如何在一个进程中编码 34 个位置32 位掩码?
The file in /usr/include/linux/capability.h
#defines 34 possible capabilities.
It goes like:
#define CAP_CHOWN 0
#define CAP_DAC_OVERRIDE 1
.....
#define CAP_MAC_ADMIN 33
#define CAP_LAST_CAP CAP_MAC_ADMIN
each process has capabilities defined thusly
typedef struct __user_cap_data_struct {
__u32 effective;
__u32 permitted;
__u32 inheritable;
} * cap_user_data_t;
I'm confused - a process can have 32-bits of effective capabilities, yet the total amount of capabilities defined in capability.h is 34. How is it possible to encode 34 positions in a 32-bit mask?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为你还没有读完说明书。
capget 手册首先说服您不要使用它:
当前详细信息
,其中
datap
之前被定义为指向__user_cap_data_struct
的指针。因此,您只需在两个__user_cap_data_struct
数组中用两个__u32
表示 64 位值。仅这一点就告诉我永远不要使用这个 API,所以我没有阅读手册的其余部分。
Because you haven't read all of the manual.
The capget manual starts by convincing you to not use it :
Current details
where
datap
is defined earlier as a pointer to a__user_cap_data_struct
. So you just represent a 64bit values with two__u32
in an array of two__user_cap_data_struct
.This, alone, tells me to not ever use this API, so i didn't read the rest of the manual.
它们不是位掩码,它们只是常量。 EG
CAP_MAC_ADMIN
设置多个位。在二进制中,33 是什么,10001?They aren't bit-masks, they're just constants. E.G.
CAP_MAC_ADMIN
sets more than one bit. In binary, 33 is what, 10001?