ipc message_queue getting permission denied
Hello, I ran across this problem when I moved my code to another system. Not sure if this is the right list to post this, but I've been having trouble debugging this as all of my attempts have lead me to dead ends. I have the following code with boost 1.47: try { m_messageQueue = boost::shared_ptrboost::interprocess::message_queue( new boost::interprocess::message_queue ( boost::interprocess::open_or_create ,name.c_str() //name ,numElements //max message number ,sizeof(Message) //max message size )); } catch(boost::interprocess::interprocess_exception &e) { cerr << e.what(); } where name="test_queue", numElements=100, and sizeof(Message)=256. The output is: Permission denied If I run as user root, it will pass. I can't figure out where it is trying to write to where it would have a permission error. Looking at the boost code, shouldn't it just be in /tmp/boost_interprocess which any user would have access to create and write to? Also, I noticedhttps://svn.boost.org/trac/boost/ticket/4250, but this should be fixed now. Any help or insight would be appreciated. Thanks, Matt
El 29/09/2011 18:07, Matt Fair escribió:
Hello,
I ran across this problem when I moved my code to another system. Not sure if this is the right list to post this, but I've been having trouble debugging this as all of my attempts have lead me to dead ends.
The container is built with default permissions (0644 in unix), you'd need provide you own permissions in message queue constructor instead of the default permissions() parameter. Best, Ion
I tried:
m_messageQueue = boost::shared_ptrboost::interprocess::message_queue(
new boost::interprocess::message_queue (
boost::interprocess::open_or_create
,name.c_str() //name
,numElements //max message number
,sizeof(Message) //max message size
,boost::interprocess::permissions(777)
));
And got the same results as before with Permission denied. Am I doing
something wrong?
Thanks,
Matt
2011/9/29 Ion Gaztañaga
El 29/09/2011 18:07, Matt Fair escribió:
Hello,
I ran across this problem when I moved my code to another system. Not sure if this is the right list to post this, but I've been having trouble debugging this as all of my attempts have lead me to dead ends.
The container is built with default permissions (0644 in unix), you'd need provide you own permissions in message queue constructor instead of the default permissions() parameter.
Best,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
El 29/09/2011 23:19, Matt Fair escribió:
I tried: m_messageQueue = boost::shared_ptrboost::interprocess::message_queue( new boost::interprocess::message_queue ( boost::interprocess::open_or_create ,name.c_str() //name ,numElements //max message number ,sizeof(Message) //max message size ,boost::interprocess::permissions(777) ));
And got the same results as before with Permission denied. Am I doing something wrong?
Maybe it's a bug, can you check if /tmp/boost_interprocess has enough permissions to create a file? We can try to erase it and see if the library is creating it with wrong permissions. Best, Ion
The code as is, the /tmp/boost_interprocess is not created, which made
me wonder if the shared memory handle is trying to be made somewhere
else. If I call boost::iterprocess::detail::create_tmp_and_clean_old,
it creates /tmp/boost_interprocess with 777 permissions. However even
if this folder is created with the correct write access, I still get
Permission denied when not root user. Which brings me back to my
theory that something else is going on with the shared memory handle
that it isn't being created in /tmp/boost_interprocess. Also to note,
my /tmp dir is also 777.
Thanks,
Matt
2011/9/29 Ion Gaztañaga
El 29/09/2011 23:19, Matt Fair escribió:
I tried: m_messageQueue = boost::shared_ptrboost::interprocess::message_queue( new boost::interprocess::message_queue ( boost::interprocess::open_or_create ,name.c_str() //name ,numElements //max message number ,sizeof(Message) //max message size ,boost::interprocess::permissions(777) ));
And got the same results as before with Permission denied. Am I doing something wrong?
Maybe it's a bug, can you check if /tmp/boost_interprocess has enough permissions to create a file? We can try to erase it and see if the library is creating it with wrong permissions.
Best,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
That did it! It said it was storing the shared memory in /dev/shm,
changed the permissions of that directory and everything worked.
Thank you very much!!!
Matt
On Fri, Sep 30, 2011 at 1:25 AM,
The code as is, the /tmp/boost_interprocess is not created, which made me wonder if the shared memory handle is trying to be made somewhere else.
Use strace to find it out
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Ion Gaztañaga
-
Matt Fair
-
Viatcheslav.Sysoltsev@h-d-gmbh.de