LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   mq_open-> Permission denied (https://www.linuxquestions.org/questions/linux-software-2/mq_open-permission-denied-4175472118/)

Niraj Kulkarni 08-05-2013 12:15 AM

mq_open-> Permission denied
 
Hi,

I am facing "mq_open-> Permission denied" problem while trying to open POSIX message queue. Can any one tell me why "Permission denied".

Here are related information:

1. I am using Linux ubuntu 2.6.32-33.
2. Args passed to mq_open : mq_path = /root/mq,
oflag = O_CREAT|O_WRONLY,
mode = 0666
mq_attribute->mq_maxmsg = 1;
mq_attribute->mq_msgsize = 10;
mq_attribute->mq_flags = 0;
mq_attribute->mq_curmsgs = 0;
3. I am root.

Regards
Niraj Kulkarni.

TB0ne 08-05-2013 09:11 AM

Quote:

Originally Posted by Niraj Kulkarni (Post 5002970)
Hi,
I am facing "mq_open-> Permission denied" problem while trying to open POSIX message queue. Can any one tell me why "Permission denied". Here are related information:
1. I am using Linux ubuntu 2.6.32-33.
2. Args passed to mq_open : mq_path = /root/mq,
oflag = O_CREAT|O_WRONLY,
mode = 0666
mq_attribute->mq_maxmsg = 1;
mq_attribute->mq_msgsize = 10;
mq_attribute->mq_flags = 0;
mq_attribute->mq_curmsgs = 0;
3. I am root.

There are a few solutions posted, one on this site, but they center around (obviously enough), a permissions issue on the object, specifically either the mode or oflag:
http://www.linuxquestions.org/questi...ileges-867954/
http://manpages.ubuntu.com/manpages/....2freebsd.html
http://www.freag.net/en/t/3aaw7/mq_open_permiss

From the documentation:
Quote:

Originally Posted by mq_open Docs
O_WRONLY
Open the queue for sending messages. The process can use the returned message queue descriptor with the mq_send subroutine but not the mq_receive subroutine. A message queue may be open multiple times in the same or different processes for sending messages.

...and depending on how your program is working, that may explain it. If you're trying to use the mq_receive subroutine, it'll fail, but the send will work. Have you tried O_RDWR instead of O_WRONLY?


All times are GMT -5. The time now is 10:13 PM.