当段已经存在时,如何使用 shmget 权限位?
How are shmget permission bits used when the segment already exists?
假设我使用以下参数调用 shmget
:
int shmid = shmget(KEY, 1024*4096, IPC_CREAT|0644);
进一步,假设具有关键字 KEY
的段已经存在。 shmget
的 shmflg
参数(在本例中为 0644
)中的权限模式位或如何影响 shmget
的行为? shmget
是否对具有这些权限标志的段的权限执行任何类型的“权限验证?具体来说,该验证需要什么?
How do the permission mode bits OR'd into the shmflg argument
[...] of shmget
affect shmget
's behavior?
POSIX 对于指定键已经存在共享内存段的情况,在这个问题上解释起来有点棘手,但其意图似乎是它与 [=13 的操作类似=].即如果进程的uid、gid和请求的mode与段的uid、gid、权限不一致,则函数失败。具体来说,
The shmget()
function shall fail if: [...] A shared memory identifier exists for key but operation permission as specified by the low-order nine bits of shmflg
would not be granted [...].
shmget()
的 Linux 联机帮助页有类似的文字,还特别指出
If the shared memory segment already exists, the permissions are verified [...].
这与 POSIX 没有什么不同,只是更明确。
Another section of POSIX 提供了更多细节,归结为根据进程的 euid 和 egid 根据适用于该进程的一组权限位来授予或拒绝读取/和/或写入访问权限。
Does shmget perform any kind of "permission verification on the permissions of the segment with these permission flags? Specifically what does that verification entail?
是的,如上文和链接的 POSIX 规范中所述。
我还是有点不清楚 "operation permission as specified by the low-order nine bits of shmflg
" 是什么。可以将其解释为调用进程在创建段时对段具有的权限,但我认为这实际上意味着 shmflag
中打开的所有模式位也在 shmflag
中打开段的权限字段。
假设我使用以下参数调用 shmget
:
int shmid = shmget(KEY, 1024*4096, IPC_CREAT|0644);
进一步,假设具有关键字 KEY
的段已经存在。 shmget
的 shmflg
参数(在本例中为 0644
)中的权限模式位或如何影响 shmget
的行为? shmget
是否对具有这些权限标志的段的权限执行任何类型的“权限验证?具体来说,该验证需要什么?
How do the permission mode bits OR'd into the
shmflg argument
[...] ofshmget
affectshmget
's behavior?
POSIX 对于指定键已经存在共享内存段的情况,在这个问题上解释起来有点棘手,但其意图似乎是它与 [=13 的操作类似=].即如果进程的uid、gid和请求的mode与段的uid、gid、权限不一致,则函数失败。具体来说,
The
shmget()
function shall fail if: [...] A shared memory identifier exists for key but operation permission as specified by the low-order nine bits ofshmflg
would not be granted [...].
shmget()
的 Linux 联机帮助页有类似的文字,还特别指出
If the shared memory segment already exists, the permissions are verified [...].
这与 POSIX 没有什么不同,只是更明确。
Another section of POSIX 提供了更多细节,归结为根据进程的 euid 和 egid 根据适用于该进程的一组权限位来授予或拒绝读取/和/或写入访问权限。
Does shmget perform any kind of "permission verification on the permissions of the segment with these permission flags? Specifically what does that verification entail?
是的,如上文和链接的 POSIX 规范中所述。
我还是有点不清楚 "operation permission as specified by the low-order nine bits of shmflg
" 是什么。可以将其解释为调用进程在创建段时对段具有的权限,但我认为这实际上意味着 shmflag
中打开的所有模式位也在 shmflag
中打开段的权限字段。