简体   繁体   English

可以在Linux上的跨用户使用POSIX消息队列吗?

[英]Can POSIX message queues be used cross user on Linux?

I have implemented a POSIX message queue. 我已经实现了POSIX消息队列。 On the listener side, I am opening the queue like this: 在侦听器方面,我这样打开队列:

mqdes = mq_open(s_mailbox_name.c_str(), O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, NULL);

On the sender side, I am opening the queue like this: 在发送方,我像这样打开队列:

mqdes = mq_open(m_s_mailbox_name.c_str(), O_WRONLY);

The string is the same on both, lets call it /foobox 两者上的字符串相同,我们将其/foobox/foobox

Now, when I run both the sender and receiver as the same user on the box, everything works perfectly. 现在,当我在盒子上以同一用户身份运行发送者和接收者时,一切都可以正常运行。 However If the sender and receiver are 2 different users, the receiver can not open the queue. 但是,如果发送者和接收者是2个不同的用户,则接收者无法打开队列。 I would think this wouldn't be a problem because I am opening the queue as 0777 above so everyone can RWX. 我认为这不会有问题,因为我将队列设置为上面的0777,因此每个人都可以RWX。

Is there something obvious i'm doing wrong? 我做错什么了吗? Or is this not possible (Please don't let it be this one) 还是这不可能(请不要让它成为这个)

Thanks 谢谢

Check umask . 检查umask

From man mq_open : "The permissions settings are masked against the process umask." 来自man mq_open :“权限设置针对进程umask进行屏蔽。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM