[Boost-users] ipc message_queue getting permission denied

559 views
Skip to first unread message

Matt Fair

unread,
Sep 29, 2011, 12:07:22 PM9/29/11
to boost...@lists.boost.org
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
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Ion Gaztañaga

unread,
Sep 29, 2011, 4:31:39 PM9/29/11
to Boost User List
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

Matt Fair

unread,
Sep 29, 2011, 5:19:11 PM9/29/11
to boost...@lists.boost.org
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

2011/9/29 Ion Gaztañaga <igazt...@gmail.com>:

Ion Gaztañaga

unread,
Sep 29, 2011, 6:00:14 PM9/29/11
to Boost User List
El 29/09/2011 23:19, Matt Fair escribió:
> 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?

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.

Matt Fair

unread,
Sep 29, 2011, 6:13:10 PM9/29/11
to boost...@lists.boost.org
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 <igazt...@gmail.com>:

Viatchesla...@h-d-gmbh.de

unread,
Sep 30, 2011, 3:25:23 AM9/30/11
to boost...@lists.boost.org
> 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

unread,
Sep 30, 2011, 4:00:31 AM9/30/11
to boost...@lists.boost.org
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
Reply all
Reply to author
Forward
0 new messages