Discussion:
ipc message_queue getting permission denied
Matt Fair
2011-09-29 16:07:22 UTC
Permalink
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_ptr<boost::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
Ion Gaztañaga
2011-09-29 20:31:39 UTC
Permalink
Post by Matt Fair
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
Matt Fair
2011-09-29 21:19:11 UTC
Permalink
I tried:
m_messageQueue = boost::shared_ptr<boost::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
Post by Matt Fair
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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ion Gaztañaga
2011-09-29 22:00:14 UTC
Permalink
Post by Matt Fair
m_messageQueue = boost::shared_ptr<boost::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
Matt Fair
2011-09-29 22:13:10 UTC
Permalink
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
Post by Ion Gaztañaga
      m_messageQueue =
boost::shared_ptr<boost::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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
V***@h-d-gmbh.de
2011-09-30 07:25:23 UTC
Permalink
Post by Matt Fair
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
Matt Fair
2011-09-30 08:00:31 UTC
Permalink
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
Post by V***@h-d-gmbh.de
Post by Matt Fair
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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...